rereel patch
patch applies small, deterministic edits to a bundle’s JSON files so that an agent never has to hand-edit timestamps in several files at once. The JSON files are rewritten pretty-printed with 2-space indentation.
Synopsis
Section titled “Synopsis”rereel patch <reel_dir> ripple-shift --at-sec <sec> --delta-sec <sec>rereel patch <reel_dir> trim-segment --id <seg_id> [--src-start-sec <sec>] [--duration-sec <sec>] [--start-sec <sec>] [--gain-db <db>]rereel patch <reel_dir> swap-asset --old <ref> --new <ref>All operations read <reel_dir>/rereel.json first (exit 2 if missing) to find the file names (propsFile, mixPlanFile, timingFile, captionsFile, lockFile) and video.fps (default 30).
ripple-shift
Section titled “ripple-shift”Shifts every timestamp at or after --at-sec by --delta-sec across all timeline files. Use a negative delta after removing a pause or cut, and a positive delta to insert time.
What it does
Section titled “What it does”The following files are processed if they exist: props.json, mix_plan.json, timing.json, captions.srt. JSON files are walked recursively (objects and arrays), and in every object:
| Key | Shifted when | Rule |
|---|---|---|
start_sec |
>= at |
+ delta, clamped at 0, rounded to 4 decimals |
end_sec |
> at |
same |
at_sec |
>= at |
same |
fromFrame, atFrame, startFrame |
>= round(at × fps) |
+ round(delta × fps), clamped at 0 |
endFrame |
> round(at × fps) |
same |
Additional per-file rules:
- props.json: top-level
duration_sec+= delta. Top-leveldurationInFrames+=round(delta × fps)(minimum 1). - mix_plan.json: top-level
duration_sec+= delta. Eachspeechpair[a, b]is shifted with the same>=/>rules. - timing.json: top-level
duration_sec+= delta. - captions.srt: cue start (
>= at) and end (> at) are shifted, and cues are renumbered from 1.
Objects under keys named anchor or end_anchor are not descended into. src_start_sec and nested duration_sec values are never changed, so items that straddle at are stretched or shrunk through their end_sec.
Options
Section titled “Options”| Flag | Type | Default | Description |
|---|---|---|---|
--at-sec |
number | — (required) | Pivot time in seconds. |
--delta-sec |
number | — (required) | Seconds to add (negative to pull earlier). |
Output
Section titled “Output”{ "status": "patched", "atSec": 12, "deltaSec": -0.5, "filesUpdated": ["props.json", "mix_plan.json", "timing.json", "captions.srt"]}filesUpdated lists only the files that existed and were rewritten.
Example
Section titled “Example”# A 0.5 s pause at 12.0 s was removed from the narrationrereel patch ./reels/ep01 ripple-shift --at-sec 12.0 --delta-sec -0.5trim-segment
Section titled “trim-segment”Updates one mix_plan.json narration[] entry, found by its id.
What it does
Section titled “What it does”- Reads
mix_plan.json(exit2if missing). - Finds the first narration segment with
id === --id. Segments without anidcannot be targeted. If none matches, the command fails with exit2(Narration segment not found: <id>). - Applies only the flags that were passed:
--src-start-sec→src_start_sec(clamped ≥ 0, 4 decimals)--duration-sec→duration_sec(minimum0.01)--start-sec→start_sec(clamped ≥ 0, 4 decimals)--gain-db→gain_db(as-is)
- Writes
mix_plan.json. No other file is touched, so follow withripple-shiftif the segment length change should move later content.
Options
Section titled “Options”| Flag | Type | Default | Description |
|---|---|---|---|
--id |
string | — (required) | Narration segment id. |
--src-start-sec |
number | unchanged | New source offset. |
--duration-sec |
number | unchanged | New duration. |
--start-sec |
number | unchanged | New timeline start. |
--gain-db |
number | unchanged | New gain in dB. |
Output
Section titled “Output”{ "status": "patched", "segmentId": "seg_004" }Example
Section titled “Example”rereel patch ./reels/ep01 trim-segment --id seg_004 --src-start-sec 18.42 --duration-sec 3.1swap-asset
Section titled “swap-asset”Replaces every string exactly equal to --old with --new in props.json and mix_plan.json (when present). Replacement happens anywhere in the tree, including non-media fields and keys such as output.
Options
Section titled “Options”| Flag | Type | Default | Description |
|---|---|---|---|
--old |
string | — (required) | Exact reference to replace (e.g. media/bg_1a2b3c4d.png). |
--new |
string | — (required) | Replacement reference. |
Output
Section titled “Output”{ "status": "patched", "replacements": 3 }replacements is the total number of replaced strings across both files. 0 is not an error.
Example
Section titled “Example”rereel patch ./reels/ep01 swap-asset --old media/bg_1a2b3c4d.png --new media/bg_v2_77ef0011.pngExit codes
Section titled “Exit codes”| Code | When |
|---|---|
0 |
Patched. |
2 |
Missing <reel_dir> or operation (patch requires <reel_dir> <op>); unknown operation (Unknown patch op: <op>); missing required flags; non-numeric values; missing rereel.json (or mix_plan.json for trim-segment); segment not found; invalid JSON. |