davinci-resolve-mcp 2.189.0 → 2.191.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,65 @@
2
2
 
3
3
  Release history for the DaVinci Resolve MCP Server. The latest release is summarized in the root README; older entries live here to keep the README focused.
4
4
 
5
+ ## What's New in v2.191.0 — E139: a .drt timeline walks into events; two Resolve versions diff
6
+
7
+ ### Added
8
+
9
+ - **A `.drt`/`.drp` timeline walks into normalized events, so two Resolve
10
+ timeline VERSIONS diff.** `parse_interchange {format:'drt', content: PATH}`
11
+ (optional `timeline` = pool name or index) returns the same event shape as
12
+ every other format, with sequence-relative record positions plus the
13
+ timeline's `fps`, `startFrame` and `startTimecode` read from the pool
14
+ sequence. Measured on a real 19.1.3.7 export of a 229-clip reel: 230 events
15
+ on V–V4 and A–A2, 11 dissolves attached with their witnessed alignment, the
16
+ 4 retimed clips flagged, and v19 vs v20 of that reel reads `identical, 229
17
+ of 229 retained` through `turnover_changelist`.
18
+ - **The DRT parser reads the fields it used to skip.** Per clip: `in` (the
19
+ source in-point — EMPTY on a real export's audio clips, reported `null`, and
20
+ `srcInAbsent` on the event, never a silent 0), `mediaStartTime`,
21
+ `mediaFrameRate` (decoded from Resolve's little-endian double blob) and
22
+ `timemap` (`linear` vs a keyed `curve`; a curve is a retime this reader does
23
+ not decode, so the event carries `speed: null`, `srcOut: null` and
24
+ `retimeUnknown` instead of a faked 100%). Per track: `transitions`
25
+ (`Sm2TiTransition` span, type, `alignmentType` → `alignment`: 2 centres on
26
+ the cut, 3 ends at it, witnessed on all 11 real dissolves). Per timeline:
27
+ `frameRate`, `startFrame`, `startTimecode` and `resolution` now fill from the
28
+ pool `Sm2Sequence` (`FrameRate` LE double, `MediaExtents` seconds,
29
+ `Resolution` BE uint64 pair) when the container carries none — a real export
30
+ used to report them all `null`.
31
+
32
+ ### Measured (filed in api-limitations)
33
+
34
+ - The EXPORT_DRT clip, transition and pool-sequence field encodings.
35
+
36
+ ## What's New in v2.190.0 — E138: the changelist names its shape; pairing is closest-first globally
37
+
38
+ ### Added
39
+
40
+ - **`turnover_changelist` leads with a SHAPE verdict.** A real Premiere
41
+ auto-save of a locked reel kept 3 of its 335 cuts, byte-identical at their
42
+ record positions, and deleted the rest: a patch/selects reel of the same
43
+ cut. Per-event kinds read that as 332 `gone`. The result now names the
44
+ relationship first: `identical` | `subset` (new keeps some of old's cuts
45
+ unchanged in place and nothing else) | `superset` (the reverse) | `edit`,
46
+ with `retained`, `oldCuts`, `newCuts`, and for subset/superset `sparse`,
47
+ the `retainedWindows`, and a plain-language `note`. A transition that
48
+ vanished or appeared with the cuts it joins counts as a consequence, not an
49
+ edit. `gone`/`new` changes carry their record OUT so a dropped junction can
50
+ be attributed to them.
51
+
52
+ ### Fixed
53
+
54
+ - **Event pairing was first-come, not closest-first.** Walking new cuts in
55
+ order let the first new instance of a source consume an old instance 6,000
56
+ frames away while the old instance at its own position went unpaired, so
57
+ the same two reels compared as `subset` one way and `moved + 332 new` the
58
+ other. Every same-signature (old, new) pair now sorts by record distance
59
+ and is taken once; the diff is symmetric under swapping old and new. On
60
+ the real reels: `subset 3 of 335` forward, `superset 3 of 335` back.
61
+ Sweep across every sequence the two auto-saves share: 739 compared, 738
62
+ `identical`, 1 `subset`, 0 asymmetric in either shape or counts.
63
+
5
64
  ## What's New in v2.189.0 — E136: Premiere markers belong to their sequence and read their real fields
6
65
 
7
66
  ### Fixed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  English | [简体中文](README.zh-CN.md)
4
4
 
5
- [![Version](https://img.shields.io/badge/version-2.189.0-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
5
+ [![Version](https://img.shields.io/badge/version-2.191.0-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
6
6
  [![npm](https://img.shields.io/npm/v/davinci-resolve-mcp.svg?label=npm&color=CB3837)](https://www.npmjs.com/package/davinci-resolve-mcp)
7
7
  [![API Coverage](https://img.shields.io/badge/API%20Coverage-100%25-brightgreen.svg)](docs/reference/api-coverage.md)
8
8
  [![Tools](https://img.shields.io/badge/MCP%20Tools-36%20(353%20full)-blue.svg)](#server-modes)
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) | 简体中文
4
4
 
5
- [![Version](https://img.shields.io/badge/version-2.189.0-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
5
+ [![Version](https://img.shields.io/badge/version-2.191.0-blue.svg)](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
6
6
  [![npm](https://img.shields.io/npm/v/davinci-resolve-mcp.svg?label=npm&color=CB3837)](https://www.npmjs.com/package/davinci-resolve-mcp)
7
7
  [![API Coverage](https://img.shields.io/badge/API%20Coverage-100%25-brightgreen.svg)](docs/reference/api-coverage.md)
8
8
  [![Tools](https://img.shields.io/badge/MCP%20Tools-36%20(353%20full)-blue.svg)](#服务器模式)
@@ -12,7 +12,7 @@
12
12
  [![Python](https://img.shields.io/badge/python-3.10+-green.svg)](https://www.python.org/downloads/)
13
13
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
14
14
 
15
- > 本翻译对应 v2.189.0 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
15
+ > 本翻译对应 v2.191.0 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
16
16
 
17
17
  一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
18
18
 
@@ -12,7 +12,7 @@ that none exists).
12
12
 
13
13
  **Verified on:** DaVinci Resolve Studio 21.0.2
14
14
 
15
- **Totals:** 40 missing capabilities, 50 bugs / unreliable behaviors.
15
+ **Totals:** 41 missing capabilities, 50 bugs / unreliable behaviors.
16
16
 
17
17
  The authoritative source is the runtime-queryable `api_truth` ledger
18
18
  (`resolve_control api_truth "<query>"`); this document is generated from
@@ -301,6 +301,14 @@ equivalent, blocking full automation.
301
301
  - **Workaround / current handling:** Read item.GetNodeGraph().GetNumNodes() before SetCDL and diagnose a False against the node count and clip type. Prove the applied look with a rendered frame (gallery_stills grab_and_export or Project.ExportCurrentFrameAsStill), not the return value.
302
302
  - **Tags:** color, cdl, readback, silent-failure
303
303
 
304
+ ### Timeline.Export EXPORT_DRT (clip, transition and pool-sequence field encodings)
305
+
306
+ - **Object:** `Timeline`
307
+ - **Signature:** `(filePath, EXPORT_DRT) -> bool`
308
+ - **Behavior:** Measured on a Studio 19.1.3.7 export of a 229-clip reel (E139). A SeqContainer clip (Sm2TiVideoClip / Sm2TiAudioClip) carries its record window as <Start> and <Duration> (frames, absolute), its SOURCE in-point as <In> (frames) — written EMPTY (<In/>) on every audio clip and on generator tails — <MediaFilePath>, <MediaStartTime> (seconds), <MediaFrameRate> as a 16-hex blob = one little-endian IEEE double + 8 pad bytes (24.0 = 0000000000003840…), and <MediaTimemapBA>: tag byte 0x02 + one double (the media length in seconds) on a 100% clip, a keyed curve opening 00000001… on a retimed clip and on generators. An Sm2TiTransition sits in the same <Items> list as the clips with <Start>/<Duration> (its span), <PrettyType> (Cross Dissolve), <AlignmentType> and <Position>: type 2 centres the span on the cut, type 3 ends it at the cut (11/11 witnessed against the clip edges; the one-sided 8-frame fade-in is type 3 / Position 1). The container carries NO frame rate, start or resolution — they live in the pool folder's embedded Sm2Sequence: <FrameRate> (LE double blob), <MediaExtents> = two LE doubles, record start SECONDS then duration SECONDS (7192.0 → frame 172608 = 01:59:52:00 at 24), <Resolution> = two big-endian uint64, width then height.
309
+ - **Workaround / current handling:** Read record timing from Start/Duration, source in from In (null when empty — do not fake 0 silently), fps and start from the pool sequence (frames = round(seconds × fps)); treat a curve timemap as a retime whose speed is not decoded here (speed null) rather than 100%. The parser exposes these and editorial.parse_interchange {format:'drt', content: PATH} walks one timeline into normalized events so two timeline versions diff through turnover_changelist (v19 vs v20 of a real reel: identical, 229 of 229 retained).
310
+ - **Tags:** timeline, export, drt, interchange
311
+
304
312
  ### Timeline.Export EXPORT_EDL (video-only, reel AX, clip-name comments)
305
313
 
306
314
  - **Object:** `Timeline`
package/install.py CHANGED
@@ -37,7 +37,7 @@ from src.utils.update_check import (
37
37
 
38
38
  # ─── Version ──────────────────────────────────────────────────────────────────
39
39
 
40
- VERSION = "2.189.0"
40
+ VERSION = "2.191.0"
41
41
  # Only hard floor: mcp[cli] requires Python 3.10+. There is no upper bound —
42
42
  # Resolve's scripting bridge loads into newer interpreters on recent builds
43
43
  # (Python 3.14 verified against Resolve Studio 20.3.2). Older Resolve builds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "davinci-resolve-mcp",
3
- "version": "2.189.0",
3
+ "version": "2.191.0",
4
4
  "description": "NPM bootstrapper for the DaVinci Resolve MCP Server.",
5
5
  "license": "MIT",
6
6
  "author": "Samuel Gursky <samgursky@gmail.com>",
@@ -606,13 +606,93 @@ export function parseInterchange(format, content, opts = {}) {
606
606
  case 'drt':
607
607
  case 'drp':
608
608
  throw new Error(
609
- `parse_interchange: .${String(format).toLowerCase()} is a ZIP container — parse it via the path-based reader (drt.mjs \`parseDRT(path)\`), not the sync parseInterchange(). Entry points: editorial \`list_sequences({path})\` or drt \`parse({drtPath})\`.`,
609
+ `parse_interchange: .${String(format).toLowerCase()} is a ZIP container — parse it via the async path-based reader (editorial.mjs \`parseDrtEvents(path, {timeline})\` over drt-parser \`parseDRT(path)\`, E139), not the sync parseInterchange(). Entry points: editorial \`parse_interchange({format:'drt', content: PATH})\`, \`list_sequences({path})\` or drt \`parse({drtPath})\`.`,
610
610
  );
611
611
  default:
612
612
  throw new Error(`parse_interchange: unknown format '${format}' (edl|otio|xml|xmeml|fcp7|drt|drp|aaf|prproj)`);
613
613
  }
614
614
  }
615
615
 
616
+ // ── DRT → normalized events (E139) ─────────────────────────────────────
617
+ /**
618
+ * Normalized events for ONE timeline of a parsed .drt/.drp (drt-parser
619
+ * `parseDRT`), so two Resolve timeline versions diff through
620
+ * turnover_changelist and a DRT re-export verifies like any other format.
621
+ * Measured on a real 19.1.3.7 EXPORT_DRT: a clip's record window is
622
+ * <Start>/<Duration>, its source in-point <In> (EMPTY on audio clips and on
623
+ * generator tails — reported srcInAbsent, never faked to 0 silently), its
624
+ * media <MediaFilePath>; <MediaTimemapBA> tag 0x02 = linear 100%, a keyed
625
+ * curve = a retime this reader does not decode (speed null + retimeUnknown);
626
+ * Sm2TiTransition alignment 2 centres on the cut, 3 ends at it. Record
627
+ * positions are sequence-relative (start frame subtracted), like every other
628
+ * parser here; `startFrame` is returned beside the events.
629
+ * @param {object} parsed parseDRT output
630
+ * @param {{timeline?: string|number}} [opts] pool name or index; default = first `timeline` kind
631
+ */
632
+ export function drtEventsFromParsed(parsed, opts = {}) {
633
+ const tls = (parsed && parsed.timelines) || [];
634
+ if (!tls.length) throw new Error('drt events: the archive holds no SeqContainer');
635
+ let tl = null;
636
+ if (typeof opts.timeline === 'number') tl = tls[opts.timeline] || null;
637
+ else if (typeof opts.timeline === 'string' && opts.timeline) tl = tls.find((t) => t.name === opts.timeline) || null;
638
+ else tl = tls.find((t) => t.kind === 'timeline') || tls[0];
639
+ if (!tl) throw new Error(`drt events: no timeline '${opts.timeline}' in [${tls.map((t) => t.name).join(', ')}]`);
640
+ const fps = Number(tl.frameRate) || 24;
641
+ const startFrame = Number.isFinite(Number(tl.startFrame)) ? Number(tl.startFrame) : 0;
642
+ const events = [];
643
+ let index = 1;
644
+ const base = (pth, name) => (pth ? String(pth).split(/[\\/]/).pop() : name);
645
+ const walk = (tracks, prefix) => {
646
+ (tracks || []).forEach((t, i) => {
647
+ const label = i === 0 ? prefix : `${prefix}${i + 1}`;
648
+ const before = events.length;
649
+ const clips = [...(t.clips || [])].filter((c) => Number.isFinite(c.start) && Number.isFinite(c.duration)).sort((a, b) => a.start - b.start);
650
+ for (const c of clips) {
651
+ const srcIn = c.in != null ? c.in : 0;
652
+ const media = c.mediaFilePath || null;
653
+ const isGen = !media && !c.compound;
654
+ const ev = {
655
+ index: index++, track: label, source: media ? base(media, c.name) : (c.name || 'BL'),
656
+ // A keyed speed curve makes the source OUT unknowable here — null, never
657
+ // srcIn + duration as if it played at 100%.
658
+ srcIn, srcOut: c.timemap === 'curve' ? null : srcIn + c.duration, recIn: c.start - startFrame, recOut: c.start - startFrame + c.duration,
659
+ speed: c.timemap === 'curve' ? null : 100, reverse: false, transition: null, fps,
660
+ };
661
+ if (media) ev.sourcePath = media;
662
+ if (c.in == null) ev.srcInAbsent = true;
663
+ if (c.timemap === 'curve') ev.retimeUnknown = true;
664
+ if (c.compound) ev.compound = c.compound;
665
+ if (isGen) ev.generatorName = c.name || null;
666
+ events.push(ev);
667
+ }
668
+ for (const tr of t.transitions || []) {
669
+ if (!Number.isFinite(tr.start) || !Number.isFinite(tr.duration)) continue;
670
+ const s0 = tr.start - startFrame, e0 = s0 + tr.duration;
671
+ const lane = events.slice(before).filter((ev) => ev.track === label);
672
+ const incoming = lane.find((ev) => ev.recIn > s0 - 1 && ev.recIn <= e0);
673
+ const outgoing = lane.find((ev) => ev !== incoming && ev.recOut > s0 - 1 && ev.recOut <= e0);
674
+ const transition = { type: String(tr.type || 'Cross Dissolve'), duration: tr.duration, recStart: s0 };
675
+ if (tr.alignment) transition.alignment = tr.alignment;
676
+ if (incoming) {
677
+ incoming.transition = transition;
678
+ if (!outgoing) events.push({ index: index++, track: label, source: 'BL', srcIn: 0, srcOut: 0, recIn: incoming.recIn, recOut: incoming.recIn, speed: 100, reverse: false, transition: null, fps });
679
+ } else if (outgoing) {
680
+ events.push({ index: index++, track: label, source: 'BL', srcIn: 0, srcOut: 0, recIn: outgoing.recOut, recOut: outgoing.recOut, speed: 100, reverse: false, transition, fps });
681
+ }
682
+ }
683
+ });
684
+ };
685
+ walk(tl.videoTracks, 'V');
686
+ walk(tl.audioTracks, 'A');
687
+ return { events, timeline: tl.name, kind: tl.kind || null, fps, startFrame, startTimecode: tl.startTimecode || null };
688
+ }
689
+
690
+ /** Path-based DRT/DRP → events (async: ZIP). */
691
+ export async function parseDrtEvents(filePath, opts = {}) {
692
+ const { parseDRT } = require('../vendor/drt-format/drt-parser.js');
693
+ return drtEventsFromParsed(await parseDRT(filePath), opts);
694
+ }
695
+
616
696
  // ── turnover_changelist ────────────────────────────────────────────────
617
697
  const sig = (e) => `${e.track}:${e.source}`;
618
698
  const isBlackSource = (s) => /^(bl|black|solid color)$/i.test(String(s || '').trim());
@@ -712,21 +792,39 @@ function pairEvents(oldEvents, newEvents, recTol = 1) {
712
792
  return { cuts, carriers, transitions: trs };
713
793
  };
714
794
  const o = cutsOf(oldEvents), n = cutsOf(newEvents);
715
- const pool = o.cuts.map((e) => ({ e, used: false }));
716
- const pairs = [], unmatchedNew = [];
717
- for (const ne of n.cuts) {
718
- const cands = pool.filter((p) => !p.used && sig(p.e) === sig(ne));
719
- if (!cands.length) { unmatchedNew.push(ne); continue; }
720
- cands.sort((a, b) => Math.abs((a.e.recIn ?? 0) - (ne.recIn ?? 0)) - Math.abs((b.e.recIn ?? 0) - (ne.recIn ?? 0)));
721
- cands[0].used = true;
722
- pairs.push({ oe: cands[0].e, ne });
795
+ // Pairing is closest-first GLOBALLY (E138), not first-come in new order:
796
+ // walking new cuts in order let the first new instance of a source consume
797
+ // an old instance 6,000 frames away while the old instance at its own
798
+ // position went unpaired a subset reel read back as moved + new. Every
799
+ // same-signature (old, new) pair sorts by record distance and is taken
800
+ // once; the result is symmetric under swapping old and new.
801
+ const pool = o.cuts.map((e) => ({ e, used: false, sig: sig(e) }));
802
+ const newSigs = n.cuts.map(sig);
803
+ const cands = [];
804
+ for (let ni = 0; ni < n.cuts.length; ni++) {
805
+ for (let oi = 0; oi < pool.length; oi++) {
806
+ if (pool[oi].sig !== newSigs[ni]) continue;
807
+ cands.push({ oi, ni, d: Math.abs((pool[oi].e.recIn ?? 0) - (n.cuts[ni].recIn ?? 0)) });
808
+ }
809
+ }
810
+ cands.sort((a, b) => a.d - b.d || a.ni - b.ni || a.oi - b.oi);
811
+ const usedNew = new Set();
812
+ const taken = [];
813
+ for (const c of cands) {
814
+ if (pool[c.oi].used || usedNew.has(c.ni)) continue;
815
+ pool[c.oi].used = true; usedNew.add(c.ni);
816
+ taken.push(c);
723
817
  }
818
+ taken.sort((a, b) => a.ni - b.ni);
819
+ const pairs = taken.map((c) => ({ oe: pool[c.oi].e, ne: n.cuts[c.ni] }));
820
+ const unmatchedNew = n.cuts.filter((_, i) => !usedNew.has(i));
724
821
  const unmatchedOld = pool.filter((p) => !p.used).map((p) => p.e);
725
822
  return { pairs, unmatchedOld, unmatchedNew, old: o, new: n, recTol };
726
823
  }
727
824
 
728
825
  /**
729
- * Diff two normalized event lists → per-event {kind: moved|retimed|trimmed|replaced|new|gone}
826
+ * Diff two normalized event lists → a SHAPE verdict (identical|subset|superset|edit, E138)
827
+ * plus per-event {kind: moved|retimed|trimmed|replaced|new|gone}
730
828
  * PLUS per-junction {kind: transition_added|transition_dropped|transition_changed}
731
829
  * (fade 'in'/'out' or null for a dissolve). Zero-length carrier lines and the
732
830
  * black legs that carry fades fold into the junction diff instead of reading
@@ -762,6 +860,7 @@ export function diffChangelist(oldEvents, newEvents, opts = {}) {
762
860
  }
763
861
  const P = pairEvents(oldEvents.filter((e) => !skipOld.has(e)), newEvents.filter((e) => !skipNew.has(e)), recTol);
764
862
 
863
+ const retained = [];
765
864
  for (const { oe, ne } of P.pairs) {
766
865
  const deltas = {};
767
866
  let kind = 'unchanged';
@@ -777,8 +876,9 @@ export function diffChangelist(oldEvents, newEvents, opts = {}) {
777
876
  deltas.src = { old: [oe.srcIn, oe.srcOut], new: [ne.srcIn, ne.srcOut] };
778
877
  }
779
878
  if (kind !== 'unchanged') changes.push({ kind, source: ne.source, track: ne.track, oldRecIn: oe.recIn, newRecIn: ne.recIn, deltas });
879
+ else retained.push(ne);
780
880
  }
781
- for (const ne of P.unmatchedNew) changes.push({ kind: 'new', source: ne.source, track: ne.track, newRecIn: ne.recIn });
881
+ for (const ne of P.unmatchedNew) changes.push({ kind: 'new', source: ne.source, track: ne.track, newRecIn: ne.recIn, newRecOut: ne.recOut });
782
882
  // Unconsumed old events → gone (unless a 'new' at the same rec position → replaced).
783
883
  for (const oe of P.unmatchedOld) {
784
884
  const replacement = changes.find((c) => c.kind === 'new' && c.track === oe.track && Math.abs((c.newRecIn ?? 0) - (oe.recIn ?? 0)) <= recTol);
@@ -787,7 +887,7 @@ export function diffChangelist(oldEvents, newEvents, opts = {}) {
787
887
  replacement.oldSource = oe.source;
788
888
  replacement.oldRecIn = oe.recIn;
789
889
  } else {
790
- changes.push({ kind: 'gone', source: oe.source, track: oe.track, oldRecIn: oe.recIn });
890
+ changes.push({ kind: 'gone', source: oe.source, track: oe.track, oldRecIn: oe.recIn, oldRecOut: oe.recOut });
791
891
  }
792
892
  }
793
893
 
@@ -825,10 +925,40 @@ export function diffChangelist(oldEvents, newEvents, opts = {}) {
825
925
  const counts = {};
826
926
  for (const c of changes) counts[c.kind] = (counts[c.kind] || 0) + 1;
827
927
  changes.sort((a, b) => (a.newRecIn ?? a.oldRecIn ?? 0) - (b.newRecIn ?? b.oldRecIn ?? 0));
928
+
929
+ // SHAPE (E138): a real Premiere auto-save of a locked reel kept 3 of its
930
+ // 335 cuts — byte-identical at their record positions — and deleted the
931
+ // rest (a patch/selects reel). Per-event kinds read that as 332 'gone';
932
+ // it is a sparse SUBSET of the same cut with nothing edited. The verdict
933
+ // names the relationship so a reader never mistakes a subset for a
934
+ // re-cut: identical | subset (new ⊂ old) | superset (old ⊂ new) | edit.
935
+ // A transition that vanished because both cuts it joined vanished (or
936
+ // appeared with the cuts it joins) is a consequence, not an edit.
937
+ const touches = (kind, junction, track) => changes.some((c) => c.kind === kind && c.track === track
938
+ && ((kind === 'gone' ? [c.oldRecIn, c.oldRecOut] : [c.newRecIn, c.newRecOut]).some((v) => Math.abs((v ?? -1e9) - junction) <= recTol)));
939
+ const consequential = (c) => (c.kind === 'transition_dropped' && touches('gone', c.oldRecIn, c.track))
940
+ || (c.kind === 'transition_added' && touches('new', c.newRecIn, c.track));
941
+ const edits = changes.filter((c) => c.kind !== 'gone' && c.kind !== 'new' && !consequential(c)).length;
942
+ const gone = counts.gone || 0, added = counts.new || 0;
943
+ const oldCuts = P.old.cuts.length + skipOld.size, newCuts = P.new.cuts.length + skipNew.size;
944
+ let shape = 'edit';
945
+ if (!changes.length) shape = 'identical';
946
+ else if (!edits && gone && !added && retained.length) shape = 'subset';
947
+ else if (!edits && added && !gone && retained.length) shape = 'superset';
948
+ const shapeInfo = { shape, retained: retained.length, oldCuts, newCuts };
949
+ if (shape === 'subset' || shape === 'superset') {
950
+ const of = shape === 'subset' ? oldCuts : newCuts;
951
+ shapeInfo.sparse = retained.length / Math.max(1, of) < 0.5;
952
+ shapeInfo.retainedWindows = retained.slice(0, 200).map((e) => ({ track: e.track, source: e.source, recIn: e.recIn, recOut: e.recOut }));
953
+ shapeInfo.note = shape === 'subset'
954
+ ? `new keeps ${retained.length} of ${oldCuts} cuts unchanged in place and nothing else — a patch/selects reel of the same cut, not ${gone} deletions`
955
+ : `old is ${retained.length} of the new cut's ${newCuts} cuts, unchanged in place — the rest is the new cut's additions, not ${added} edits to old`;
956
+ }
828
957
  return {
829
958
  changes, counts, changedCount: changes.length,
830
959
  transitions: { old: P.old.transitions.length, new: P.new.transitions.length },
831
960
  carriersFolded: { old: P.old.carriers.length, new: P.new.carriers.length },
961
+ ...shapeInfo,
832
962
  gate: 'review',
833
963
  };
834
964
  }
@@ -3,17 +3,17 @@
3
3
  * changelist + conform manifest with TIMING silent-lie guards. Report-only (gate: review). No Resolve.
4
4
  *
5
5
  * Actions:
6
- * parse_interchange — EDL / OTIO / XMEML / AAF (pyaaf2) / PRPROJ (gunzip+XML) → normalized events
6
+ * parse_interchange — EDL / OTIO / XMEML / AAF (pyaaf2) / PRPROJ (gunzip+XML) / DRT+DRP (ZIP, one timeline) → normalized events
7
7
  * list_sequences — ONE picker entry point across xml/edl/otio/drt/drp/aaf/prproj → [{id,name,eventCount}]
8
8
  * (AAF rows also carry startTimecode/startFrame — see aaf.mjs sequenceSummary)
9
9
  * convert_to_interchange— events (or a parsed source) → OTIO/EDL/DRT Resolve CAN import (the .prproj bridge)
10
- * turnover_changelist — diff old vs new events → moved/retimed/replaced/new/gone (+timing flags)
10
+ * turnover_changelist — diff old vs new events → shape verdict (identical|subset|superset|edit) + moved/retimed/replaced/new/gone (+timing flags)
11
11
  * conform_manifest — per-event assert: source resolved, handles, retime, reverse, TC-base
12
12
  * marker_roundtrip — marker/note round-trip with provenance tags
13
13
  */
14
14
  import fs from 'node:fs/promises';
15
15
  import { z } from 'zod';
16
- import { parseInterchange, diffChangelist, timingGuards, conformManifest, markerRoundtrip } from '../editorial.mjs';
16
+ import { parseInterchange, parseDrtEvents, diffChangelist, timingGuards, conformManifest, markerRoundtrip } from '../editorial.mjs';
17
17
  import { parseAAF, parseAafDocument } from '../aaf.mjs';
18
18
  import { parsePrproj, parsePrprojDoc } from '../prproj.mjs';
19
19
  import { listSequences, detectFormat } from '../sequences.mjs';
@@ -39,9 +39,10 @@ const parseSchema = z.object({
39
39
  content: z
40
40
  .union([z.string(), z.object({}).passthrough()])
41
41
  .describe(
42
- 'EDL text / OTIO JSON (string or object) / XMEML string. For AAF or PRPROJ (binary): the file PATH. For .drt/.drp (ZIP): use list_sequences or drt.parse — this action redirects.',
42
+ 'EDL text / OTIO JSON (string or object) / XMEML string. For AAF, PRPROJ, DRT or DRP (binary/ZIP): the file PATH.',
43
43
  ),
44
44
  fps: z.number().optional(),
45
+ timeline: z.union([z.string(), z.number()]).optional().describe('drt/drp only: pool timeline name or index to walk (default: the first timeline-kind container; list_sequences names them)'),
45
46
  });
46
47
 
47
48
  const listSequencesSchema = z.object({
@@ -86,7 +87,7 @@ const markerSchema = z.object({
86
87
  export const editorialTool = {
87
88
  name: 'editorial',
88
89
  description:
89
- 'Editorial integrity (Cluster E) — turnover interchange → normalized events → changelist + conform manifest with TIMING silent-lie guards (flattened retime / dropped J/L-cut audio / framerate-pulldown slip / reverse dropped / transition-handle starvation → flag, skip-not-fake). Report-only (gate: review). Actions: parse_interchange (EDL/OTIO/XMEML natively — incl. Resolve-written OTIO generator clips (a Solid Color is a Clip with a NULL media_reference; it walks as a BL leg with generatorName, and an OTIO GeneratorReference carries its colour) and nested OTIO Stacks (compound clips — Resolve\'s writer nests them with a trim window) FLATTEN into record time with fromCompound on each cut, so Resolve\'s own OTIO exports re-conform (its FCP7 XML writer flattens a compound to ONE media-less clipitem instead — tagged `compound`, which the bridge drops with a reason in unresolvedCompounds unless the sourceMap maps the compound name to a flattened media file), Resolve-written FCP7 -1 junction edges (paired in record order) + Solid Color / Color Matte generators carrying their `fillcolor` (BL legs with `color` → fade-to-white and colour mattes author, E110), XMEML audio-track transitionitems as audio cross-fades on numbered lanes A/A2/…, and CMX FROM/TO CLIP NAME comments over the generic AX reel — + AAF via pyaaf2 (flat sound/picture slots number A/A2/… and V/V2/… in slot order so separate beds keep their lanes; NestedScope layers keep layer numbering; a NESTED SEQUENCE used as a clip — a SourceClip referencing a named CompositionMob — flattens through its reference window with fromCompound, like OTIO Stacks) + PRPROJ via gunzip+XML (real Premiere 2025 files — uuid ObjectUID/ObjectURef graph, TrackGroups, ClipTrackItem→SubClip→VideoClip→MediaSource→Media chain, zeros written as absence — and the legacy ObjectID/VideoTracks shape both walk; measured on a 739-sequence turnover that used to list ZERO; a NESTED SEQUENCE used as a clip — Source = Video/AudioSequenceSource → Sequence — flattens through its in-point window with fromCompound, like OTIO Stacks and AAF nested compositions; 13,711 such events on one real reels project; real transitions live in the track\'s TransitionItems list — read alongside ClipItems, attached with their DisplayName as type, HasOutgoingClip/HasIncomingClip false = fade from/to black or silence; tracks number as lanes V/V2…/A/A2… and a flattened nested sequence\'s inner lanes first-fit above what the parent already stacks — laneShift records the shift; markers are the sequence\'s OWN, read from Premiere\'s DVAMarker JSON) → normalized events incl. span-explicit transitions, BL fade legs, and freezes as zero-speed events (OTIO FreezeFrame, XMEML timeremap 0, PrProj in==out, AAF 0% motion effects); for AAF/PRPROJ pass the file PATH as content; AAF also returns per-sequence startTimecode/startFrame — build the timeline at THAT start, not the Resolve 01:00:00:00 default — and per-clip `geometry` for Avid transform effects), list_sequences (ONE offline picker entry point across xml/edl/otio/drt/drp/aaf/prproj → [{id,name,eventCount}], plus startTimecode/startFrame for AAF and nestedIn — an AAF composition another composition uses as a clip is NESTED in it; offer the parent, its cuts arrive flattened), convert_to_interchange (author OTIO/EDL/DRT Resolve CAN import from events or a parsed source; the EDL target writes CMX transition pairs incl. BL fades — the .prproj→Resolve conform bridge, no Premiere needed; editorial timing/transitions survive and per-clip effects/color do not. SPEED/REVERSE survive on the otio (LinearTimeWarp) and edl (M2) targets ONLY — this FLAT drt target flattens every retime to 100% forward and returns `flattened`/`flattenedCount` naming each event that lost one (`flattened` is always present on `drt`, empty when there were none); for a .drt that AUTHORS retimes/dissolves/multi-track/audio, use drt.assemble_from_interchange), turnover_changelist (diff old vs new → moved/retimed/trimmed/replaced/new/gone PLUS the junction diff: transition_added/transition_dropped/transition_changed with fade in/out or dissolve, outgoing/incoming, span and duration/type/pre-roll deltas — zero-length CMX carrier lines and the BL legs that carry fades fold into the junction diff instead of reading as gone/new sources; events pair by closest record position, consumed once, so a source cut twice at two speeds compares instance to instance; + timing flags incl. transition_dropped and dropped_split_audio on any A-track; a compound seen collapsed in one cut and flattened in the other reports compound_collapsed/compound_expanded once, never replaced+gone), conform_manifest (per-event assert: source resolved/handles/retime/reverse/TC-base; BL-aware — black legs need no source, fades no black-side handles, and a fade-out tail requirement lands on the picture source; a compound clipitem fails source_resolved by NAME with the remedy — map it to a flattened file or turn over as OTIO), marker_roundtrip (markers with provenance tags), verify_roundtrip (input events vs re-export events -> pass/mismatches + fitted per-source TC offsets + marker compare w/ markersNotInExport honesty flag; FADE-AWARE: BL/Solid-Color legs merge out as blackSegments and fade-window boundary reshapes are excused into fadeReshapedBoundaries instead of failing; RETIME-AWARE: speed/reverse compare pairwise — EXPORT_OTIO carries an authored Sm2TimeMap back as LinearTimeWarp (measured), so a flattened/lost retime fails as drift geometry alone cannot catch; AUDIO-AWARE: declared audio events compare (a video-only export such as EXPORT_EDL flags audioNotInExport instead of failing) (channel legs deduped, mismatches tagged trackType audio) while the mirrored-A1 export of a video-only turnover stays informational; COLOUR-AWARE: an input generator leg carrying a fillcolor (fade-to-white, colour matte) must come back on the same track over its span with the same colour — Resolve\'s FCP7 writer emits it — else generator-colour fails (generatorColours reports the compare) — pass exportedFormat: an OTIO/EDL re-export cannot carry colour (measured) and reports generatorColourNotInExport instead of failing; COMPOUND-AWARE: an XML re-export that collapsed a compound to one clipitem over cuts the input flattened from that compound reports compoundsCollapsedInExport instead of count/source drift; the conform QC loop-closer). Offline (AAF needs pyaaf2; live AAF/DRP import is on the Python davinci-resolve MCP).',
90
+ 'Editorial integrity (Cluster E) — turnover interchange → normalized events → changelist + conform manifest with TIMING silent-lie guards (flattened retime / dropped J/L-cut audio / framerate-pulldown slip / reverse dropped / transition-handle starvation → flag, skip-not-fake). Report-only (gate: review). Actions: parse_interchange (EDL/OTIO/XMEML natively — incl. Resolve-written OTIO generator clips (a Solid Color is a Clip with a NULL media_reference; it walks as a BL leg with generatorName, and an OTIO GeneratorReference carries its colour) and nested OTIO Stacks (compound clips — Resolve\'s writer nests them with a trim window) FLATTEN into record time with fromCompound on each cut, so Resolve\'s own OTIO exports re-conform (its FCP7 XML writer flattens a compound to ONE media-less clipitem instead — tagged `compound`, which the bridge drops with a reason in unresolvedCompounds unless the sourceMap maps the compound name to a flattened media file), Resolve-written FCP7 -1 junction edges (paired in record order) + Solid Color / Color Matte generators carrying their `fillcolor` (BL legs with `color` → fade-to-white and colour mattes author, E110), XMEML audio-track transitionitems as audio cross-fades on numbered lanes A/A2/…, and CMX FROM/TO CLIP NAME comments over the generic AX reel — + AAF via pyaaf2 (flat sound/picture slots number A/A2/… and V/V2/… in slot order so separate beds keep their lanes; NestedScope layers keep layer numbering; a NESTED SEQUENCE used as a clip — a SourceClip referencing a named CompositionMob — flattens through its reference window with fromCompound, like OTIO Stacks) + PRPROJ via gunzip+XML (real Premiere 2025 files — uuid ObjectUID/ObjectURef graph, TrackGroups, ClipTrackItem→SubClip→VideoClip→MediaSource→Media chain, zeros written as absence — and the legacy ObjectID/VideoTracks shape both walk; measured on a 739-sequence turnover that used to list ZERO; a NESTED SEQUENCE used as a clip — Source = Video/AudioSequenceSource → Sequence — flattens through its in-point window with fromCompound, like OTIO Stacks and AAF nested compositions; 13,711 such events on one real reels project; real transitions live in the track\'s TransitionItems list — read alongside ClipItems, attached with their DisplayName as type, HasOutgoingClip/HasIncomingClip false = fade from/to black or silence; tracks number as lanes V/V2…/A/A2… and a flattened nested sequence\'s inner lanes first-fit above what the parent already stacks — laneShift records the shift; markers are the sequence\'s OWN, read from Premiere\'s DVAMarker JSON) → normalized events incl. span-explicit transitions, BL fade legs, and freezes as zero-speed events (OTIO FreezeFrame, XMEML timeremap 0, PrProj in==out, AAF 0% motion effects); for AAF/PRPROJ/DRT/DRP pass the file PATH as content; DRT/DRP walk ONE timeline (`timeline` = pool name or index; default the first timeline-kind container) into events with sequence-relative record positions + the returned startFrame/startTimecode/fps read from the pool sequence — <In> is the source in-point (EMPTY on real audio clips → srcInAbsent), a keyed MediaTimemapBA curve is a retime this reader does not decode (speed null + retimeUnknown, never faked to 100%), Sm2TiTransition alignment 2 centres on the cut and 3 ends at it — so two Resolve timeline VERSIONS diff through turnover_changelist (E139); AAF also returns per-sequence startTimecode/startFrame — build the timeline at THAT start, not the Resolve 01:00:00:00 default — and per-clip `geometry` for Avid transform effects), list_sequences (ONE offline picker entry point across xml/edl/otio/drt/drp/aaf/prproj → [{id,name,eventCount}], plus startTimecode/startFrame for AAF and nestedIn — an AAF composition another composition uses as a clip is NESTED in it; offer the parent, its cuts arrive flattened), convert_to_interchange (author OTIO/EDL/DRT Resolve CAN import from events or a parsed source; the EDL target writes CMX transition pairs incl. BL fades — the .prproj→Resolve conform bridge, no Premiere needed; editorial timing/transitions survive and per-clip effects/color do not. SPEED/REVERSE survive on the otio (LinearTimeWarp) and edl (M2) targets ONLY — this FLAT drt target flattens every retime to 100% forward and returns `flattened`/`flattenedCount` naming each event that lost one (`flattened` is always present on `drt`, empty when there were none); for a .drt that AUTHORS retimes/dissolves/multi-track/audio, use drt.assemble_from_interchange), turnover_changelist (diff old vs new → a SHAPE verdict first — identical | subset (new keeps some of old\'s cuts unchanged in place and nothing else: a patch/selects reel of the same cut, NOT N deletions; a real Premiere auto-save kept 3 of 335) | superset (the reverse) | edit — with retained/oldCuts/newCuts, `sparse` and the retainedWindows for subset/superset, a transition that vanished or appeared with the cuts it joins counting as a consequence not an edit; then moved/retimed/trimmed/replaced/new/gone PLUS the junction diff: transition_added/transition_dropped/transition_changed with fade in/out or dissolve, outgoing/incoming, span and duration/type/pre-roll deltas — zero-length CMX carrier lines and the BL legs that carry fades fold into the junction diff instead of reading as gone/new sources; events pair by closest record position, consumed once, so a source cut twice at two speeds compares instance to instance; + timing flags incl. transition_dropped and dropped_split_audio on any A-track; a compound seen collapsed in one cut and flattened in the other reports compound_collapsed/compound_expanded once, never replaced+gone), conform_manifest (per-event assert: source resolved/handles/retime/reverse/TC-base; BL-aware — black legs need no source, fades no black-side handles, and a fade-out tail requirement lands on the picture source; a compound clipitem fails source_resolved by NAME with the remedy — map it to a flattened file or turn over as OTIO), marker_roundtrip (markers with provenance tags), verify_roundtrip (input events vs re-export events -> pass/mismatches + fitted per-source TC offsets + marker compare w/ markersNotInExport honesty flag; FADE-AWARE: BL/Solid-Color legs merge out as blackSegments and fade-window boundary reshapes are excused into fadeReshapedBoundaries instead of failing; RETIME-AWARE: speed/reverse compare pairwise — EXPORT_OTIO carries an authored Sm2TimeMap back as LinearTimeWarp (measured), so a flattened/lost retime fails as drift geometry alone cannot catch; AUDIO-AWARE: declared audio events compare (a video-only export such as EXPORT_EDL flags audioNotInExport instead of failing) (channel legs deduped, mismatches tagged trackType audio) while the mirrored-A1 export of a video-only turnover stays informational; COLOUR-AWARE: an input generator leg carrying a fillcolor (fade-to-white, colour matte) must come back on the same track over its span with the same colour — Resolve\'s FCP7 writer emits it — else generator-colour fails (generatorColours reports the compare) — pass exportedFormat: an OTIO/EDL re-export cannot carry colour (measured) and reports generatorColourNotInExport instead of failing; COMPOUND-AWARE: an XML re-export that collapsed a compound to one clipitem over cuts the input flattened from that compound reports compoundsCollapsedInExport instead of count/source drift; the conform QC loop-closer). Offline (AAF needs pyaaf2; live AAF/DRP import is on the Python davinci-resolve MCP).',
90
91
  async handler({ action, args }) {
91
92
  if (action === 'parse_interchange') {
92
93
  const p = parseSchema.parse(args);
@@ -98,6 +99,15 @@ export const editorialTool = {
98
99
  const { events, sequences } = await parseAafDocument(p.content);
99
100
  return { format: 'aaf', count: events.length, events, sequences };
100
101
  }
102
+ if (p.format === 'drt' || p.format === 'drp') {
103
+ // A .drt/.drp is a ZIP: the caller must hand over the PATH. Inline bytes
104
+ // (a slurped archive) name the requirement instead of surfacing ENOENT
105
+ // on the first four bytes of the file.
106
+ const isPath = typeof p.content === 'string' && await fs.access(p.content).then(() => true, () => false);
107
+ if (!isPath) throw new Error(`parse_interchange: for ${p.format} pass the file PATH as content — a .${p.format} is a ZIP read by parseDRT(path), not text`);
108
+ const r = await parseDrtEvents(p.content, { timeline: p.timeline });
109
+ return { format: p.format, count: r.events.length, events: r.events, timeline: r.timeline, kind: r.kind, fps: r.fps, startFrame: r.startFrame, startTimecode: r.startTimecode };
110
+ }
101
111
  if (p.format === 'prproj') {
102
112
  const doc = parsePrprojDoc(p.content);
103
113
  const events = parsePrproj(p.content);
@@ -39,6 +39,60 @@ function extractInt(xml, tag) {
39
39
 
40
40
  const CLIP_TAGS = ['Sm2TiVideoClip', 'Sm2VideoClip', 'Sm2TiAudioClip', 'Sm2AudioClip'];
41
41
 
42
+ // Resolve stores several scalars as 16-hex-char blobs (E139, measured on a
43
+ // 19.1.3.7 EXPORT_DRT): <FrameRate> / <MediaFrameRate> = one little-endian
44
+ // IEEE double + 8 pad bytes (24.0 = 0000000000003840…); <MediaExtents> = two
45
+ // little-endian doubles, start SECONDS then duration SECONDS; <Resolution> =
46
+ // two big-endian uint64, width then height.
47
+ function leDouble(hex, offset = 0) {
48
+ const h = String(hex || '').replace(/[^0-9a-fA-F]/g, '');
49
+ if (h.length < offset + 16) return null;
50
+ const v = Buffer.from(h.slice(offset, offset + 16), 'hex').readDoubleLE(0);
51
+ return Number.isFinite(v) ? v : null;
52
+ }
53
+ function beUint64(hex, offset = 0) {
54
+ const h = String(hex || '').replace(/[^0-9a-fA-F]/g, '');
55
+ if (h.length < offset + 16) return null;
56
+ const v = Number(Buffer.from(h.slice(offset, offset + 16), 'hex').readBigUInt64BE(0));
57
+ return Number.isFinite(v) ? v : null;
58
+ }
59
+ // <MediaTimemapBA>: tag byte 0x02 + one double = a LINEAR (100%) clip whose
60
+ // double is the media length in seconds; a blob opening 00000001… is a keyed
61
+ // speed CURVE (retime) whose speed this parser does not decode — it is
62
+ // reported as 'curve' so a consumer never fakes 100%.
63
+ function timemapKind(hex) {
64
+ const h = String(hex || '').replace(/[^0-9a-fA-F]/g, '').toLowerCase();
65
+ if (!h) return null;
66
+ if (h.startsWith('02') && h.length === 18) return 'linear';
67
+ if (h.startsWith('02')) return 'linear-multi';
68
+ if (h.startsWith('00000001')) return 'curve';
69
+ return 'unknown';
70
+ }
71
+ // Sm2TiTransition alignment (E139, witnessed against the cut points of 11
72
+ // real dissolves): 2 = centred on the cut, 3 = ends at the cut (the
73
+ // one-sided 8-frame fade-in on a real reel is type 3 / Position 1).
74
+ const ALIGNMENT_BY_TYPE = { 1: 'start', 2: 'center', 3: 'end' };
75
+
76
+ function extractTransitionsFromTrackXml(trackXml) {
77
+ const out = [];
78
+ const re = /<(Sm2TiTransition)\b[^>]*?DbId="([^"]+)"[^>]*>([\s\S]*?)<\/\1>/g;
79
+ let m;
80
+ while ((m = re.exec(trackXml)) !== null) {
81
+ const inner = m[3];
82
+ const alignmentType = extractInt(inner, 'AlignmentType');
83
+ out.push({
84
+ transitionId: m[2],
85
+ type: extractScalar(inner, 'PrettyType') || 'Cross Dissolve',
86
+ start: extractInt(inner, 'Start'),
87
+ duration: extractInt(inner, 'Duration'),
88
+ alignmentType,
89
+ alignment: alignmentType != null ? ALIGNMENT_BY_TYPE[alignmentType] || null : null,
90
+ position: extractInt(inner, 'Position'),
91
+ });
92
+ }
93
+ return out;
94
+ }
95
+
42
96
  function extractClipsFromTrackXml(trackXml, trackType) {
43
97
  const clips = [];
44
98
  const tagAlt = CLIP_TAGS.filter((t) => t.toLowerCase().includes(trackType)).join('|');
@@ -56,6 +110,8 @@ function extractClipsFromTrackXml(trackXml, trackType) {
56
110
  const stripped = bodyMatch[1].replace(/[^0-9a-fA-F]/g, '');
57
111
  if (stripped.length > 0) bodyHex = stripped;
58
112
  }
113
+ const inRaw = extractScalar(inner, 'In');
114
+ const mst = extractScalar(inner, 'MediaStartTime');
59
115
  clips.push({
60
116
  clipId: m[3],
61
117
  name: extractScalar(inner, 'Name'),
@@ -63,6 +119,13 @@ function extractClipsFromTrackXml(trackXml, trackType) {
63
119
  duration,
64
120
  mediaFilePath,
65
121
  bodyHex,
122
+ // E139: the clip's SOURCE in-point in frames (<In>); a real export writes
123
+ // an EMPTY <In/> on audio clips and on generator tails — null, not 0.
124
+ in: inRaw === null || inRaw === '' ? null : (Number.isFinite(Number.parseInt(inRaw, 10)) ? Number.parseInt(inRaw, 10) : null),
125
+ mediaStartTime: mst === null || mst === '' ? null : (Number.isFinite(Number(mst)) ? Number(mst) : null),
126
+ mediaFrameRate: leDouble(extractScalar(inner, 'MediaFrameRate')),
127
+ timemap: timemapKind(extractScalar(inner, 'MediaTimemapBA')),
128
+ prettyType: extractScalar(inner, 'PrettyType') || null,
66
129
  });
67
130
  }
68
131
  return clips;
@@ -90,6 +153,7 @@ function extractTracks(seqXml, trackVecTag, trackTagBase, trackType) {
90
153
  trackId,
91
154
  trackType,
92
155
  clips: extractClipsFromTrackXml(trackInner, trackType),
156
+ transitions: extractTransitionsFromTrackXml(trackInner),
93
157
  });
94
158
  }
95
159
  return tracks;
@@ -114,16 +178,47 @@ async function loadPoolSequenceNames(zip) {
114
178
  while ((m = re.exec(xml)) !== null) {
115
179
  const body = m[3];
116
180
  const name = extractScalar(body, 'Name');
117
- const seqRe = /<Sm2Sequence DbId="([^"]+)">/g;
181
+ const seqRe = /<Sm2Sequence DbId="([^"]+)">([\s\S]*?)<\/Sm2Sequence>/g;
118
182
  let sm;
119
183
  while ((sm = seqRe.exec(body)) !== null) {
120
- if (!map.has(sm[1])) map.set(sm[1], { name, kind: m[1] === 'Sm2MpCompoundClip' ? 'compound' : 'timeline' });
184
+ if (map.has(sm[1])) continue;
185
+ // E139: the embedded Sm2Sequence is also where a real export keeps the
186
+ // timeline's frame rate, record extents and resolution — the
187
+ // SeqContainer carries none of them.
188
+ const sb = sm[2];
189
+ const ext = extractScalar(sb, 'MediaExtents');
190
+ const res = extractScalar(sb, 'Resolution');
191
+ map.set(sm[1], {
192
+ name,
193
+ kind: m[1] === 'Sm2MpCompoundClip' ? 'compound' : 'timeline',
194
+ frameRate: leDouble(extractScalar(sb, 'FrameRate')),
195
+ startSeconds: ext ? leDouble(ext, 0) : null,
196
+ durationSeconds: ext ? leDouble(ext, 16) : null,
197
+ width: res ? beUint64(res, 0) : null,
198
+ height: res ? beUint64(res, 16) : null,
199
+ });
121
200
  }
122
201
  }
123
202
  }
124
203
  return map;
125
204
  }
126
205
 
206
+ // E139: a real export's record start lives ONLY in the pool sequence's
207
+ // MediaExtents (seconds) — frames = round(seconds × fps); the timecode is
208
+ // derived at that rate (non-drop; the export writes no drop flag here).
209
+ function poolStartFrame(pool) {
210
+ if (!pool || pool.startSeconds == null || !pool.frameRate) return null;
211
+ return Math.round(pool.startSeconds * pool.frameRate);
212
+ }
213
+ function poolStartTimecode(pool) {
214
+ const f = poolStartFrame(pool);
215
+ if (f == null) return null;
216
+ const fps = Math.round(pool.frameRate);
217
+ const ff = f % fps, totalS = Math.floor(f / fps);
218
+ const pad = (n) => String(n).padStart(2, '0');
219
+ return `${pad(Math.floor(totalS / 3600))}:${pad(Math.floor(totalS / 60) % 60)}:${pad(totalS % 60)}:${pad(ff)}`;
220
+ }
221
+
127
222
  function parseSeqContainer(seqXml, sequenceName, poolNames = new Map()) {
128
223
  const seqId = extractScalar(seqXml, 'Sequence');
129
224
  const pool = seqId ? poolNames.get(seqId) : null;
@@ -134,13 +229,13 @@ function parseSeqContainer(seqXml, sequenceName, poolNames = new Map()) {
134
229
  name: (pool && pool.name) || extractScalar(seqXml, 'Name') || sequenceName,
135
230
  kind: pool ? pool.kind : null,
136
231
  sequence: sequenceName,
137
- frameRate: extractScalar(seqXml, 'FrameRate'),
138
- startTimecode: extractScalar(seqXml, 'StartTC'),
139
- startFrame: extractInt(seqXml, 'StartFrame'),
232
+ frameRate: extractScalar(seqXml, 'FrameRate') ?? (pool && pool.frameRate != null ? pool.frameRate : null),
233
+ startTimecode: extractScalar(seqXml, 'StartTC') ?? poolStartTimecode(pool),
234
+ startFrame: extractInt(seqXml, 'StartFrame') ?? poolStartFrame(pool),
140
235
  resolution: (() => {
141
236
  const w = extractInt(seqXml, 'ResolutionWidth');
142
237
  const h = extractInt(seqXml, 'ResolutionHeight');
143
- if (w === null || h === null) return null;
238
+ if (w === null || h === null) return pool && pool.width && pool.height ? `${pool.width}x${pool.height}` : null;
144
239
  return `${w}x${h}`;
145
240
  })(),
146
241
  videoTracks: extractTracks(seqXml, 'VideoTrackVec', 'Sm2TiVideoTrack', 'video').map((t) => ({
@@ -87,7 +87,7 @@ if not logging.getLogger().handlers:
87
87
  handlers=[logging.StreamHandler()],
88
88
  )
89
89
 
90
- VERSION = "2.189.0"
90
+ VERSION = "2.191.0"
91
91
  logger = logging.getLogger("davinci-resolve-mcp")
92
92
  logger.info(f"Starting DaVinci Resolve MCP Server v{VERSION}")
93
93
  logger.info(f"Detected platform: {get_platform()}")
package/src/server.py CHANGED
@@ -11,7 +11,7 @@ Usage:
11
11
  python src/server.py --full # Start the 353-tool granular server instead
12
12
  """
13
13
 
14
- VERSION = "2.189.0"
14
+ VERSION = "2.191.0"
15
15
 
16
16
  import base64
17
17
  import os
@@ -2729,6 +2729,47 @@ API_TRUTH: List[Dict[str, Any]] = [
2729
2729
  "submit": "bug",
2730
2730
  "mitigation": ["drt.assemble cuts[].markers"],
2731
2731
  },
2732
+ {
2733
+ "symbol": "Timeline.Export EXPORT_DRT (clip, transition and pool-sequence field encodings)",
2734
+ "object": "Timeline",
2735
+ "signature": "(filePath, EXPORT_DRT) -> bool",
2736
+ "reality": "Measured on a Studio 19.1.3.7 export of a 229-clip reel "
2737
+ "(E139). A SeqContainer clip (Sm2TiVideoClip / "
2738
+ "Sm2TiAudioClip) carries its record window as <Start> and "
2739
+ "<Duration> (frames, absolute), its SOURCE in-point as <In> "
2740
+ "(frames) — written EMPTY (<In/>) on every audio clip and on "
2741
+ "generator tails — <MediaFilePath>, <MediaStartTime> "
2742
+ "(seconds), <MediaFrameRate> as a 16-hex blob = one "
2743
+ "little-endian IEEE double + 8 pad bytes (24.0 = "
2744
+ "0000000000003840…), and <MediaTimemapBA>: tag byte 0x02 + "
2745
+ "one double (the media length in seconds) on a 100% clip, a "
2746
+ "keyed curve opening 00000001… on a retimed clip and on "
2747
+ "generators. An Sm2TiTransition sits in the same <Items> "
2748
+ "list as the clips with <Start>/<Duration> (its span), "
2749
+ "<PrettyType> (Cross Dissolve), <AlignmentType> and "
2750
+ "<Position>: type 2 centres the span on the cut, type 3 ends "
2751
+ "it at the cut (11/11 witnessed against the clip edges; the "
2752
+ "one-sided 8-frame fade-in is type 3 / Position 1). The "
2753
+ "container carries NO frame rate, start or resolution — they "
2754
+ "live in the pool folder's embedded Sm2Sequence: <FrameRate> "
2755
+ "(LE double blob), <MediaExtents> = two LE doubles, record "
2756
+ "start SECONDS then duration SECONDS (7192.0 → frame 172608 "
2757
+ "= 01:59:52:00 at 24), <Resolution> = two big-endian uint64, "
2758
+ "width then height.",
2759
+ "recommended": "Read record timing from Start/Duration, source in from "
2760
+ "In (null when empty — do not fake 0 silently), fps and "
2761
+ "start from the pool sequence (frames = round(seconds × "
2762
+ "fps)); treat a curve timemap as a retime whose speed is "
2763
+ "not decoded here (speed null) rather than 100%. The "
2764
+ "parser exposes these and editorial.parse_interchange "
2765
+ "{format:'drt', content: PATH} walks one timeline into "
2766
+ "normalized events so two timeline versions diff through "
2767
+ "turnover_changelist (v19 vs v20 of a real reel: "
2768
+ "identical, 229 of 229 retained).",
2769
+ "tags": ["timeline", "export", "drt", "interchange"],
2770
+ "submit": "missing",
2771
+ "mitigation": ["editorial.parse_interchange drt", "drt.parse"],
2772
+ },
2732
2773
  {
2733
2774
  "symbol": "Timeline.Export EXPORT_OTIO (drops timeline markers)",
2734
2775
  "object": "Timeline",