@morshoto/framekit 0.1.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.
Files changed (31) hide show
  1. package/README.md +67 -0
  2. package/bin/framekit.mjs +26 -0
  3. package/dist-package/adapters/final-cut/typescript/src/analyzers.js +116 -0
  4. package/dist-package/adapters/final-cut/typescript/src/assets.js +112 -0
  5. package/dist-package/adapters/final-cut/typescript/src/connection.js +379 -0
  6. package/dist-package/adapters/final-cut/typescript/src/disposable-native.js +282 -0
  7. package/dist-package/adapters/final-cut/typescript/src/export.js +382 -0
  8. package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +503 -0
  9. package/dist-package/adapters/final-cut/typescript/src/index.js +11 -0
  10. package/dist-package/adapters/final-cut/typescript/src/live.js +415 -0
  11. package/dist-package/adapters/final-cut/typescript/src/native-operation.js +18 -0
  12. package/dist-package/adapters/final-cut/typescript/src/native.js +3134 -0
  13. package/dist-package/adapters/final-cut/typescript/src/publisher.js +102 -0
  14. package/dist-package/adapters/final-cut/typescript/src/session.js +171 -0
  15. package/dist-package/apps/cli/src/main.js +130 -0
  16. package/dist-package/apps/mcp-server/src/main.js +146 -0
  17. package/dist-package/apps/mcp-server/src/server.js +617 -0
  18. package/dist-package/packages/runtime/src/capabilities.js +24 -0
  19. package/dist-package/packages/runtime/src/context/context-engine.js +142 -0
  20. package/dist-package/packages/runtime/src/diff/diff.js +145 -0
  21. package/dist-package/packages/runtime/src/domain/types.js +1 -0
  22. package/dist-package/packages/runtime/src/editing/intent.js +83 -0
  23. package/dist-package/packages/runtime/src/index.js +8 -0
  24. package/dist-package/packages/runtime/src/runtime.js +890 -0
  25. package/dist-package/packages/runtime/src/snapshot-digest.js +24 -0
  26. package/dist-package/packages/runtime/src/speech/filler-removal.js +87 -0
  27. package/dist-package/packages/runtime/src/verification/verification.js +113 -0
  28. package/dist-package/packages/testkit/src/fixture-analyzers.js +39 -0
  29. package/dist-package/packages/testkit/src/in-memory-editor.js +520 -0
  30. package/dist-package/packages/testkit/src/index.js +2 -0
  31. package/package.json +64 -0
@@ -0,0 +1,520 @@
1
+ import { diffSnapshots } from "../../runtime/src/index.js";
2
+ export class InMemoryEditorAdapter {
3
+ snapshot;
4
+ assets;
5
+ history = new Map();
6
+ snapshotsByTarget;
7
+ projects;
8
+ activeProjectId;
9
+ activeSequenceId;
10
+ selectionRevision = 0;
11
+ framesByTarget;
12
+ constructor(fixture) {
13
+ this.assets = structuredClone(fixture.assets ?? []);
14
+ this.projects = structuredClone(fixture.projects ?? [{
15
+ id: fixture.projectId,
16
+ name: fixture.projectName,
17
+ sequences: [{ id: fixture.timelineId, name: fixture.timelineName }],
18
+ }]);
19
+ const projectSnapshots = fixture.projectSnapshots ?? [fixture];
20
+ this.snapshotsByTarget = new Map(projectSnapshots.map((candidate) => [
21
+ snapshotKey(candidate.projectId, candidate.timelineId),
22
+ createSnapshot(candidate),
23
+ ]));
24
+ this.framesByTarget = new Map(projectSnapshots.map((candidate) => [
25
+ snapshotKey(candidate.projectId, candidate.timelineId),
26
+ candidate.frames ? structuredClone(candidate.frames) : undefined,
27
+ ]));
28
+ this.activeProjectId = fixture.projectId;
29
+ this.activeSequenceId = fixture.timelineId;
30
+ const initialSnapshot = this.snapshotsByTarget.get(snapshotKey(fixture.projectId, fixture.timelineId));
31
+ if (!initialSnapshot)
32
+ throw new Error(`PROJECT_NOT_FOUND: ${fixture.projectId}`);
33
+ this.snapshot = structuredClone(initialSnapshot);
34
+ this.history.set(this.snapshot.revision.id, structuredClone(this.snapshot));
35
+ }
36
+ async read() {
37
+ return structuredClone(this.snapshot);
38
+ }
39
+ async readProject() {
40
+ return this.read();
41
+ }
42
+ async getIdentity() {
43
+ return { name: "In-memory Editor", version: "phase-2-fixture", backend: "fixture" };
44
+ }
45
+ async getCapabilities() {
46
+ return {
47
+ editor: {
48
+ projectRead: true,
49
+ timelineSnapshotRead: true,
50
+ timelineWrite: true,
51
+ timelineArtifactWrite: false,
52
+ readAfterWrite: true,
53
+ incrementalChanges: true,
54
+ rollback: true,
55
+ assetDiscovery: true,
56
+ liveStateRead: false,
57
+ playheadWrite: false,
58
+ frameCapture: Boolean(this.activeFrames()),
59
+ projectCatalogRead: true,
60
+ projectSelection: true,
61
+ compositeTransactions: true,
62
+ mediaImport: true,
63
+ mediaPlacement: true,
64
+ titlePlacement: true,
65
+ },
66
+ analyzers: {
67
+ speechTranscribe: false,
68
+ speechVad: false,
69
+ audioLoudness: false,
70
+ visualTrack: false,
71
+ },
72
+ };
73
+ }
74
+ async captureFrame(position, expectedRevision) {
75
+ if (this.snapshot.revision.id !== expectedRevision.id
76
+ || this.snapshot.revision.sequence !== expectedRevision.sequence) {
77
+ throw new Error("STALE_CONTEXT: editor revision changed before frame capture");
78
+ }
79
+ const frames = this.activeFrames();
80
+ if (!frames)
81
+ throw new Error("CAPABILITY_UNAVAILABLE: timeline frame capture");
82
+ const frame = frames.find((candidate) => sameRational(candidate.position, position));
83
+ if (!frame)
84
+ throw new Error(`FRAME_NOT_FOUND: ${position.value}/${position.timescale}`);
85
+ return structuredClone({ image: frame.image, timecode: frame.timecode });
86
+ }
87
+ activeFrames() {
88
+ return this.framesByTarget.get(snapshotKey(this.activeProjectId, this.activeSequenceId));
89
+ }
90
+ async listAssets(query) {
91
+ const normalized = query?.query?.trim().toLowerCase();
92
+ return structuredClone(this.assets.filter((asset) => {
93
+ if (normalized && ![asset.id, asset.name, asset.vendor].some((value) => value.toLowerCase().includes(normalized)))
94
+ return false;
95
+ if (query?.kind && asset.kind !== query.kind)
96
+ return false;
97
+ if (query?.vendor && asset.vendor.toLowerCase() !== query.vendor.trim().toLowerCase())
98
+ return false;
99
+ return true;
100
+ }));
101
+ }
102
+ async listProjects() {
103
+ return {
104
+ projects: structuredClone(this.projects),
105
+ activeProjectId: this.activeProjectId,
106
+ activeSequenceId: this.activeSequenceId,
107
+ };
108
+ }
109
+ async selectProject(selection) {
110
+ const project = this.projects.find((candidate) => candidate.id === selection.projectId);
111
+ if (!project)
112
+ throw new Error(`PROJECT_NOT_FOUND: ${selection.projectId}`);
113
+ const sequenceId = selection.sequenceId
114
+ ?? (project.sequences.length === 1 ? project.sequences[0]?.id : undefined);
115
+ if (!sequenceId)
116
+ throw new Error(`AMBIGUOUS_PROJECT_TARGET: ${selection.projectId} has multiple sequences`);
117
+ if (!project.sequences.some((sequence) => sequence.id === sequenceId)) {
118
+ throw new Error(`SEQUENCE_NOT_FOUND: ${sequenceId}`);
119
+ }
120
+ const target = this.snapshotsByTarget.get(snapshotKey(project.id, sequenceId));
121
+ if (!target) {
122
+ throw new Error(`UNSUPPORTED_PROJECT_SELECTION: no canonical snapshot for ${project.id}`);
123
+ }
124
+ if (target.timeline.id !== sequenceId) {
125
+ throw new Error(`UNSUPPORTED_PROJECT_SELECTION: no canonical snapshot for sequence ${sequenceId}`);
126
+ }
127
+ if (this.activeProjectId === project.id && this.activeSequenceId === sequenceId)
128
+ return this.listProjects();
129
+ this.selectionRevision += 1;
130
+ this.snapshot = {
131
+ ...structuredClone(target),
132
+ revision: {
133
+ id: `rev-select-${this.selectionRevision}`,
134
+ sequence: this.selectionRevision,
135
+ timestamp: new Date(this.selectionRevision).toISOString(),
136
+ },
137
+ };
138
+ this.history.clear();
139
+ this.history.set(this.snapshot.revision.id, structuredClone(this.snapshot));
140
+ this.activeProjectId = project.id;
141
+ this.activeSequenceId = sequenceId;
142
+ return this.listProjects();
143
+ }
144
+ async readChanges(since) {
145
+ const before = this.history.get(since.id);
146
+ if (!before)
147
+ throw new Error(`REVISION_NOT_FOUND: ${since.id}`);
148
+ return {
149
+ from: before.revision,
150
+ to: this.snapshot.revision,
151
+ timeline: diffSnapshots(before, this.snapshot),
152
+ stateChanges: [],
153
+ assetChanges: [],
154
+ };
155
+ }
156
+ async apply(operation, expectedRevision) {
157
+ if (this.snapshot.revision.id !== expectedRevision.id) {
158
+ throw new Error("STALE_CONTEXT: editor revision changed before write");
159
+ }
160
+ this.snapshot = this.nextSnapshot(this.applyOperation(this.snapshot, operation));
161
+ return structuredClone(this.snapshot.revision);
162
+ }
163
+ async previewTransaction(operations, expectedRevision) {
164
+ this.assertRevision(expectedRevision);
165
+ const preview = operations.reduce((snapshot, operation) => this.applyOperation(snapshot, operation), structuredClone(this.snapshot));
166
+ return structuredClone(withRevision(withTimelineDuration(preview), nextRevision(this.snapshot.revision)));
167
+ }
168
+ async applyTransaction(operations, expectedRevision) {
169
+ this.assertRevision(expectedRevision);
170
+ const next = operations.reduce((snapshot, operation) => this.applyOperation(snapshot, operation), structuredClone(this.snapshot));
171
+ this.snapshot = this.nextSnapshot(next);
172
+ }
173
+ async restore(snapshot, expectedRevision) {
174
+ if (this.snapshot.revision.id !== expectedRevision.id) {
175
+ throw new Error("STALE_CONTEXT: editor revision changed before rollback");
176
+ }
177
+ if (snapshot.projectId !== this.activeProjectId || snapshot.timeline.id !== this.activeSequenceId) {
178
+ throw new Error(`TARGET_MISMATCH: cannot restore ${snapshot.projectId}/${snapshot.timeline.id} while ${this.activeProjectId}/${this.activeSequenceId} is active`);
179
+ }
180
+ this.snapshot = withRevision(structuredClone(snapshot), nextRevision(this.snapshot.revision));
181
+ this.history.set(this.snapshot.revision.id, structuredClone(this.snapshot));
182
+ }
183
+ applyOperation(snapshot, operation) {
184
+ if (operation.type === "media.import") {
185
+ if (snapshot.media.some((media) => media.mediaId === operation.mediaId)) {
186
+ throw new Error(`MEDIA_ALREADY_EXISTS: ${operation.mediaId}`);
187
+ }
188
+ if (!operation.source.trim() || !Number.isFinite(operation.duration) || operation.duration <= 0
189
+ || !operation.sourceDigest.trim()) {
190
+ throw new Error("INVALID_OPERATION: imported media requires source, duration, and digest");
191
+ }
192
+ return {
193
+ ...snapshot,
194
+ media: [...snapshot.media, {
195
+ mediaId: operation.mediaId,
196
+ source: operation.source,
197
+ mediaKind: operation.mediaKind,
198
+ duration: operation.duration,
199
+ sourceDigest: operation.sourceDigest,
200
+ }],
201
+ };
202
+ }
203
+ if (operation.type === "timeline.media.add") {
204
+ const media = snapshot.media.find((candidate) => candidate.mediaId === operation.mediaId);
205
+ if (!media)
206
+ throw new Error(`MEDIA_NOT_FOUND: ${operation.mediaId}`);
207
+ if (snapshot.timeline.clips.some((clip) => clip.id === operation.occurrenceId)) {
208
+ throw new Error(`OCCURRENCE_ALREADY_EXISTS: ${operation.occurrenceId}`);
209
+ }
210
+ if (!Number.isFinite(operation.start) || !Number.isFinite(operation.duration)
211
+ || operation.start < 0 || operation.duration <= 0) {
212
+ throw new Error("INVALID_OPERATION: media placement timing");
213
+ }
214
+ const lane = operation.targetLane ?? (operation.role === "video" ? "primary" : undefined);
215
+ if (operation.role === "video" && lane !== "primary") {
216
+ throw new Error("INVALID_OPERATION: video must target the primary storyline");
217
+ }
218
+ if (operation.role === "music" && (typeof lane !== "number" || lane === 0)) {
219
+ throw new Error("INVALID_OPERATION: music requires an explicit non-primary lane");
220
+ }
221
+ const clip = withClipTime({
222
+ id: operation.occurrenceId,
223
+ mediaId: operation.mediaId,
224
+ name: media.source.split("/").pop() || media.mediaId,
225
+ start: operation.start,
226
+ duration: operation.duration,
227
+ track: typeof lane === "number" ? lane : 0,
228
+ });
229
+ return {
230
+ ...snapshot,
231
+ timeline: {
232
+ ...snapshot.timeline,
233
+ clips: [...snapshot.timeline.clips, clip],
234
+ storyElements: [...snapshot.timeline.storyElements, {
235
+ id: clip.id,
236
+ kind: "asset-clip",
237
+ start: clip.start,
238
+ duration: clip.duration,
239
+ startTime: clip.startTime,
240
+ durationTime: clip.durationTime,
241
+ lane: clip.track,
242
+ mediaId: clip.mediaId,
243
+ }],
244
+ },
245
+ };
246
+ }
247
+ if (operation.type === "timeline.audio.fades") {
248
+ const clip = snapshot.timeline.clips.find(({ id }) => id === operation.clipId);
249
+ if (!clip)
250
+ throw new Error(`CLIP_NOT_FOUND: ${operation.clipId}`);
251
+ if (!Number.isFinite(operation.fadeIn) || !Number.isFinite(operation.fadeOut)
252
+ || operation.fadeIn < 0 || operation.fadeOut < 0
253
+ || operation.fadeIn + operation.fadeOut > clip.duration) {
254
+ throw new Error("INVALID_OPERATION: audio fades must be non-negative and fit within the clip duration");
255
+ }
256
+ return {
257
+ ...snapshot,
258
+ timeline: {
259
+ ...snapshot.timeline,
260
+ clips: snapshot.timeline.clips.map((candidate) => candidate.id === operation.clipId
261
+ ? { ...candidate, fadeIn: operation.fadeIn, fadeOut: operation.fadeOut }
262
+ : candidate),
263
+ },
264
+ };
265
+ }
266
+ if (operation.type === "timeline.title.add") {
267
+ const asset = this.assets.find((candidate) => candidate.id === operation.assetId && candidate.kind === "title");
268
+ if (!asset)
269
+ throw new Error(`TITLE_ASSET_NOT_FOUND: ${operation.assetId}`);
270
+ if (snapshot.timeline.clips.some((clip) => clip.id === operation.occurrenceId)) {
271
+ throw new Error(`OCCURRENCE_ALREADY_EXISTS: ${operation.occurrenceId}`);
272
+ }
273
+ if (!operation.text.trim() || !Number.isFinite(operation.start) || !Number.isFinite(operation.duration)
274
+ || operation.start < 0 || operation.duration <= 0 || operation.targetLane === 0) {
275
+ throw new Error("INVALID_OPERATION: title text, timing, and non-primary lane are required");
276
+ }
277
+ const clip = withClipTime({
278
+ id: operation.occurrenceId,
279
+ name: operation.text,
280
+ start: operation.start,
281
+ duration: operation.duration,
282
+ track: operation.targetLane,
283
+ });
284
+ return {
285
+ ...snapshot,
286
+ timeline: {
287
+ ...snapshot.timeline,
288
+ clips: [...snapshot.timeline.clips, clip],
289
+ storyElements: [...snapshot.timeline.storyElements, {
290
+ id: clip.id,
291
+ kind: "title",
292
+ start: clip.start,
293
+ duration: clip.duration,
294
+ startTime: clip.startTime,
295
+ durationTime: clip.durationTime,
296
+ lane: clip.track,
297
+ assetId: operation.assetId,
298
+ text: operation.text,
299
+ }],
300
+ },
301
+ };
302
+ }
303
+ if (operation.type === "ripple-delete") {
304
+ return this.applyRippleDelete(snapshot, operation.timelineId, operation.range.start, operation.range.end);
305
+ }
306
+ if (operation.type === "add-marker") {
307
+ if (operation.timelineId !== snapshot.timeline.id)
308
+ throw new Error(`TIMELINE_NOT_FOUND: ${operation.timelineId}`);
309
+ return {
310
+ ...snapshot,
311
+ timeline: {
312
+ ...snapshot.timeline,
313
+ markers: [...snapshot.timeline.markers, normalizeMarker(operation.marker)],
314
+ },
315
+ };
316
+ }
317
+ const clip = snapshot.timeline.clips.find(({ id }) => id === operation.clipId);
318
+ if (!clip)
319
+ throw new Error(`CLIP_NOT_FOUND: ${operation.clipId}`);
320
+ let updatedClip;
321
+ switch (operation.type) {
322
+ case "rename-clip":
323
+ if (!operation.name.trim())
324
+ throw new Error("INVALID_OPERATION: clip name cannot be empty");
325
+ updatedClip = { ...clip, name: operation.name };
326
+ break;
327
+ case "trim-clip":
328
+ if ((!Number.isFinite(operation.duration) || operation.duration <= 0) && !operation.durationTime) {
329
+ throw new Error("INVALID_OPERATION: clip duration must be positive");
330
+ }
331
+ updatedClip = {
332
+ ...clip,
333
+ duration: operation.durationTime
334
+ ? Number(operation.durationTime.value) / Number(operation.durationTime.timescale)
335
+ : operation.duration,
336
+ durationTime: operation.durationTime ?? decimalToRational(operation.duration),
337
+ };
338
+ break;
339
+ case "set-gain":
340
+ if (!Number.isFinite(operation.gainDb))
341
+ throw new Error("INVALID_OPERATION: gain must be finite");
342
+ updatedClip = { ...clip, gainDb: operation.gainDb };
343
+ break;
344
+ }
345
+ return {
346
+ ...snapshot,
347
+ timeline: {
348
+ ...snapshot.timeline,
349
+ clips: snapshot.timeline.clips.map((candidate) => candidate.id === operation.clipId ? updatedClip : candidate),
350
+ storyElements: snapshot.timeline.storyElements.map((element) => element.id === operation.clipId
351
+ ? { ...element, start: updatedClip.start, duration: updatedClip.duration, durationTime: updatedClip.durationTime }
352
+ : element),
353
+ },
354
+ };
355
+ }
356
+ applyRippleDelete(snapshot, timelineId, start, end) {
357
+ if (timelineId !== snapshot.timeline.id)
358
+ throw new Error(`TIMELINE_NOT_FOUND: ${timelineId}`);
359
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start < 0 || end <= start) {
360
+ throw new Error("INVALID_OPERATION: ripple delete range must be positive");
361
+ }
362
+ const removedDuration = end - start;
363
+ const clips = snapshot.timeline.clips.flatMap((clip) => {
364
+ const clipEnd = clip.start + clip.duration;
365
+ if (clipEnd <= start)
366
+ return [clip];
367
+ if (clip.start >= end)
368
+ return [withClipTime({
369
+ ...clip,
370
+ start: clip.start - removedDuration,
371
+ startTime: undefined,
372
+ durationTime: undefined,
373
+ })];
374
+ const overlap = Math.min(clipEnd, end) - Math.max(clip.start, start);
375
+ const duration = clip.duration - overlap;
376
+ if (duration <= 0)
377
+ return [];
378
+ return [withClipTime({
379
+ ...clip,
380
+ start: clip.start < start ? clip.start : start,
381
+ duration,
382
+ startTime: undefined,
383
+ durationTime: undefined,
384
+ })];
385
+ });
386
+ const markers = snapshot.timeline.markers.flatMap((marker) => {
387
+ if (marker.start >= end)
388
+ return [normalizeMarker({
389
+ ...marker,
390
+ start: marker.start - removedDuration,
391
+ startTime: undefined,
392
+ durationTime: undefined,
393
+ })];
394
+ if (marker.start + marker.duration <= start)
395
+ return [marker];
396
+ return [];
397
+ });
398
+ const captions = snapshot.timeline.captions.flatMap((caption) => {
399
+ if (caption.start + caption.duration <= start)
400
+ return [caption];
401
+ if (caption.start >= end)
402
+ return [normalizeCaption({
403
+ ...caption,
404
+ start: caption.start - removedDuration,
405
+ startTime: undefined,
406
+ durationTime: undefined,
407
+ })];
408
+ return [];
409
+ });
410
+ return {
411
+ ...snapshot,
412
+ timeline: {
413
+ ...snapshot.timeline,
414
+ clips,
415
+ storyElements: snapshot.timeline.storyElements
416
+ .filter((element) => clips.some((clip) => clip.id === element.id))
417
+ .map((element) => {
418
+ const clip = clips.find((candidate) => candidate.id === element.id);
419
+ return clip ? { ...element, start: clip.start, duration: clip.duration, startTime: clip.startTime, durationTime: clip.durationTime } : element;
420
+ }),
421
+ markers,
422
+ captions,
423
+ },
424
+ };
425
+ }
426
+ assertRevision(expectedRevision) {
427
+ if (this.snapshot.revision.id !== expectedRevision.id) {
428
+ throw new Error("STALE_CONTEXT: editor revision changed before write");
429
+ }
430
+ }
431
+ nextSnapshot(snapshot) {
432
+ const next = withRevision(withTimelineDuration(snapshot), nextRevision(snapshot.revision));
433
+ this.history.set(next.revision.id, structuredClone(next));
434
+ return next;
435
+ }
436
+ }
437
+ function sameRational(left, right) {
438
+ return BigInt(left.value) * BigInt(right.timescale) === BigInt(right.value) * BigInt(left.timescale);
439
+ }
440
+ function nextRevision(revision) {
441
+ const sequence = revision.sequence + 1;
442
+ return {
443
+ id: `rev-${sequence}`,
444
+ sequence,
445
+ timestamp: new Date(sequence).toISOString(),
446
+ };
447
+ }
448
+ function withTimelineDuration(snapshot) {
449
+ const duration = snapshot.timeline.clips.reduce((end, clip) => Math.max(end, clip.start + clip.duration), 0);
450
+ return {
451
+ ...snapshot,
452
+ timeline: {
453
+ ...snapshot.timeline,
454
+ duration,
455
+ durationTime: decimalToRational(duration),
456
+ },
457
+ };
458
+ }
459
+ function withRevision(snapshot, revision) {
460
+ return { ...snapshot, revision };
461
+ }
462
+ function createSnapshot(fixture) {
463
+ const clips = fixture.clips.map((clip) => normalizeClip(clip));
464
+ return {
465
+ projectId: fixture.projectId,
466
+ projectName: fixture.projectName,
467
+ timeline: {
468
+ id: fixture.timelineId,
469
+ name: fixture.timelineName,
470
+ duration: clips.reduce((end, clip) => Math.max(end, clip.start + clip.duration), 0),
471
+ durationTime: decimalToRational(clips.reduce((end, clip) => Math.max(end, clip.start + clip.duration), 0)),
472
+ clips,
473
+ storyElements: clips.map((clip) => ({
474
+ id: clip.id,
475
+ kind: "asset-clip",
476
+ start: clip.start,
477
+ duration: clip.duration,
478
+ startTime: clip.startTime,
479
+ durationTime: clip.durationTime,
480
+ lane: clip.track,
481
+ mediaId: clip.mediaId,
482
+ })),
483
+ markers: (fixture.markers ?? []).map((marker) => normalizeMarker(marker)),
484
+ captions: (fixture.captions ?? []).map((caption) => normalizeCaption(caption)),
485
+ },
486
+ media: structuredClone(fixture.media ?? []),
487
+ revision: {
488
+ id: "rev-0",
489
+ sequence: 0,
490
+ timestamp: new Date(0).toISOString(),
491
+ },
492
+ };
493
+ }
494
+ function snapshotKey(projectId, timelineId) {
495
+ return `${projectId}\u0000${timelineId}`;
496
+ }
497
+ function normalizeClip(clip) {
498
+ return withClipTime({ ...clip, startTime: clip.startTime, durationTime: clip.durationTime });
499
+ }
500
+ function withClipTime(clip) {
501
+ return {
502
+ ...clip,
503
+ startTime: clip.startTime ?? decimalToRational(clip.start),
504
+ durationTime: clip.durationTime ?? decimalToRational(clip.duration),
505
+ };
506
+ }
507
+ function normalizeMarker(marker) {
508
+ return { ...marker, startTime: marker.startTime ?? decimalToRational(marker.start), durationTime: marker.durationTime ?? decimalToRational(marker.duration) };
509
+ }
510
+ function normalizeCaption(caption) {
511
+ return { ...caption, startTime: caption.startTime ?? decimalToRational(caption.start), durationTime: caption.durationTime ?? decimalToRational(caption.duration) };
512
+ }
513
+ function decimalToRational(value) {
514
+ const text = value.toFixed(6).replace(/0+$/, "").replace(/\.$/, "");
515
+ if (!text.includes("."))
516
+ return { value: text, timescale: "1" };
517
+ const decimals = text.split(".")[1].length;
518
+ const scale = 10 ** decimals;
519
+ return { value: String(Math.round(value * scale)), timescale: String(scale) };
520
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./in-memory-editor.js";
2
+ export * from "./fixture-analyzers.js";
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@morshoto/framekit",
3
+ "version": "0.1.0",
4
+ "packageManager": "pnpm@11.10.0",
5
+ "private": false,
6
+ "type": "module",
7
+ "description": "Agentic video editing runtime and MCP server for Final Cut Pro",
8
+ "files": [
9
+ "bin",
10
+ "dist-package"
11
+ ],
12
+ "bin": {
13
+ "framekit": "./bin/framekit.mjs"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json",
20
+ "build:package": "tsc -p tsconfig.package.json && tsc-alias -p tsconfig.package.json",
21
+ "test": "tsx --test tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/golden/*.test.ts",
22
+ "test:filler-removal": "tsx --test tests/filler-removal/*.test.ts",
23
+ "benchmark:filler-removal": "tsx scripts/run-filler-removal-benchmark.ts",
24
+ "test:golden": "tsx --test tests/golden/*.test.ts",
25
+ "test:codex-plugin": "node scripts/codex-plugin-smoke.mjs",
26
+ "test:clean-mcp-clients": "node scripts/clean-mcp-client-smoke.mjs",
27
+ "evaluate": "tsx scripts/run-mcp-evaluation.ts",
28
+ "test:final-cut-headless": "tsx --test tests/integration/connection.test.ts tests/integration/finalcut-mcp.test.ts tests/integration/native.test.ts",
29
+ "test:final-cut-overlay-headed": "node scripts/final-cut-overlay-headed-e2e.mjs",
30
+ "test:final-cut-canonical-read-headed": "node scripts/final-cut-canonical-read-headed-e2e.mjs",
31
+ "test:final-cut-canonical-headed": "node scripts/final-cut-canonical-headed-e2e.mjs",
32
+ "test:final-cut-filler-headed": "node scripts/final-cut-filler-removal-headed-e2e.mjs",
33
+ "test:watch": "tsx --test --watch tests/integration/*.test.ts tests/evaluation/*.test.ts tests/filler-removal/*.test.ts tests/golden/*.test.ts",
34
+ "test:final-cut-disposable-headed": "node scripts/final-cut-disposable-native-headed-e2e.mjs",
35
+ "hooks:install": "node scripts/install-git-hooks.mjs",
36
+ "mcp": "tsx apps/mcp-server/src/main.ts",
37
+ "framekit": "node ./bin/framekit.mjs",
38
+ "package:final-cut-release": "bash scripts/package-final-cut-release.sh",
39
+ "prepack": "pnpm run build:package",
40
+ "xcode:check": "bash nix/check-xcode.sh",
41
+ "check:boundaries": "node scripts/check-boundaries.mjs"
42
+ },
43
+ "config": {
44
+ "commitizen": {
45
+ "path": "./node_modules/git-cz"
46
+ }
47
+ },
48
+ "engines": {
49
+ "node": ">=20"
50
+ },
51
+ "dependencies": {
52
+ "@modelcontextprotocol/sdk": "^1.30.0",
53
+ "commitizen": "^4.3.1",
54
+ "fast-xml-parser": "^5.10.1",
55
+ "git-cz": "^4.9.0",
56
+ "zod": "^3.25.76"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^22.15.0",
60
+ "tsc-alias": "^1.8.16",
61
+ "tsx": "^4.19.4",
62
+ "typescript": "^5.8.3"
63
+ }
64
+ }