@morshoto/framekit 0.1.0 → 0.1.5

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 (65) hide show
  1. package/README.md +42 -17
  2. package/dist-package/adapters/final-cut/typescript/src/analyzers.js +86 -2
  3. package/dist-package/adapters/final-cut/typescript/src/connection.js +5 -1
  4. package/dist-package/adapters/final-cut/typescript/src/export.js +231 -8
  5. package/dist-package/adapters/final-cut/typescript/src/fcpxml.js +70 -9
  6. package/dist-package/adapters/final-cut/typescript/src/live.js +2 -2
  7. package/dist-package/adapters/final-cut/typescript/src/native.js +1000 -100
  8. package/dist-package/adapters/final-cut/typescript/src/publisher.js +242 -30
  9. package/dist-package/adapters/final-cut/typescript/src/session.js +86 -9
  10. package/dist-package/apps/mcp-server/src/main.js +10 -1
  11. package/dist-package/apps/mcp-server/src/routing.js +172 -0
  12. package/dist-package/apps/mcp-server/src/server.js +867 -52
  13. package/dist-package/apps/mcp-server/src/version.js +34 -0
  14. package/dist-package/packages/runtime/src/application/duration-policy-service.js +6 -0
  15. package/dist-package/packages/runtime/src/application/media-analysis-service.js +473 -0
  16. package/dist-package/packages/runtime/src/application/project-service.js +146 -0
  17. package/dist-package/packages/runtime/src/application/runtime-options.js +1 -0
  18. package/dist-package/packages/runtime/src/application/transaction-store.js +12 -0
  19. package/dist-package/packages/runtime/src/audio/dialogue-normalization.js +64 -0
  20. package/dist-package/packages/runtime/src/audio/noise-reduction.js +46 -0
  21. package/dist-package/packages/runtime/src/capabilities.js +187 -1
  22. package/dist-package/packages/runtime/src/color-correction.js +48 -0
  23. package/dist-package/packages/runtime/src/context/context-engine.js +20 -6
  24. package/dist-package/packages/runtime/src/context/context-service.js +30 -0
  25. package/dist-package/packages/runtime/src/context/revision.js +3 -0
  26. package/dist-package/packages/runtime/src/domain/capabilities.js +1 -0
  27. package/dist-package/packages/runtime/src/domain/context.js +1 -0
  28. package/dist-package/packages/runtime/src/domain/diff.js +1 -0
  29. package/dist-package/packages/runtime/src/domain/duration.js +1 -0
  30. package/dist-package/packages/runtime/src/domain/editing.js +1 -0
  31. package/dist-package/packages/runtime/src/domain/index.js +12 -0
  32. package/dist-package/packages/runtime/src/domain/media.js +8 -0
  33. package/dist-package/packages/runtime/src/domain/ports.js +1 -0
  34. package/dist-package/packages/runtime/src/domain/primitives.js +1 -0
  35. package/dist-package/packages/runtime/src/domain/project.js +1 -0
  36. package/dist-package/packages/runtime/src/domain/rough-cut.js +69 -0
  37. package/dist-package/packages/runtime/src/domain/skills.js +33 -0
  38. package/dist-package/packages/runtime/src/domain/types.js +5 -1
  39. package/dist-package/packages/runtime/src/domain/verification.js +1 -0
  40. package/dist-package/packages/runtime/src/editing/dialogue-normalization-service.js +141 -0
  41. package/dist-package/packages/runtime/src/editing/duration-policy.js +187 -0
  42. package/dist-package/packages/runtime/src/editing/edit-service.js +449 -0
  43. package/dist-package/packages/runtime/src/editing/filler-removal-service.js +361 -0
  44. package/dist-package/packages/runtime/src/editing/music-service.js +85 -0
  45. package/dist-package/packages/runtime/src/index.js +14 -3
  46. package/dist-package/packages/runtime/src/planning/rough-cut.js +71 -0
  47. package/dist-package/packages/runtime/src/runtime.js +131 -826
  48. package/dist-package/packages/runtime/src/skills/builtin.js +339 -0
  49. package/dist-package/packages/runtime/src/skills/index.js +3 -0
  50. package/dist-package/packages/runtime/src/skills/registry.js +74 -0
  51. package/dist-package/packages/runtime/src/skills/requirements.js +170 -0
  52. package/dist-package/packages/runtime/src/skills/runtime.js +239 -0
  53. package/dist-package/packages/runtime/src/speech/analysis.js +301 -0
  54. package/dist-package/packages/runtime/src/speech/filler-detector.js +132 -0
  55. package/dist-package/packages/runtime/src/speech/mapping.js +227 -0
  56. package/dist-package/packages/runtime/src/speech/safe-cut-resolver.js +314 -0
  57. package/dist-package/packages/runtime/src/timeline/rational-time.js +63 -0
  58. package/dist-package/packages/runtime/src/verification/verification.js +712 -1
  59. package/dist-package/packages/testkit/src/fixture-analyzers.js +28 -0
  60. package/dist-package/packages/testkit/src/in-memory-editor.js +287 -3
  61. package/dist-package/packages/testkit/src/index.js +1 -0
  62. package/dist-package/packages/testkit/src/skill-fixtures.js +64 -0
  63. package/package.json +17 -8
  64. /package/dist-package/packages/runtime/src/{diff/diff.js → timeline/snapshot-diff.js} +0 -0
  65. /package/dist-package/packages/runtime/src/{snapshot-digest.js → timeline/snapshot-digest.js} +0 -0
@@ -3,6 +3,7 @@ import { readFile, writeFile } from "node:fs/promises";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { dirname, isAbsolute, resolve } from "node:path";
5
5
  import { XMLBuilder, XMLParser } from "fast-xml-parser";
6
+ import { withCapabilityFamilies } from "../../../../packages/runtime/src/index.js";
6
7
  const CLIP_KINDS = new Set(["asset-clip", "clip", "ref-clip", "sync-clip", "mc-clip", "audio", "video"]);
7
8
  const TIMELINE_KINDS = new Set([
8
9
  ...CLIP_KINDS,
@@ -42,8 +43,14 @@ export class FcpxmlDocumentAdapter {
42
43
  async getIdentity() {
43
44
  return { name: "Final Cut Pro", version: "FCPXML", backend: "fcpxml-document" };
44
45
  }
46
+ async getManagedArtifact() {
47
+ return { id: `fcpxml:${this.filePath}`, path: this.filePath, format: "fcpxml" };
48
+ }
49
+ async getManagedArtifactDigest() {
50
+ return hash(await readFile(this.filePath, "utf8"));
51
+ }
45
52
  async getCapabilities() {
46
- return {
53
+ return withCapabilityFamilies({
47
54
  editor: {
48
55
  projectRead: true,
49
56
  timelineSnapshotRead: true,
@@ -58,9 +65,11 @@ export class FcpxmlDocumentAdapter {
58
65
  frameCapture: false,
59
66
  projectCatalogRead: true,
60
67
  projectSelection: true,
68
+ compositeTransactions: true,
69
+ semanticOperations: { "add-marker": true },
61
70
  },
62
71
  analyzers: emptyAnalyzerCapabilities(),
63
- };
72
+ }, { backend: "fcpxml-document" });
64
73
  }
65
74
  async listAssets() {
66
75
  return [];
@@ -142,6 +151,51 @@ export class FcpxmlDocumentAdapter {
142
151
  throw new Error("STALE_CONTEXT: FCPXML document changed before write");
143
152
  }
144
153
  this.history.set(expectedRevision.id, structuredClone(this.xml));
154
+ this.applyOperation(operation);
155
+ this.sequence += 1;
156
+ await this.persist();
157
+ return this.revision();
158
+ }
159
+ async previewTransaction(operations, expectedRevision) {
160
+ await this.ensureLoaded();
161
+ if (!sameRevision(expectedRevision, this.revision())) {
162
+ throw new Error("STALE_CONTEXT: FCPXML document changed before preview");
163
+ }
164
+ const originalXml = structuredClone(this.xml);
165
+ const originalSequence = this.sequence;
166
+ const originalSignature = this.fileSignature;
167
+ try {
168
+ for (const operation of operations) {
169
+ if (operation.type === "media.import" || operation.type.startsWith("timeline.")) {
170
+ throw new Error(`CAPABILITY_UNAVAILABLE: FCPXML preview does not support ${operation.type}`);
171
+ }
172
+ this.applyOperation(operation);
173
+ }
174
+ const preview = await this.readProject();
175
+ return preview;
176
+ }
177
+ finally {
178
+ this.xml = originalXml;
179
+ this.sequence = originalSequence;
180
+ this.fileSignature = originalSignature;
181
+ }
182
+ }
183
+ async applyTransaction(operations, expectedRevision) {
184
+ await this.ensureLoaded();
185
+ if (!sameRevision(expectedRevision, this.revision())) {
186
+ throw new Error("STALE_CONTEXT: FCPXML document changed before transaction");
187
+ }
188
+ this.history.set(expectedRevision.id, structuredClone(this.xml));
189
+ for (const operation of operations) {
190
+ if (operation.type === "media.import" || operation.type.startsWith("timeline.")) {
191
+ throw new Error(`CAPABILITY_UNAVAILABLE: FCPXML transaction does not support ${operation.type}`);
192
+ }
193
+ this.applyOperation(operation);
194
+ }
195
+ this.sequence += 1;
196
+ await this.persist();
197
+ }
198
+ applyOperation(operation) {
145
199
  const project = this.projectNode();
146
200
  const sequenceNode = findElement(project, "sequence");
147
201
  const sequence = sequenceNode ?? {};
@@ -194,9 +248,6 @@ export class FcpxmlDocumentAdapter {
194
248
  }
195
249
  }
196
250
  this.updateSequenceDuration(sequence, spine);
197
- this.sequence += 1;
198
- await this.persist();
199
- return this.revision();
200
251
  }
201
252
  async restore(snapshot, expectedRevision) {
202
253
  await this.ensureLoaded();
@@ -244,12 +295,18 @@ export class FcpxmlDocumentAdapter {
244
295
  clipFromXml(entry, timelineId) {
245
296
  const { node, kind, path, startTime, durationTime } = entry;
246
297
  const gain = firstChild(node, "adjust-volume");
298
+ const sourceStartValue = attribute(node, "start");
299
+ const sourceStartTime = sourceStartValue === undefined ? undefined : parseRational(sourceStartValue);
300
+ const sourceStart = sourceStartTime === undefined ? undefined : rationalSeconds(sourceStartTime);
301
+ if (sourceStart !== undefined && sourceStart < 0)
302
+ throw new Error("FCPXML_INVALID_TIME: source clip start cannot be negative");
247
303
  return {
248
304
  id: this.instanceId(node, kind, path, timelineId),
249
305
  mediaId: attribute(node, "ref") === undefined ? undefined : String(attribute(node, "ref")),
250
306
  name: String(attribute(node, "name") ?? attribute(node, "ref") ?? `Clip ${path.includes(".") ? path : path + 1}`),
251
307
  start: rationalSeconds(startTime),
252
308
  duration: rationalSeconds(durationTime),
309
+ ...(sourceStart !== undefined ? { sourceStart, sourceStartTime } : {}),
253
310
  track: Number(attribute(node, "lane") ?? 0),
254
311
  startTime,
255
312
  durationTime,
@@ -312,10 +369,14 @@ export class FcpxmlDocumentAdapter {
312
369
  const resources = findElement(this.xml ?? [], "resources");
313
370
  return storyEntries(resources ?? {})
314
371
  .filter(({ kind }) => kind === "asset" || kind === "media" || kind === "effect")
315
- .map(({ node }) => ({
316
- mediaId: String(attribute(node, "id") ?? ""),
317
- source: resolveMediaSource(String(attribute(node, "src") ?? attribute(node, "name") ?? attribute(node, "id") ?? ""), this.filePath),
318
- }))
372
+ .map(({ node }) => {
373
+ const durationValue = attribute(node, "duration");
374
+ return {
375
+ mediaId: String(attribute(node, "id") ?? ""),
376
+ source: resolveMediaSource(String(attribute(node, "src") ?? attribute(node, "name") ?? attribute(node, "id") ?? ""), this.filePath),
377
+ ...(durationValue !== undefined ? { duration: parseSeconds(durationValue) } : {}),
378
+ };
379
+ })
319
380
  .filter((media) => media.mediaId.length > 0);
320
381
  }
321
382
  revision() {
@@ -2,7 +2,7 @@ import { createConnection } from "node:net";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { homedir } from "node:os";
4
4
  import { join } from "node:path";
5
- import { withCanonicalTimelineMode } from "../../../../packages/runtime/src/index.js";
5
+ import { withCapabilityFamilies } from "../../../../packages/runtime/src/index.js";
6
6
  export const FINAL_CUT_LIVE_PROTOCOL_VERSION = 1;
7
7
  /** Shared deterministic endpoint used by both the Node client and Swift host. */
8
8
  export const DEFAULT_FINAL_CUT_LIVE_SOCKET = join(homedir(), "Library/Containers/com.framekit.finalcut.workflow.extension/Data/framekit.sock");
@@ -77,7 +77,7 @@ export class FinalCutLiveAdapter {
77
77
  }
78
78
  async getCapabilities() {
79
79
  const response = await this.request({ method: "capabilities" });
80
- return withCanonicalTimelineMode(response.capabilities);
80
+ return withCapabilityFamilies(response.capabilities, { backend: response.identity.backend });
81
81
  }
82
82
  async read() {
83
83
  return this.readProject();