track-gate: plain text IS the deliverable - the skill told the agent to write JSON (goal line said 'PRIMARY deliverable is prompt_override.json'; smoke test, file lists, Step 4 and Step 5A all JSON-centric), so it kept writing the old format; now the paste is plain text end to end: verify_track_rules gains validate_prompt_override_text (mirror of the pack's parse_override_segments: split on |, strip, drop empties, trailing [s-e(,type)] marker lifted, @imageN/@audioN/@videoN refs vs inventory, <Picture N> and stray @ rejected, marker frames/types pinned to the approved rows, markerless form requires equal row lengths, markers all-or-nothing) + build_plain_text_override (fragment text VERBATIM - newlines survive, six-section structure intact - not the JSON's collapsed prompts; bare-| join, byte-identical to the user's proven node186 paste) and the override command takes .txt or .json; build_track_plan writes prompt_override.txt for EVERY zero-media story (markers auto-added for uneven lengths / non-t2v types), media stories keep JSON-only with an explicit note; SKILL.md/README/schema/wiring docs flipped: plain text default, JSON demoted to the <Picture N>/continuity/locks option; suite 46/46; merge output proven byte-identical to prompt_override_r2v_refmod.txt

This commit is contained in:
Z User 2026-11-02 22:26:53 +00:00
parent bbd46a4764
commit 3587e676fa
7 changed files with 535 additions and 109 deletions

View File

@ -5,9 +5,15 @@ patch plan** for the ComfyUI-Easy-Media nodes (`easy multiTrackEditor` +
`easy multitrackProject`), built with the same outline → approval → one-segment-per-turn → `easy multitrackProject`), built with the same outline → approval → one-segment-per-turn →
merge → gate flow as `h3-plan-gate`, adapted to the Easy-Media multitrack schema. merge → gate flow as `h3-plan-gate`, adapted to the Easy-Media multitrack schema.
The deliverable is a `plan.json` patch plan that the node pack's own The PRIMARY deliverable is a **plain-text `prompt_override` paste** (`prompt_override.txt`:
`skills/easy-media-multitrack-workflow/scripts/patch_workflow.py apply` consumes — it is the scene prompts joined with `|` on one line, `[start-end(,type)]` markers where scene
not pasted into a widget. lengths differ or a scene is not t2v) for the `easy multiTrackEditor` node's
`prompt_override` input (format `MiniMax`) — the editor splits on pipes and renders one
clip per scene, no JSON needed. `prompt_override.json` (a `minimax_prompt_override`
payload) is the option for what plain text cannot carry (`<Picture N>` media tokens,
continuity modes, track locks), and `plan.json` is the whole-workflow alternative applied
by the node pack's own `skills/easy-media-multitrack-workflow/scripts/patch_workflow.py
apply`.
## What the gate enforces ## What the gate enforces
@ -18,6 +24,7 @@ not pasted into a widget.
| Verbatim media contract | Every `file_path` in fragments and locked tracks must be a character-for-character copy of the outline's `media_inventory` entry (the same discipline `h3-plan-gate` applies to refmods; a retyped path fails with a closest-match hint) | | Verbatim media contract | Every `file_path` in fragments and locked tracks must be a character-for-character copy of the outline's `media_inventory` entry (the same discipline `h3-plan-gate` applies to refmods; a retyped path fails with a closest-match hint) |
| Context prompt rules | Self-contained prompts in every mode (no "same as before"); context/context_drift joins must open by keeping the delivered tail and must not open with a new composition; a join followed by another join must not end at rest | | Context prompt rules | Self-contained prompts in every mode (no "same as before"); context/context_drift joins must open by keeping the delivered tail and must not open with a new composition; a join followed by another join must not end at rest |
| Drift discipline | `context_drift` is all-or-nothing across the task range (first segment included), with the consecutive 10-second split unless the user pinned lengths | | Drift discipline | `context_drift` is all-or-nothing across the task range (first segment included), with the consecutive 10-second split unless the user pinned lengths |
| Paste payload | `prompt_override` re-checked against the guide in BOTH forms: plain text (scene count/order, `[s-e,type]` markers vs the approved row frames and task types, `@imageN/@audioN/@videoN` refs vs the inventory, `<Picture N>` and stray `@` rejected) and JSON payload (durations, generation/continuity modes, exact `<Picture N>` sets, track locks) |
## Folder ## Folder
@ -25,12 +32,14 @@ not pasted into a widget.
easy-media-track-gate/ easy-media-track-gate/
├── SKILL.md agent procedure (the entry point) ├── SKILL.md agent procedure (the entry point)
├── README.md this file ├── README.md this file
├── verify_track_rules.py the gate: outline / segment / trackdata / plan / suite ├── verify_track_rules.py the gate: outline / segment / trackdata / plan / override / suite
├── build_track_plan.py merge fragments → TRACK_DATA + patch plan.json ├── build_track_plan.py merge fragments → prompt_override.txt/.json + TRACK_DATA + patch plan.json
├── references/ ├── references/
│ └── track-schema.md English translation of the node pack's Chinese │ └── track-schema.md English translation of the node pack's Chinese
│ multitrack-schema.md (all field names preserved) │ multitrack-schema.md (all field names preserved)
└── examples/ worked 3-segment example: outline, segments, plan, track_data └── examples/ worked 3-segment example: outline, segments, plan, track_data,
paste payloads (prompt_override.json + the plain-text
prompt_override_r2v_refmod.txt with its outline_sam_park.json)
``` ```
Standard library only; Windows-first (`py -3`), runs anywhere Python 3.8+ lives. Standard library only; Windows-first (`py -3`), runs anywhere Python 3.8+ lives.
@ -59,9 +68,13 @@ py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py"
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" segment segment_01.json --index 1 --outline outline.json py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" segment segment_01.json --index 1 --outline outline.json
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" segment segment_02.json --index 2 --prev segment_01.json --outline outline.json py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" segment segment_02.json --index 2 --prev segment_01.json --outline outline.json
:: merge everything (writes plan.json + track_data.json) :: merge everything (writes prompt_override.txt + prompt_override.json + plan.json + track_data.json)
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" outline.json segment_01.json segment_02.json segment_03.json -o plan.json py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" outline.json segment_01.json segment_02.json segment_03.json -o plan.json
:: validate the paste payloads (plain text is the default form; JSON the option)
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override prompt_override.txt --outline outline.json
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override prompt_override.json --outline outline.json
:: apply with the node pack's own script (dry-run, then write) :: apply with the node pack's own script (dry-run, then write)
py -3 <ComfyUI>\custom_nodes\ComfyUI-Easy-Media\skills\easy-media-multitrack-workflow\scripts\patch_workflow.py apply WORKFLOW.json --plan plan.json py -3 <ComfyUI>\custom_nodes\ComfyUI-Easy-Media\skills\easy-media-multitrack-workflow\scripts\patch_workflow.py apply WORKFLOW.json --plan plan.json
py -3 <ComfyUI>\custom_nodes\ComfyUI-Easy-Media\skills\easy-media-multitrack-workflow\scripts\patch_workflow.py apply WORKFLOW.json --plan plan.json --output RESULT.json --write py -3 <ComfyUI>\custom_nodes\ComfyUI-Easy-Media\skills\easy-media-multitrack-workflow\scripts\patch_workflow.py apply WORKFLOW.json --plan plan.json --output RESULT.json --write

View File

@ -4,8 +4,9 @@ description: Turn a video idea into a validated MultiTrack plan for ComfyUI-Easy
(the `easy multiTrackEditor` node). Use when the user wants to plan task segments/shots (the `easy multiTrackEditor` node). Use when the user wants to plan task segments/shots
on the multitrack timeline, write or extend a MultiTrack timeline, arrange prompts, on the multitrack timeline, write or extend a MultiTrack timeline, arrange prompts,
reference images, master audio or reference-video locks, regenerate one task segment, reference images, master audio or reference-video locks, regenerate one task segment,
or produce the `prompt_override` paste payload for the multitrack editor node (plus the or produce the `prompt_override` paste for the multitrack editor node — plain text
optional patch plan JSON that `patch_workflow.py apply` consumes). The scripts and `scene1|scene2|...` by default — plus the optional patch plan JSON that
`patch_workflow.py apply` consumes. The scripts and
references live next to this SKILL.md (the skill's install folder); run them from the references live next to this SKILL.md (the skill's install folder); run them from the
user's working folder, where all generated files are written. user's working folder, where all generated files are written.
--- ---
@ -19,14 +20,20 @@ compose the task segments one at a time (about 10 seconds each), each turn exist
ONE segment gets a complete prompt, the right references and the right continuity mode → ONE segment gets a complete prompt, the right references and the right continuity mode →
the scripts verify schema, timing and continuity across the whole chain → the scripts verify schema, timing and continuity across the whole chain →
`build_track_plan.py` assembles the deliverables at the end. The PRIMARY deliverable is `build_track_plan.py` assembles the deliverables at the end. The PRIMARY deliverable is
`prompt_override.json`, a `minimax_prompt_override` payload the user pastes into the `prompt_override.txt` — PLAIN TEXT, the scene prompts joined with `|` on one line (the
multitrack editor node's `prompt_override` input (format `MiniMax`) — the editor then editor splits on pipes; no JSON), which the user pastes into the multitrack editor node's
renders one clip per prompt, chained back-to-back. The patch plan (`plan.json` for the node `prompt_override` input (format `MiniMax`) — the editor then renders one clip per scene,
pack's `patch_workflow.py`) is the optional whole-workflow alternative. Never deliver a plan chained back-to-back. The merge adds `[start-end]` / `[start-end,type]` markers per scene
that did not pass validation, and never compose a segment from a guide the user has not when the story needs them (unequal lengths, or a scene that is not the plain-text default
approved. Never hand the user any other JSON as the paste: a non-`minimax_prompt_override` t2v — e.g. r2v). `prompt_override.json` (a `minimax_prompt_override` payload) is the
value in `prompt_override` falls back to the editor's `|`-separated text parser and renders OPTION for what plain text cannot carry: `<Picture N>`/`<Audio N>`/`<Video N>` media
the whole story as ONE clip over the entire timeline. tokens, per-segment continuity modes, track locks. The patch plan (`plan.json` for the
node pack's `patch_workflow.py`) is the optional whole-workflow alternative. Never deliver
a plan that did not pass validation, and never compose a segment from a guide the user has
not approved. Never hand the user any other JSON as the paste: a non-
`minimax_prompt_override` value in `prompt_override` falls back to the editor's
`|`-separated text parser and renders the whole story as ONE clip over the entire
timeline — and never put `|` inside a scene prompt for the same reason.
## Paths and Python (read first — these exact forms prevent most errors) ## Paths and Python (read first — these exact forms prevent most errors)
@ -37,7 +44,8 @@ the whole story as ONE clip over the entire timeline.
Windows default install path; substitute your real SKILL_DIR if it differs. Windows default install path; substitute your real SKILL_DIR if it differs.
- Work in the user's **working folder** (the folder open in the editor). Write generated - Work in the user's **working folder** (the folder open in the editor). Write generated
files there: `outline.json`, `segment_01.json`, `segment_02.json`, …, `plan.json`, files there: `outline.json`, `segment_01.json`, `segment_02.json`, …, `plan.json`,
`track_data.json`. Never write generated files into SKILL_DIR. `track_data.json`, `prompt_override.txt`, `prompt_override.json`. Never write generated
files into SKILL_DIR.
- Python command: Windows `py -3` (or `python`); macOS/Linux `python3`. If the working - Python command: Windows `py -3` (or `python`); macOS/Linux `python3`. If the working
folder has a `.venv`, its interpreter works too (`.venv\Scripts\python.exe`). The scripts folder has a `.venv`, its interpreter works too (`.venv\Scripts\python.exe`). The scripts
need only the Python standard library — nothing to install. need only the Python standard library — nothing to install.
@ -49,11 +57,14 @@ the whole story as ONE clip over the entire timeline.
arrives cut no matter how large the context window is. A truncation notice is Cline's arrives cut no matter how large the context window is. A truncation notice is Cline's
read cap, not repo corruption — do not "fix" truncated files. `build_track_plan.py` read cap, not repo corruption — do not "fix" truncated files. `build_track_plan.py`
(~10 KB) and `references/track-schema.md` (~26 KB) are safe to read whole. (~10 KB) and `references/track-schema.md` (~26 KB) are safe to read whole.
- **Never read back `plan.json`, `track_data.json` or `prompt_override.json` once real - **Never read back `plan.json`, `track_data.json`, `prompt_override.txt` or
segments exist** — a 10-segment plan passes the read caps today and exceeds them `prompt_override.json` once real segments exist** — a 10-segment plan passes the read
tomorrow. Validate with `--check` / the `override` command and trust the one-line OK caps today and exceeds them tomorrow. Validate with `--check` / the `override` command
summary; the shipped `examples/prompt_override.json` (2.5 KB) and `examples/plan.json` (it takes BOTH the `.txt` paste and the `.json` payload) and trust the one-line OK
(6.8 KB) are safe to read if you need to see the shape. summary; the shipped `examples/prompt_override_r2v_refmod.txt` (7 KB, the worked
plain-text paste), `examples/outline_sam_park.json` (its guide),
`examples/prompt_override.json` (2.5 KB) and `examples/plan.json` (6.8 KB) are safe to
read if you need to see a shape.
- Cline's editor rejects writes over 6,000 characters ("Editor input too large"). A segment - Cline's editor rejects writes over 6,000 characters ("Editor input too large"). A segment
fragment with a rich prompt often does. NEVER write part 2 with write_to_file — it fragment with a rich prompt often does. NEVER write part 2 with write_to_file — it
replaces the whole file and part 1 is lost. Split instead: write the first part ending replaces the whole file and part 1 is lost. Split instead: write the first part ending
@ -69,12 +80,15 @@ the whole story as ONE clip over the entire timeline.
```sh ```sh
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py"
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" --check "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\plan.json" py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" --check "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\plan.json"
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\prompt_override_r2v_refmod.txt" --outline "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\outline_sam_park.json"
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\prompt_override.json" --outline "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\outline.json" py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\prompt_override.json" --outline "%USERPROFILE%\.agent\skills\easy-media-track-gate\examples\outline.json"
``` ```
Expect the suite to print `SUITE PASS (34/34 cases)` and the other two commands to print Expect the suite to print `SUITE PASS (46/46 cases)`, the `--check` to print `PLAN OK`
`PLAN OK` with `total_length 720 frames = 30.00s` and `OVERRIDE OK: 3 prompts, duration 10, with `total_length 720 frames = 30.00s`, the first `override` to print `OVERRIDE OK
total 30.00s`. (plain text): 3 scenes split on '|' with [start-end,type] markers, total 30.00s at 24 fps`
and the second `OVERRIDE OK (JSON payload): 3 prompts, duration 10 (default), total
30.00s`.
## Step 0 — Media paths come first (never invent one) ## Step 0 — Media paths come first (never invent one)
@ -277,60 +291,64 @@ Once every segment file passes, the merge is the continuity check: `build_track_
re-walks every fragment against the guide (ids, frames, modes, verbatim media paths, prompt re-walks every fragment against the guide (ids, frames, modes, verbatim media paths, prompt
rules, handoff chain), assembles the TRACK_DATA (task track from the fragments; the locked rules, handoff chain), assembles the TRACK_DATA (task track from the fragments; the locked
master-audio / reference-video tracks built straight from the outline), computes master-audio / reference-video tracks built straight from the outline), computes
`total_length`, builds the `minimax_prompt_override` paste payload from the same validated `total_length`, builds the paste payload from the same validated fragments in BOTH forms,
fragments, and only then writes the deliverables. Never write the plan by hand and never and only then writes the deliverables. Never write the plan by hand and never edit
edit fragment prose during the merge. fragment prose during the merge.
```sh ```sh
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" outline.json segment_01.json segment_02.json segment_03.json -o plan.json py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" outline.json segment_01.json segment_02.json segment_03.json -o plan.json
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" --check plan.json --outline outline.json py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\build_track_plan.py" --check plan.json --outline outline.json
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override prompt_override.txt --outline outline.json
py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override prompt_override.json --outline outline.json py -3 "%USERPROFILE%\.agent\skills\easy-media-track-gate\verify_track_rules.py" override prompt_override.json --outline outline.json
``` ```
The merge writes `prompt_override.json` (the paste payload, one line), `plan.json` (the The merge writes `prompt_override.txt` (the plain-text paste — the DEFAULT deliverable for
patch plan) and `track_data.json` (pretty, for inspection), and prints the delivered zero-media stories), `prompt_override.json` (the optional per-segment payload, and the
durations/seconds, the track list and the locked tracks. Segment, track and image ids are only form that carries `<Picture N>`/`<Audio N>`/`<Video N>` tokens for stories with
stable UUIDv5 values derived from the project title, so a re-merge keeps ids consistent. media), `plan.json` (the patch plan) and `track_data.json` (pretty, for inspection), and
The `override` command re-checks the paste payload against the guide: one prompt per prints the delivered durations/seconds, the track list and the locked tracks. Segment,
segment, durations inside the runtime's 2–15s window and equal to the approved rows, track and image ids are stable UUIDv5 values derived from the project title, so a re-merge
per-segment generation/continuity modes, the exact `<Picture N>` / `<Audio N>` / `<Video N>` keeps ids consistent. Both `override` commands re-check the paste against the guide: one
reference set per prompt (a missing token renders with no reference media; a stray one scene per segment in order; plain text — `[start-end]`/`[start-end,type]` markers equal
attaches the wrong image), and the track locks. to the approved row frames and task types (or, without markers, equal row lengths),
@imageN/@audioN/@videoN refs matching the inventory, no `<Picture N>` (JSON-only), no
stray `@`, no `[number-number]` prose (the parser eats it as a frame range); JSON —
durations inside the runtime's 2–15s window and equal to the approved rows,
per-segment generation/continuity modes, the exact `<Picture N>` / `<Audio N>` /
`<Video N>` reference set per prompt (a missing token renders with no reference media; a
stray one attaches the wrong image), and the track locks.
## Step 5 — Deliver (paste payload first, patch script as the alternative) ## Step 5 — Deliver (plain-text paste first, patch script as the alternative)
### 5A — Default: the `prompt_override` paste ### 5A — Default: the plain-text `prompt_override` paste
**Default paste: plain text, no JSON.** For zero-media stories with equal scene lengths, **The paste is plain text — `scene1|scene2|...` — unless the story needs the JSON option
deliver `prompt_override.txt` — the scene prompts joined with ` | ` on one line (the merge below.** Deliver `prompt_override.txt` (the merge writes it next to the JSON): the scene
writes it next to the JSON). The input splits plain text on pipes: one scene per chunk, prompts joined with `|` on ONE line, one scene per pipe-chunk. The editor splits on pipes
the editor's existing `total_length` divided evenly, a trailing `|` harmless, TYPE renders with no JSON at all: one clip per scene, back-to-back; a trailing `|` is a no-op. Newlines
as t2v (`track-schema.md` "plain text form" — proven against the pack's parser). The JSON INSIDE a scene survive — multi-section prompt structure is fine — but `|` inside a scene
payload below is the OPTION for per-segment durations, continuity modes, locks or would split it. For unequal scene lengths or a scene that is not the plain-text default
`<Picture N>` media tokens. t2v (e.g. r2v), the merge ends each scene with a `[start-end]` / `[start-end,type]`
marker (`[0-240,r2v]|[240-480,r2v]|[480-720,r2v]` — the marker sits at the scene END,
sets the frame range and task TYPE, and is stripped from the text before it reaches the
model; the worked example `examples/prompt_override_r2v_refmod.txt` shows the full
multi-section r2v form). A story with media needs the JSON option: `<Picture N>` tokens
are NOT parsed in this path — they would stay literal text (the text path attaches media
via `@imageN`/`@audioN`/`@videoN` only).
`prompt_override.json` is what the user pastes into the **multitrack editor node's Deliver `prompt_override.txt` with these instructions:
`prompt_override` input** (`easy multiTrackEditor`) when that per-segment control is
needed. It is minimal by design — the parser requires only `type` and `prompts`; optional
keys appear only when non-default (duration is SECONDS, `generation_type` defaults to
`r2v` in the pack's code). It is self-contained: one prompt per clip, media reference
tokens inside the prompts, and no frame fields anywhere. Deliver it with these
instructions:
1. In the editor node set `format` to `MiniMax` (the payload is parsed as MiniMax only in 1. In the editor node set `format` to `MiniMax`.
that format). 2. Zero-media story: wire nothing — the editor demands no media inputs. (A story with
2. Wire the media IF the outline has any: the inventory's image rows (in inventory order) media cannot go through this path — see the JSON option.)
into the editor's `image` input, the master song into `audio`, the reference video into 3. Select the `prompt_override` widget, clear it, paste the one-line plain text. The
`video`. The `<Picture N>` / `<Audio N>` / `<Video N>` tokens resolve against those editor rebuilds the task track: one clip per pipe-chunk, back-to-back, frame ranges
input lists positionally. With an empty inventory (`[]`, pure t2v) nothing gets wired — and task types as marked (or even splits of the editor's `total_length` when no
the editor demands no media inputs at all. markers are present — keep that length equal to the story total).
3. Select the `prompt_override` widget, clear it, paste the one-line plain text
(`prompt_override.txt`) or the one-line JSON payload. The editor rebuilds the task
track: one clip per prompt/pipe-chunk, back-to-back, durations as specified.
4. **Rendering walks the timeline through `easy multiTrackTaskOutput` — and that node 4. **Rendering walks the timeline through `easy multiTrackTaskOutput` — and that node
outputs ONE task segment per pass, selected by its `task_index` int input (default 0 = outputs ONE task segment per pass, selected by its `task_index` int input (default 0 =
only the FIRST clip).** A workflow whose `task_index` stays 0 renders only the first only the FIRST clip).** A workflow whose `task_index` stays 0 renders only the first
scene no matter how many prompts the override carries. Two ways to render all clips: scene no matter how many scenes the paste carries. Two ways to render all clips:
- **Loop workflow (proper multi-shot):** use the node pack's - **Loop workflow (proper multi-shot):** use the node pack's
`example_workflows/MinimaxH3_ForLoop_MultiShot.json`. Its `forLoopStart` takes `example_workflows/MinimaxH3_ForLoop_MultiShot.json`. Its `forLoopStart` takes
`total` from `easy multiTrackInfoOutput.TASK_COUNT` (via a math node that also lets a `total` from `easy multiTrackInfoOutput.TASK_COUNT` (via a math node that also lets a
@ -350,11 +368,23 @@ instructions:
user's own endpoint (`base_url` accepts any OpenAI-compatible server: Ollama, LM user's own endpoint (`base_url` accepts any OpenAI-compatible server: Ollama, LM
Studio, vLLM, llama.cpp server). Full wiring: `references/workflow_wiring.md`. Studio, vLLM, llama.cpp server). Full wiring: `references/workflow_wiring.md`.
**The paste target is the `prompt_override` input and only that payload type.** Never give **JSON option (`prompt_override.json`) — only for what plain text cannot carry:**
`<Picture N>`/`<Audio N>`/`<Video N>` media tokens (stories with images/song/reference
video), per-segment continuity modes or track locks. The payload is minimal by design —
the parser requires only `type` and `prompts`; optional keys appear only when non-default
(duration is SECONDS, `generation_type` defaults to `r2v` in the pack's code) — and is
self-contained: one prompt per clip, media reference tokens inside the prompts, no frame
fields anywhere. The paste steps are the same three as above (format MiniMax; wire the
inventory's image rows into the editor's `image` input in inventory order, the master song
into `audio`, the reference video into `video` — the `<Picture N>`/`<Audio N>`/`<Video N>`
tokens resolve against those input lists positionally; clear the widget and paste the
one-line JSON), and the same `task_index`/loop wiring applies afterwards.
**The paste target is the `prompt_override` input and only these two forms.** Never give
the user a `plan.json`, an outline, an H3 plan or any other JSON to paste there: without the user a `plan.json`, an outline, an H3 plan or any other JSON to paste there: without
`"type": "minimax_prompt_override"` the editor falls back to its `|`-separated text parser `"type": "minimax_prompt_override"` the editor falls back to its `|`-separated text parser
and renders the whole thing as ONE clip spanning the timeline (the single-clip failure). and renders the whole thing as ONE clip spanning the timeline (the single-clip failure).
Never add `|` inside prompts for the same reason. Never add `|` inside a scene for the same reason.
### 5B — Alternative: the node pack's patch script (whole-workflow patch) ### 5B — Alternative: the node pack's patch script (whole-workflow patch)
@ -386,16 +416,22 @@ the node pack's own flow (see its `references/execution-api.md`). "Queued" never
- Guide-level change (timings, beats, modes, segment count, media): update `outline.json` - Guide-level change (timings, beats, modes, segment count, media): update `outline.json`
first, show the changed rows, then rewrite only the affected segments against it and first, show the changed rows, then rewrite only the affected segments against it and
re-run the Step 4 merge so `plan.json` and `prompt_override.json` refresh. re-run the Step 4 merge so `prompt_override.txt`, `prompt_override.json` and `plan.json`
refresh.
- One segment reads badly: rewrite that `segment_NN.json` (keep its id and frames from the - One segment reads badly: rewrite that `segment_NN.json` (keep its id and frames from the
guide), re-validate it with the `segment` command, then re-merge. Never patch `plan.json` guide), re-validate it with the `segment` command, then re-merge. Never patch
or `prompt_override.json` directly — the merge rebuilds both from the fragments every `prompt_override.txt`, `prompt_override.json` or `plan.json` directly — the merge
time. rebuilds all three from the fragments every time.
## If you cannot run Python ## If you cannot run Python
Say plainly that the result skipped script validation. Follow the rules manually: copy the Say plainly that the result skipped script validation. Follow the rules manually: copy the
`examples/` shapes exactly, compute frames as `round(seconds * frame_rate)`, copy every `examples/` shapes exactly, compute frames as `round(seconds * frame_rate)`, copy every
`file_path` and resolution token by selection (never retyping), and hand-assemble the `file_path` and resolution token by selection (never retyping), and hand-assemble the
TRACK_DATA the way Step 4 describes. Manual assembly is error-prone — prefer getting TRACK_DATA the way Step 4 describes. Hand-write the paste as plain text — scene prompts
Python running (any of `py -3`, `python`, a `.venv`) over hand-building the plan. joined with `|` on one line, one `[start-end(,type)]` marker at each scene end when
lengths differ or the scene is not t2v, exactly like
`examples/prompt_override_r2v_refmod.txt` — and use the JSON payload only when the story
needs `<Picture N>` tokens, continuity modes or locks. Manual assembly is error-prone —
prefer getting Python running (any of `py -3`, `python`, a `.venv`) over hand-building
the plan.

View File

@ -6,16 +6,22 @@
The merge is the continuity check: it re-validates every fragment against the approved The merge is the continuity check: it re-validates every fragment against the approved
outline (ids, frames, modes, verbatim media paths, context-prompt rules, handoff chain), outline (ids, frames, modes, verbatim media paths, context-prompt rules, handoff chain),
then assembles TWO deliverables from it: then assembles the deliverables from it:
1. `prompt_override.json` — the PRIMARY paste payload for the `easy multiTrackEditor` 1. `prompt_override.txt` — the PRIMARY paste for the `easy multiTrackEditor` node's
node's `prompt_override` input (format MiniMax): {"type": "minimax_prompt_override", `prompt_override` input (format MiniMax): plain text, the scene prompts joined with
"prompts": [...]} with one prompt per segment. The parser requires ONLY those two keys ' | ' on one line, plus [start-end(,type)] markers when the rows have unequal durations
(utils/prompt_override.py); duration (SECONDS), generation_type, continuity_mode and or a scene is not the text default (flf -> t2v). The editor splits a non-JSON
track locks are emitted only when non-default. Paste it into the widget and queue; prompt_override on '|' — one clip per scene, no JSON needed. Zero-media stories only:
wire the inventory's media into the editor's image/audio/video inputs in inventory <Picture N>/<Audio N>/<Video N> tokens are NOT parsed in this path.
order so the <Picture N>/<Audio N>/<Video N> tokens resolve. 2. `prompt_override.json` — the OPTION for what plain text cannot carry: the minimal
2. `plan.json` — the patch plan the node pack's `patch_workflow.py apply` consumes {"type": "minimax_prompt_override", "prompts": [...]} payload (parser requires ONLY
those two keys; duration in SECONDS, generation_type, continuity_mode and track locks
emitted only when non-default) with <Picture N>/<Audio N>/<Video N> media tokens for
stories that have media. Paste it into the widget and queue; wire the inventory's
media into the editor's image/audio/video inputs in inventory order so the tokens
resolve.
3. `plan.json` — the patch plan the node pack's `patch_workflow.py apply` consumes
({"editor": {..., "track_data": {...}}, "project": {...}}) for patching a whole ({"editor": {..., "track_data": {...}}, "project": {...}}) for patching a whole
workflow file, plus `track_data.json` (pretty, for inspection). workflow file, plus `track_data.json` (pretty, for inspection).
@ -219,21 +225,24 @@ def _main(argv: list[str]) -> int:
override_path.write_text( override_path.write_text(
json.dumps(override, ensure_ascii=True, separators=(",", ":")) + "\n", json.dumps(override, ensure_ascii=True, separators=(",", ":")) + "\n",
encoding="utf-8") encoding="utf-8")
# Plain-text form of the same payload: the prompt_override input splits on '|' # Plain-text form — the DEFAULT paste: the prompt_override input splits on '|'
# with no JSON at all (parse_override_segments -> one even segment per part). # with no JSON at all (parse_override_segments -> one segment per part). Only
# Only valid with zero media — <Picture N>/<Audio N>/<Video N> tokens are # valid with zero media — <Picture N>/<Audio N>/<Video N> tokens are JSON-only;
# JSON-only; the text path understands only @imageN/@audioN/@videoN. And only # the text path attaches media via @imageN/@audioN/@videoN. Unequal row durations
# valid for EQUAL row durations: the text form divides total_length evenly. # or non-default task types are carried by [start-end(,type)] markers, which the
# builder emits per scene (proven: [0-240,r2v] renders TYPE r2v, task-duration
# sum drives the MiniMax total).
uses_media = bool( uses_media = bool(
outline["_roles"].get("master_audio") outline["_roles"].get("master_audio")
or outline["_roles"].get("reference_video") or outline["_roles"].get("reference_video")
or any(row.get("images") for row in outline["rows"]) or any(row.get("images") for row in outline["rows"])
) )
equal_durations = len({float(row["duration_seconds"]) for row in outline["rows"]}) == 1
text_path = None text_path = None
if not uses_media and equal_durations: if not uses_media:
paste_text = vtr.build_plain_text_override(outline, fragments)
vtr.validate_prompt_override_text(paste_text, copy.deepcopy(outline))
text_path = out_path.parent / "prompt_override.txt" text_path = out_path.parent / "prompt_override.txt"
text_path.write_text(" | ".join(override["prompts"]) + "\n", encoding="utf-8") text_path.write_text(paste_text + "\n", encoding="utf-8")
prompts = len(override["prompts"]) prompts = len(override["prompts"])
total_s = sum(float(row["duration_seconds"]) for row in outline["rows"]) total_s = sum(float(row["duration_seconds"]) for row in outline["rows"])
print(f"OVERRIDE OK: {prompts} prompts, duration {override.get('duration', '10 (default)')}, " print(f"OVERRIDE OK: {prompts} prompts, duration {override.get('duration', '10 (default)')}, "
@ -242,9 +251,14 @@ def _main(argv: list[str]) -> int:
print(f"PLAN OK: {_summary(plan)}") print(f"PLAN OK: {_summary(plan)}")
print(f"wrote {out_path} and {out_path.parent / 'track_data.json'}") print(f"wrote {out_path} and {out_path.parent / 'track_data.json'}")
if text_path: if text_path:
print(f"PLAIN TEXT OK: wrote {text_path} (scenes joined by ' | ', one line — " print(f"PLAIN TEXT OK (the DEFAULT paste): wrote {text_path} — scenes split on '|', "
f"the input needs no JSON for zero-media stories)") f"[start-end,type] markers where lengths differ or a scene is not t2v")
print("deliver: paste prompt_override.txt (plain text) or prompt_override.json " else:
print("PASTE NOTE: this story has media — <Picture N>/<Audio N>/<Video N> tokens are "
"JSON-only, so deliver prompt_override.json (the text path would leave those "
"tokens as literal prompt text)")
print("deliver: paste prompt_override.txt (plain text — the default for zero-media "
"stories) or prompt_override.json (media tokens / continuity modes / locks) "
"into the multitrack editor's prompt_override input (format MiniMax)") "into the multitrack editor's prompt_override input (format MiniMax)")
print("NOTE: easy multiTrackTaskOutput renders ONE task segment per pass " print("NOTE: easy multiTrackTaskOutput renders ONE task segment per pass "
"(task_index, default 0 = first clip only).") "(task_index, default 0 = first clip only).")

View File

@ -0,0 +1,63 @@
{
"title": "sam_park_butterfly",
"lengths_user_pinned": true,
"editor": {
"format": "MiniMax",
"resolution": {
"resolution": "width x height (megapixels)",
"aspect_ratio": "16:9 (Widescreen)",
"megapixels": 0.8
}
},
"defaults": {
"frame_rate": 24,
"segment_seconds": 10
},
"media_inventory": [],
"tracks": {
"master_audio": null,
"reference_video": null
},
"project": {
"project_save": "new",
"segment_start_number": 1,
"segment_count": -1,
"sampling_plan": "medium",
"sampling_mode": "single"
},
"segments": [
{
"index": 1,
"id": "park_walk_spot",
"start_seconds": 0,
"duration_seconds": 10,
"task_mode": "ref",
"continuity_mode": "shot",
"images": [],
"beat": "Sam walks the sunny park path in his pink dress, the monarch butterfly flutters into view in front of him, and the scene ends mid-step as he reaches both hands out toward it.",
"prompt_brief": "Self-contained r2v shot via the Sam refmod: walk, butterfly reveal, end mid-step reaching."
},
{
"index": 2,
"id": "butterfly_chase_miss",
"start_seconds": 10,
"duration_seconds": 10,
"task_mode": "ref",
"continuity_mode": "shot",
"images": [],
"beat": "Sam chases the butterfly across the grass swiping both hands at it, it dodges every grab and lifts out of reach, and the scene ends with him standing empty-handed, his face starting to crumple.",
"prompt_brief": "Self-contained r2v shot: chase and misses, butterfly escapes, end standing, face crumpling."
},
{
"index": 3,
"id": "ground_cry",
"start_seconds": 20,
"duration_seconds": 10,
"task_mode": "ref",
"continuity_mode": "shot",
"images": [],
"beat": "Sam sinks down and sits on the ground, then cries like a baby, tears rolling down his cheeks as the butterfly flutters away above him.",
"prompt_brief": "Self-contained r2v shot: sink and sit, crying with tears, butterfly departs; final segment may come to rest."
}
]
}

View File

@ -513,9 +513,15 @@ one task segment per part, a trailing `|` is a no-op. Proven by executing the pa
- Continuity: parts become independent segments; there is no `continuity_mode` in the - Continuity: parts become independent segments; there is no `continuity_mode` in the
text form (context joins are a JSON/TRACK_DATA feature). text form (context joins are a JSON/TRACK_DATA feature).
Use this form when the scenes share one length and t2v (or per-part `[s-e,type]`) is This is the gate's DEFAULT paste form: the merge writes `prompt_override.txt` for every
enough. Use the JSON payload below only for per-segment durations, continuity modes, zero-media story — scenes joined with `|`, and it appends the `[start-end]` /
locks or `<Picture N>` media tokens. `[start-end,type]` markers itself whenever the rows have unequal durations (the
markerless form splits the editor's `total_length` evenly) or a scene's task type differs
from the text default (flf → t2v, e.g. `[0-240,r2v]` for task_mode ref). Use the JSON
payload below only for what plain text cannot carry: per-segment continuity modes, track
locks or `<Picture N>` media tokens (stories with media — the text path attaches media
via `@imageN`/`@audioN`/`@videoN` only, and the gate validates both forms against the
approved guide).
--- ---

View File

@ -7,9 +7,10 @@ Verified against ComfyUI-Easy-Media source (`nodes/basic.py`, `nodes/minimax.py`
The render chain reads the timeline through `easy multiTrackTaskOutput`, which outputs The render chain reads the timeline through `easy multiTrackTaskOutput`, which outputs
**one task segment per pass**, picked by its `task_index` int input. Default `0` → **one task segment per pass**, picked by its `task_index` int input. Default `0` →
the first clip only. The number of prompts inside the pasted `prompt_override` JSON the first clip only. The number of scenes inside the pasted `prompt_override` (plain
does not change this: the JSON is complete (all scenes are in it); the loop lives in pipe text or the JSON payload) does not change this: the paste is complete (all scenes
the workflow, not in the JSON. Nothing needs to be added to the payload for multi-shot. are in it); the loop lives in the workflow, not in the paste. Nothing needs to be added
to it for multi-shot.
Side facts (same node, verified in source): Side facts (same node, verified in source):
@ -30,12 +31,15 @@ calls `is_minimax_prompt_override(prompt_override)` FIRST. Only a payload with
falls to the generic `|`-text parser — which is a legitimate form in its own right, not falls to the generic `|`-text parser — which is a legitimate form in its own right, not
just a failure mode (`track-schema.md` "plain text form"): just a failure mode (`track-schema.md` "plain text form"):
- Plain pipe text `scene1 | scene2 | scene3` → N task segments, evenly sliced over the - Plain pipe text `scene1|scene2|scene3` → N task segments, evenly sliced over the
editor's `total_length` (proven by executing the pack's code, editor's `total_length` (proven by executing the pack's code,
`scripts/prove_plain_text_override.py`). This is the simple default; no JSON needed. `scripts/prove_plain_text_override.py`). This is the DEFAULT form — this gate's
`prompt_override.txt` — with optional `[start-end(,type)]` markers per scene for
explicit frame ranges / non-t2v types (`examples/prompt_override_r2v_refmod.txt`).
- A full TRACKS_INFO JSON contains no `|` → ONE segment whose prompt is the literal - A full TRACKS_INFO JSON contains no `|` → ONE segment whose prompt is the literal
JSON dump (STEP A of `prove_relay_chain.py`): the garbage single-clip failure. So: JSON dump (STEP A of `prove_relay_chain.py`): the garbage single-clip failure. So:
paste plain text OR the minimal JSON payload into `prompt_override`; full TRACKS_INFO paste plain text (default) or the minimal `minimax_prompt_override` JSON payload
(media tokens / continuity modes / locks) into `prompt_override`; full TRACKS_INFO
belongs only in `track_data`. belongs only in `track_data`.
## Single-pass timeline render: task_index=-1 + prompt_format=promptRelay (short timelines only) ## Single-pass timeline render: task_index=-1 + prompt_format=promptRelay (short timelines only)
@ -135,7 +139,8 @@ Three ways to fill the slot:
### Option A — no LLM node at all (default for this skill) ### Option A — no LLM node at all (default for this skill)
The skill already wrote every scene prompt (identity text, continuity rules, LoRA The skill already wrote every scene prompt (identity text, continuity rules, LoRA
trigger) into `prompt_override.json`. Leave the enhance toggle OFF: raw trigger) into the paste (`prompt_override.txt`, or `prompt_override.json` for the JSON
form). Leave the enhance toggle OFF: raw
`USER_PROMPT` flows to the render node each pass. The "LLM that made all the scenes" `USER_PROMPT` flows to the render node each pass. The "LLM that made all the scenes"
is this skill, outside ComfyUI. is this skill, outside ComfyUI.

View File

@ -1180,6 +1180,203 @@ def validate_prompt_override(payload: Any, outline: dict[str, Any]) -> dict[str,
return payload return payload
# --------------------------------------------- plain-text prompt_override paste
# The editor's fallback path (nodes/basic.py -> build_multitrack_data_from_prompt_override
# -> parse_override_segments in utils/prompt_override.py) splits a non-JSON prompt_override
# on '|': one task segment per part, a trailing '|' a no-op. Per-part extras the pack's
# parser lifts OUT of the text: a trailing [s-e] / [s-e,type] frame-range marker (ANY
# [number-number] pattern anywhere in a scene is eaten as a marker — prose must avoid it),
# and @imageN/@audioN/@videoN media references. The <Picture N> bracket tokens are
# JSON-only and stay literal text in this path. Proven against the pack's code
# (parse_override_segments + build_multitrack_data_from_prompt_override).
_TASK_MODE_TO_TEXT_TYPE = {"ref": "r2v", "l2v": "l2v", "default": "flf"}
_TEXT_TYPES = {"flf", "fmlf", "ref", "l2v", "v2v", "i2v", "rv2v", "vi2v", "r2v"}
_TEXT_MARKER_RE = re.compile(
r"\[\s*(\d+(?:\.\d+)?)\s*(s?)\s*-\s*(\d+(?:\.\d+)?)\s*(s?)\s*(?:,\s*(\w+)\s*)?\]")
_AT_IMAGE_RE = re.compile(r"@(?:image|img|图片|图)\s*(\d+)", re.IGNORECASE)
_AT_AUDIO_RE = re.compile(r"@(?:audio|音频)\s*(\d+)", re.IGNORECASE)
_AT_VIDEO_RE = re.compile(r"@(?:video|视频)\s*(\d+)", re.IGNORECASE)
def _text_marker_values(match: "re.Match[str]", fps: int) -> tuple[int, int, str | None]:
"""[s-e(,type)] -> (start_frame, end_frame, type). Seconds forms ([1.5s-3s]) convert
at the outline's frame rate with the pack's 4-frame quanta."""
s_val, s_suf, e_val, e_suf, typ = match.groups()
start = float(s_val)
end = float(e_val)
if s_suf:
start = int(round(start * fps / 4.0)) * 4
if e_suf:
end = int(round(end * fps / 4.0)) * 4
norm_type = typ.lower() if typ else None
if norm_type is not None and norm_type not in _TEXT_TYPES:
raise Fail(f"[s-e] marker type {typ!r} is not a pack task type "
f"(one of {sorted(_TEXT_TYPES)})")
return int(start), int(end), norm_type
def _check_text_refs(scene: str, row: dict[str, Any], outline: dict[str, Any],
where: str) -> None:
"""@-media contract of the plain-text path (mirror of _check_override_refs)."""
positions = _override_media_positions(outline)
expected_pics = sorted({positions[img["key"]] for img in row.get("images", [])})
found_pics = sorted({int(m.group(1)) for m in _AT_IMAGE_RE.finditer(scene)})
unexpected = [n for n in found_pics if n not in expected_pics]
if unexpected:
raise Fail(
f"{where} references @image{unexpected[0]} which is not one of this segment's "
f"approved images (expected {expected_pics}); a stray @ref attaches the wrong "
"slot image from the editor's image input")
missing = [n for n in expected_pics if n not in found_pics]
if missing:
raise Fail(
f"{where} is missing @image{missing[0]}. In the plain-text paste the images are "
"attached ONLY through @imageN/@audioN/@videoN tokens — a scene without them "
"renders with no reference images at all")
roles = outline["_roles"]
expected_audio = [positions[roles["master_audio"]["key"]]] if roles["master_audio"] else []
expected_video = [positions[roles["reference_video"]["key"]]] if roles["reference_video"] else []
found_audio = sorted({int(m.group(1)) for m in _AT_AUDIO_RE.finditer(scene)})
found_video = sorted({int(m.group(1)) for m in _AT_VIDEO_RE.finditer(scene)})
if found_audio != expected_audio:
raise Fail(
f"{where} @audio refs {found_audio} != expected {expected_audio}: with a locked "
"master audio every scene must reference the song exactly once; with none, no "
"audio @ref may appear")
if found_video != expected_video:
raise Fail(
f"{where} @video refs {found_video} != expected {expected_video}: with a locked "
"reference video every scene must reference it exactly once; with none, no "
"video @ref may appear")
def validate_prompt_override_text(text: str, outline: dict[str, Any]) -> list[str]:
"""Validate a PLAIN-TEXT prompt_override paste ('scene1|scene2|...', spaces around
the pipes are stripped by the parser) against the approved outline — the editor's
fallback-parser contract plus this gate's outline pins. Returns the marker-stripped
scene texts."""
rows = outline["rows"]
fps = outline["defaults"]["frame_rate"]
raw = text.strip()
if raw.startswith("{"):
raise Fail("this paste is JSON: validate it as the JSON payload (it must carry "
f"\"type\": {OVERRIDE_TYPE!r}) — pasted as plain text it would parse as "
"ONE scene over the whole timeline")
parts = [p.strip() for p in raw.split("|")]
parts = [p for p in parts if p]
if not parts:
raise Fail("plain-text prompt_override is empty — paste 'scene1 | scene2 | ...'")
if len(parts) != len(rows):
raise Fail(
f"plain-text paste splits into {len(parts)} scenes but the approved outline has "
f"{len(rows)} segments — one scene per '|'-chunk, in order (a missing '|' "
"renders the whole story as ONE clip)")
equal_rows = len({float(r["duration_seconds"]) for r in rows}) == 1
scenes: list[str] = []
marker_flags: list[bool] = []
for i, (part, row) in enumerate(zip(parts, rows)):
where = f"scene {i + 1}"
matches = list(_TEXT_MARKER_RE.finditer(part))
if len(matches) > 1:
raise Fail(
f"{where}: {len(matches)} [number-number] patterns found — the pack's parser "
"eats every one as a frame-range marker. Keep exactly one [s-e(,type)] marker "
"at the scene end and no [number-number] prose anywhere in the scene")
body = part
marker = None
if matches:
match = matches[0]
if match.end() != len(part):
raise Fail(
f"{where}: the [s-e(,type)] marker must sit at the very END of the scene "
"(the parser strips only a trailing marker; text after it reaches the "
"model, text before it gets eaten as a frame range)")
start_f, end_f, typ = _text_marker_values(match, fps)
expected_start, expected_end = row["start_frame"], row["end_frame"]
if (start_f, end_f) != (expected_start, expected_end):
raise Fail(
f"{where}: marker [{start_f}-{end_f}] != approved row frames "
f"[{expected_start}-{expected_end}] (start_seconds "
f"{row['start_seconds']:g} + duration_seconds "
f"{float(row['duration_seconds']):g} at {fps} fps)")
expected_type = _TASK_MODE_TO_TEXT_TYPE[row["task_mode"]]
if expected_type != "flf" and typ is None:
raise Fail(
f"{where}: task_mode {row['task_mode']!r} renders as TYPE "
f"{expected_type} only with an explicit suffix — end the scene with "
f"[{start_f}-{end_f},{expected_type}]")
if typ is not None and typ != expected_type:
raise Fail(
f"{where}: marker type {typ!r} != {expected_type!r} for task_mode "
f"{row['task_mode']!r}")
body = part[:match.start()].rstrip()
marker = True
if not body:
raise Fail(f"{where} is only a marker — a scene still needs its prompt text")
if _PICTURE_RE.search(body) or _AUDIO_RE.search(body) or _VIDEO_RE.search(body):
raise Fail(
f"{where}: <Picture N>/<Audio N>/<Video N> tokens are JSON-only — the "
"plain-text parser leaves them as literal text in the prompt. Use "
"@imageN/@audioN/@videoN here, or deliver the JSON payload for this story")
residual = _ATREF_RE.sub("", body)
if "@" in residual:
raise Fail(
f"{where} contains a stray '@': the parser strips it (and eats @imageN/"
"@audioN/@videoN as media references) — keep '@' out of scene prose")
prompt_rules(body, row["continuity_mode"], row["followed_by_join"], where)
_check_text_refs(body, row, outline, where)
scenes.append(body)
marker_flags.append(marker is not None)
if any(marker_flags) and not all(marker_flags):
raise Fail(
"markers must be all-or-nothing: scenes with explicit [s-e] ranges and scenes "
"without them mix two unproven split behaviors — give every scene a marker")
if not any(marker_flags) and not equal_rows:
raise Fail(
"the outline's rows have unequal durations but no scene carries a [start-end] "
"marker: without markers the editor splits its total_length EVENLY across "
"scenes — add [s-e(,type)] markers or equalize the rows")
return scenes
def build_plain_text_override(outline: dict[str, Any], fragments: list[dict[str, Any]]) -> str:
"""Assemble the plain-text paste: raw scene prompts joined with '|' (no padding —
byte-identical to the proven paste form), one per outline row.
Unlike build_prompt_override this keeps the fragment text VERBATIM: the text path
preserves newlines INSIDE a scene (only '|' splits), so the multi-section prompt
structure survives — do not feed it the JSON payload's whitespace-collapsed prompts.
Markers ([start-end] / [start-end,type], the form the pack's parser lifts) are added
when the rows have unequal durations (the markerless form splits the editor's
total_length evenly) or any scene's task type differs from the text default
(flf -> t2v). Zero-media stories only: <Picture N> tokens are JSON-only.
"""
rows = outline["rows"]
if len(fragments) != len(rows):
raise Fail(f"expected {len(rows)} fragments (one per approved outline row), got {len(fragments)}")
texts: list[str] = []
for frag in fragments:
content = frag.get("content", {})
variant = content.get("user_prompt_variant", "a")
text = content.get("user_prompt_b") if variant == "b" else content.get("user_prompt")
if not isinstance(text, str) or not text.strip():
raise Fail(f"fragment {frag.get('id', '?')}: no prompt text for the plain-text paste")
texts.append(text.strip())
equal_rows = len({float(r["duration_seconds"]) for r in rows}) == 1
needs_types = any(_TASK_MODE_TO_TEXT_TYPE[r["task_mode"]] != "flf" for r in rows)
if equal_rows and not needs_types:
return "|".join(texts)
parts = []
for row, text in zip(rows, texts):
typ = _TASK_MODE_TO_TEXT_TYPE[row["task_mode"]]
suffix = f",{typ}" if typ != "flf" else ""
parts.append(f"{text} [{row['start_frame']}-{row['end_frame']}{suffix}]")
return "|".join(parts)
# ------------------------------------------------------------------- suite # ------------------------------------------------------------------- suite
def _suite_outline() -> dict[str, Any]: def _suite_outline() -> dict[str, Any]:
@ -1322,6 +1519,46 @@ def _merged_track_data(outline: dict[str, Any], fragments: list[dict[str, Any]])
return data return data
def _suite_text_outline() -> dict[str, Any]:
"""Zero-media two-scene outline: the shape the plain-text paste covers."""
return {
"title": "plain_text_two_shot",
"lengths_user_pinned": True,
"editor": {
"format": "MiniMax",
"resolution": {"resolution": "width x height (megapixels)",
"aspect_ratio": "16:9 (Widescreen)", "megapixels": 0.8},
},
"defaults": {"frame_rate": 24, "segment_seconds": 10},
"media_inventory": [],
"tracks": {"master_audio": None, "reference_video": None},
"project": {"project_save": "new", "segment_start_number": 1,
"segment_count": -1, "sampling_plan": "medium", "sampling_mode": "single"},
"segments": [
{"index": 1, "id": "text_harbor_open", "start_seconds": 0, "duration_seconds": 10,
"task_mode": "default", "continuity_mode": "shot", "images": [],
"beat": "Mia strides the wet pier as gulls lift; ends with the boat sliding out.",
"prompt_brief": "Self-contained dawn harbor shot; keep her stride; end mid-motion."},
{"index": 2, "id": "text_lighthouse_run", "start_seconds": 10, "duration_seconds": 10,
"task_mode": "default", "continuity_mode": "shot", "images": [],
"beat": "Mia climbs to the lighthouse walk and breaks into a run; ends running.",
"prompt_brief": "Self-contained midday shot; wind presses; end mid-run."},
],
}
TEXT_PROMPT_1 = (
"Dawn light spills over a quiet harbor as Mia steps onto the wet stone pier, her yellow "
"raincoat swinging with each stride; gulls lift off the pilings while she steadies a "
"coiled rope against her hip, the tide swelling green beneath the planks, and the camera "
"tracks slowly beside her as the first fishing boat slides out toward the open water.")
TEXT_PROMPT_2 = (
"Midday sun hardens over the quiet harbor as Mia climbs the wooden stairs to the "
"lighthouse walk, her boots drumming the planks while wind presses the raincoat flat "
"against her back; she raises one hand against the glare, watches a ferry cut a white "
"line across the bay, and breaks into a run along the railing as the horn sounds below.")
def run_embedded_suite() -> int: def run_embedded_suite() -> int:
cases: list[tuple[str, bool, Any, Any]] = [] cases: list[tuple[str, bool, Any, Any]] = []
@ -1487,6 +1724,48 @@ def run_embedded_suite() -> int:
bad["audio_track_lock"] = 0 bad["audio_track_lock"] = 0
check("override audio lock zeroed caught", False, validate_prompt_override, bad, outline) check("override audio lock zeroed caught", False, validate_prompt_override, bad, outline)
# ---- plain-text paste path (the editor's fallback parser + outline pins) ----
text_outline = _suite_text_outline()
check("text outline example", True, validate_outline, text_outline)
plain = f"{TEXT_PROMPT_1} | {TEXT_PROMPT_2}"
check("text override even split", True, validate_prompt_override_text, plain, text_outline)
marked = f"{TEXT_PROMPT_1} [0-240] | {TEXT_PROMPT_2} [240-480]"
check("text override frame markers", True, validate_prompt_override_text, marked, text_outline)
built = build_plain_text_override(
text_outline,
[{"content": {"user_prompt": TEXT_PROMPT_1}}, {"content": {"user_prompt": TEXT_PROMPT_2}}])
check("text override builder roundtrip", True, validate_prompt_override_text, built, text_outline)
bad = f"{TEXT_PROMPT_1} | {TEXT_PROMPT_2} | {TEXT_PROMPT_1}"
check("text override scene count caught", False, validate_prompt_override_text, bad, text_outline)
bad = f"{TEXT_PROMPT_1} [0-240] | {TEXT_PROMPT_2}"
check("text override mixed markers caught", False, validate_prompt_override_text, bad, text_outline)
bad = f"{TEXT_PROMPT_1} [0-300] | {TEXT_PROMPT_2} [240-480]"
check("text override marker frames caught", False, validate_prompt_override_text, bad, text_outline)
bad = f"{TEXT_PROMPT_1} [0-240,r2v] | {TEXT_PROMPT_2} [240-480,r2v]"
check("text override marker type caught", False, validate_prompt_override_text, bad, text_outline)
uneven = copy.deepcopy(text_outline)
uneven["rows"][1]["duration_seconds"] = 15
check("text override uneven no markers caught", False,
validate_prompt_override_text, plain, uneven)
bad = f"{TEXT_PROMPT_1} <Picture 1> | {TEXT_PROMPT_2}"
check("text override bracket token caught", False, validate_prompt_override_text, bad, text_outline)
bad = f"{TEXT_PROMPT_1} @image1 | {TEXT_PROMPT_2}"
check("text override @media without inventory caught", False,
validate_prompt_override_text, bad, text_outline)
bad = f"{TEXT_PROMPT_1} meet @ the pier | {TEXT_PROMPT_2}"
check("text override stray @ caught", False, validate_prompt_override_text, bad, text_outline)
failed = [c for c in cases if not c[1]] failed = [c for c in cases if not c[1]]
for name, ok, detail in cases: for name, ok, detail in cases:
if ok: if ok:
@ -1600,15 +1879,25 @@ def _main(argv: list[str]) -> int:
else: else:
positional.append(args[i]); i += 1 positional.append(args[i]); i += 1
if not positional or not outline_path: if not positional or not outline_path:
raise Fail("usage: override PROMPT_OVERRIDE.json --outline outline.json") raise Fail("usage: override PROMPT_OVERRIDE.(txt|json) --outline outline.json")
payload = load_json(positional[0], "prompt_override payload")
outline = load_json(outline_path, "outline") outline = load_json(outline_path, "outline")
validate_outline(outline) validate_outline(outline)
validate_prompt_override(payload, outline) raw_text = Path(positional[0]).read_text(encoding="utf-8")
total_s = sum(float(r["duration_seconds"]) for r in outline["rows"]) total_s = sum(float(r["duration_seconds"]) for r in outline["rows"])
print(f"OVERRIDE OK: {len(payload['prompts'])} prompts, duration {payload.get('duration', '10 (default)')}, " fmt = outline["editor"]["format"]
if raw_text.lstrip().startswith("{"):
payload = load_json(positional[0], "prompt_override payload")
validate_prompt_override(payload, outline)
print(f"OVERRIDE OK (JSON payload): {len(payload['prompts'])} prompts, "
f"duration {payload.get('duration', '10 (default)')}, "
f"total {total_s:.2f}s at {outline['defaults']['frame_rate']} fps — paste into " f"total {total_s:.2f}s at {outline['defaults']['frame_rate']} fps — paste into "
f"the multitrack editor's prompt_override input (format {outline['editor']['format']!r})") f"the multitrack editor's prompt_override input (format {fmt!r})")
else:
scenes = validate_prompt_override_text(raw_text, outline)
marked = " with [start-end,type] markers" if "[" in raw_text else ""
print(f"OVERRIDE OK (plain text): {len(scenes)} scenes split on '|'{marked}, "
f"total {total_s:.2f}s at {outline['defaults']['frame_rate']} fps — paste into "
f"the multitrack editor's prompt_override input (format {fmt!r})")
return 0 return 0
raise Fail(f"unknown sub-command {cmd!r} (use outline/segment/trackdata/plan/override/suite)") raise Fail(f"unknown sub-command {cmd!r} (use outline/segment/trackdata/plan/override/suite)")
except Fail as exc: except Fail as exc: