@lalalic/markcut 3.2.60 → 3.2.61

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 (52) hide show
  1. package/README.md +20 -4
  2. package/bin/markcut +10 -0
  3. package/docs/developer-reference.md +41 -1
  4. package/package.json +8 -2
  5. package/recipes/markcut/map-cinematic-follow.json +17 -0
  6. package/recipes/markcut/map-location-reveal.json +17 -0
  7. package/recipes/markcut/map-route-journey.json +18 -0
  8. package/recipes/markcut/map-streetview-explore.json +17 -0
  9. package/skills/markcut/SKILL.md +5 -1
  10. package/skills/markcut/docs/markdown-descriptive.md +68 -1
  11. package/skills/markcut/docs/recipes.md +45 -0
  12. package/skills/markcut/references/mobile-event-preview-cli.md +9 -5
  13. package/src/descriptive/compiler.ts +38 -2
  14. package/src/descriptive/markdown.ts +30 -0
  15. package/src/descriptive/model3d.test.ts +38 -0
  16. package/src/editor-decision/cli.mjs +21 -0
  17. package/src/editor-decision/editor-decision.schema.json +41 -0
  18. package/src/editor-decision/index.mjs +115 -0
  19. package/src/editor-decision/index.test.mjs +63 -0
  20. package/src/mcp/bridge.mjs +46 -9
  21. package/src/mcp/compile-worker.mjs +2 -2
  22. package/src/mcp/mobile-review-cli.mjs +40 -33
  23. package/src/mcp/preview-mobile.css +21 -8
  24. package/src/mcp/preview.mjs +95 -57
  25. package/src/mcp/remote-assets.mjs +85 -7
  26. package/src/mcp/remotion-app.bundle.js +5013 -1117
  27. package/src/mcp/remotion-app.tsx +117 -10
  28. package/src/mcp/server.mjs +4 -2
  29. package/src/player/browser.tsx +1 -3
  30. package/src/player/bundle/player.js +73054 -17357
  31. package/src/player/components/HeaderBar.tsx +3 -1
  32. package/src/player/components/VariantBar.tsx +20 -21
  33. package/src/player/pipeline.mjs +133 -77
  34. package/src/player/server.mjs +43 -23
  35. package/src/recipes/catalog.mjs +115 -0
  36. package/src/recipes/cli.mjs +87 -0
  37. package/src/render/cli.mjs +38 -1
  38. package/src/schema/index.ts +21 -0
  39. package/src/types/Folder.tsx +2 -0
  40. package/src/types/Model3D.tsx +91 -0
  41. package/src/vision/cli.mjs +63 -50
  42. package/tests/mcp-editor-decisions-mobile.test.ts +35 -0
  43. package/tests/mcp-preview-bridge.test.ts +44 -3
  44. package/tests/mcp-preview-proxy-version.test.mjs +80 -0
  45. package/tests/mcp-preview.test.ts +41 -8
  46. package/tests/mcp-remote-assets.test.ts +17 -0
  47. package/tests/mcp-static-preview.test.ts +1 -1
  48. package/tests/mcp-video-selector.test.ts +55 -0
  49. package/tests/mobile-preview-cli.test.ts +10 -15
  50. package/tests/recipes-catalog.test.ts +141 -0
  51. package/tests/vision-generic-vtt-hooks.test.ts +7 -7
  52. package/tests/vision-normalized-metadata.test.ts +23 -0
@@ -0,0 +1,38 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { parseMarkdownDescriptive } from "./markdown";
3
+ import { compileDescriptiveRoot } from "./compiler";
4
+ import { root as rootSchema } from "../schema/index";
5
+ import { model3dAngle } from "../types/Model3D";
6
+
7
+ const doc = `# video
8
+ width:640 height:640 fps:30 layout:series
9
+ ## Toy
10
+ - model3d src:assets/toy.glb duration:6 motion:turntable turns:1 rotation:[0,30,0] camera:{"position":[0,1,5],"fov":34} background:#eeeeee`;
11
+
12
+ describe("model3d native stream", () => {
13
+ it("parses Markdown through compiler and strict Zod stream schema", () => {
14
+ const descriptive = parseMarkdownDescriptive(doc);
15
+ const input = (descriptive.children[0] as any).children[0];
16
+ expect(input).toMatchObject({ type: "model3d", src: "assets/toy.glb", motion: "turntable", duration: 6, rotation: [0, 30, 0] });
17
+ const compiled = compileDescriptiveRoot(descriptive);
18
+ const parsed = rootSchema.parse(compiled);
19
+ const model = (parsed.children[0] as any).children[0];
20
+ expect(model).toMatchObject({ type: "model3d", src: "assets/toy.glb", motion: "turntable", turns: 1, durationInSeconds: 6, camera: { position: [0, 1, 5], fov: 34 } });
21
+ });
22
+
23
+ it("works with defaults and rejects USDZ, broken vectors and unknown motion", () => {
24
+ const parsed = rootSchema.parse(compileDescriptiveRoot(parseMarkdownDescriptive('# video\n## Static\n- model3d src:toy.glb')));
25
+ const model = (parsed.children[0] as any).children[0];
26
+ expect(model).toMatchObject({ motion: "none", turns: 1, autoFit: true, rotation: [0, 0, 0], durationInSeconds: 4 });
27
+ expect(() => rootSchema.parse(compileDescriptiveRoot(parseMarkdownDescriptive('# video\n- model3d src:toy.usdz duration:2')))).toThrow(/glb|gltf/i);
28
+ expect(() => rootSchema.parse(compileDescriptiveRoot(parseMarkdownDescriptive('# video\n- model3d src:toy.glb rotation:[0,20]')))).toThrow();
29
+ expect(() => rootSchema.parse(compileDescriptiveRoot(parseMarkdownDescriptive('# video\n- model3d src:toy.glb motion:fly')))).toThrow();
30
+ });
31
+
32
+ it("never accumulates rotation between seeks", () => {
33
+ expect(model3dAngle(0, 121, 1)).toBe(0);
34
+ expect(model3dAngle(60, 121, 1)).toBeCloseTo(Math.PI);
35
+ expect(model3dAngle(120, 121, 1)).toBeCloseTo(Math.PI * 2);
36
+ expect(model3dAngle(60, 121, 1)).toBeCloseTo(Math.PI);
37
+ });
38
+ });
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import {readFileSync,writeFileSync} from 'node:fs';
3
+ import {resolve,dirname,basename,join} from 'node:path';
4
+ import {loadEditorDecision,editorDecisionToMarkdown} from './index.mjs';
5
+ const [command,videoArg,...rest]=process.argv.slice(2);
6
+ if(command!=='edl'||!videoArg||!videoArg.endsWith('.md')){
7
+ console.error('Usage: markcut edl <video.md> [--output <video.edl.md>]');
8
+ process.exit(2);
9
+ }
10
+ const pos=rest.indexOf('--output');
11
+ if(pos>=0&&(!rest[pos+1]||rest.length!==2))throw Error('--output requires a file');
12
+ if(pos<0&&rest.length)throw Error('Unknown editor decision options: '+rest.join(' '));
13
+ const video=resolve(videoArg);
14
+ const source=readFileSync(video,'utf8');
15
+ const sidecar=loadEditorDecision(video,source);
16
+ if(!sidecar)throw Error('No Editor Decision sidecar found for '+videoArg);
17
+ const rendered=editorDecisionToMarkdown(video,sidecar.edl,source);
18
+ const output=pos>=0?resolve(rest[pos+1]):join(dirname(video),basename(video,'.md')+'.edl.md');
19
+ if(output===video||output===sidecar.path)throw Error('Editor Decision output must not overwrite source files');
20
+ writeFileSync(output,rendered,'utf8');
21
+ console.log(output);
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Markcut Editor Decision List v1",
4
+ "description": "Optional editable source-linked decisions accompanying an executable Markcut video.md.",
5
+ "type": "object",
6
+ "required": ["schema_version", "edits"],
7
+ "properties": {
8
+ "schema_version": {"const": 1},
9
+ "editorial_intent": {"type": "string"},
10
+ "personal_story_id": {"type": "string"},
11
+ "edits": {
12
+ "type": "array", "minItems": 1,
13
+ "items": {
14
+ "type": "object",
15
+ "required": ["shot_id", "in_seconds", "out_seconds"],
16
+ "anyOf": [{"required": ["source_id"]}, {"required": ["source_src"]}],
17
+ "properties": {
18
+ "shot_id": {"type": "string", "minLength": 1},
19
+ "sceneId": {"type": "string"},
20
+ "source_id": {"type": "string", "minLength": 1},
21
+ "source_src": {"type": "string", "minLength": 1},
22
+ "in_seconds": {"type": "number", "minimum": 0},
23
+ "out_seconds": {"type": "number", "exclusiveMinimum": 0},
24
+ "playbackSpeed": {"type": "number", "exclusiveMinimum": 0},
25
+ "timelineDuration": {"type": "number", "exclusiveMinimum": 0},
26
+ "shot_purpose": {"type": "string"},
27
+ "editor_reason": {"type": "string"},
28
+ "cut_reason": {"type": "string"},
29
+ "visual_relationship": {"type": "string"},
30
+ "sound_decision": {"type": "string"},
31
+ "revision_note": {"type": "string"},
32
+ "beat": {"type": "string"},
33
+ "story_beat_id": {"type": "string"},
34
+ "transition": {"type": "string"}
35
+ },
36
+ "additionalProperties": true
37
+ }
38
+ }
39
+ },
40
+ "additionalProperties": true
41
+ }
@@ -0,0 +1,115 @@
1
+ /** Markcut built-in Editor Decision sidecar and its playable video converter.
2
+ * The executable Markdown remains authoritative for the finished film.
3
+ */
4
+ import {readFileSync, existsSync, readdirSync, realpathSync} from 'node:fs';
5
+ import {resolve, dirname, basename, extname, relative, isAbsolute, sep, join} from 'node:path';
6
+ import * as yaml from 'js-yaml';
7
+
8
+ const videoExts=new Set(['.mp4','.mov','.m4v','.webm','.mkv','.avi']);
9
+ const imageExts=new Set(['.png','.jpg','.jpeg','.webp','.gif','.bmp']);
10
+ const nonEmpty=x=>typeof x==='string'&&x.trim().length>0;
11
+ const finite=x=>typeof x==='number'&&Number.isFinite(x);
12
+ const inside=(base,path)=>{const rel=relative(base,path);return !!rel&&rel!=='..'&&!rel.startsWith('..'+sep)&&!isAbsolute(rel);};
13
+ const frontRe=/^\uFEFF?---\s*\r?\n([\s\S]*?)\r?\n---(?:\s*\r?\n|\s*$)/;
14
+
15
+ export function frontmatterEdl(markdown){
16
+ const found=frontRe.exec(markdown);
17
+ if(!found)return undefined;
18
+ const obj=yaml.load(found[1]);
19
+ if(obj==null)return undefined;
20
+ if(typeof obj!=='object'||Array.isArray(obj))throw Error('Markcut frontmatter must be a YAML mapping');
21
+ if(!Object.hasOwn(obj,'edl'))return undefined;
22
+ if(!nonEmpty(obj.edl))throw Error('Frontmatter edl must name a relative .json file');
23
+ return obj.edl.trim();
24
+ }
25
+
26
+ /** Explicit frontmatter path wins; otherwise discover the existing <name>.edl.json sidecar. */
27
+ export function resolveEditorDecisionPath(videoPath,markdown=readFileSync(videoPath,'utf8')){
28
+ const declared=frontmatterEdl(markdown);
29
+ const name=declared??basename(videoPath,'.md')+'.edl.json';
30
+ if(extname(name).toLowerCase()!=='.json'||isAbsolute(name)||name.includes('\\')||/^[a-z][a-z\d+.-]*:/i.test(name))throw Error('EDL must be a local relative JSON path');
31
+ const base=dirname(resolve(videoPath)),full=resolve(base,name);
32
+ if(!inside(base,full))throw Error('EDL reference escapes the video directory');
33
+ if(!existsSync(full)){
34
+ if(declared)throw Error('Declared EDL not found: '+name);
35
+ return null;
36
+ }
37
+ if(!inside(realpathSync(base),realpathSync(full)))throw Error('EDL symlink escapes the video directory');
38
+ return full;
39
+ }
40
+
41
+ export function validateEditorDecision(edl){
42
+ if(!edl||typeof edl!=='object'||Array.isArray(edl)||edl.schema_version!==1||!Array.isArray(edl.edits)||!edl.edits.length)
43
+ throw Error('Editor Decision v1 requires schema_version:1 and nonempty edits[]');
44
+ if(edl.edits.length>500)throw Error('EDL exceeds 500 shots');
45
+ const ids=new Set();
46
+ for(const [i,e] of edl.edits.entries()){
47
+ if(!e||typeof e!=='object'||!nonEmpty(e.shot_id)||ids.has(e.shot_id))throw Error('EDL edits['+i+'] requires unique shot_id');
48
+ ids.add(e.shot_id);
49
+ if(!nonEmpty(e.source_src)&&!nonEmpty(e.source_id))throw Error('EDL edits['+i+'] requires source_src or source_id');
50
+ if(!finite(e.in_seconds)||e.in_seconds<0||!finite(e.out_seconds)||e.out_seconds<=e.in_seconds)throw Error('EDL edits['+i+'] has invalid in/out seconds');
51
+ if(e.playbackSpeed!=null&&(!finite(e.playbackSpeed)||e.playbackSpeed<=0))throw Error('EDL edits['+i+'] has invalid playbackSpeed');
52
+ if(e.timelineDuration!=null&&(!finite(e.timelineDuration)||e.timelineDuration<=0))throw Error('EDL edits['+i+'] has invalid timelineDuration');
53
+ }
54
+ return edl;
55
+ }
56
+
57
+ export function loadEditorDecision(videoPath,markdown=readFileSync(videoPath,'utf8')){
58
+ const path=resolveEditorDecisionPath(videoPath,markdown);
59
+ if(!path)return null;
60
+ let edl;
61
+ try{edl=JSON.parse(readFileSync(path,'utf8'));}catch(e){throw Error('Invalid EDL JSON '+basename(path)+': '+e.message);}
62
+ validateEditorDecision(edl);
63
+ return {path,edl};
64
+ }
65
+ function confinedMediaSrc(videoPath,src){
66
+ const base=dirname(resolve(videoPath));
67
+ if(!nonEmpty(src)||isAbsolute(src)||src.includes('\\')||/^[a-z][a-z\d+.-]*:/i.test(src))throw Error('EDL media must be local relative path: '+src);
68
+ const full=resolve(base,src);
69
+ if(!inside(base,full)||!existsSync(full)||!inside(realpathSync(base),realpathSync(full)))throw Error('EDL media is missing or outside video directory: '+src);
70
+ const rel=relative(base,full).split(sep).join('/');
71
+ if(/[\s"\r\n]/.test(rel))throw Error('EDL media path must not contain whitespace or quotes: '+rel);
72
+ return rel;
73
+ }
74
+ function mediaSrc(videoPath,edit){
75
+ if(nonEmpty(edit.source_src))return confinedMediaSrc(videoPath,edit.source_src);
76
+ const id=edit.source_id;
77
+ if(/[/\\]/.test(id))return confinedMediaSrc(videoPath,id);
78
+ if(extname(id)){
79
+ if(existsSync(resolve(dirname(videoPath),id)))return confinedMediaSrc(videoPath,id);
80
+ return confinedMediaSrc(videoPath,'input/media/'+id);
81
+ }
82
+ const dir=join(dirname(resolve(videoPath)),'input','media');
83
+ const candidates=existsSync(dir)?readdirSync(dir).filter(name=>basename(name,extname(name))===id&&(videoExts.has(extname(name).toLowerCase())||imageExts.has(extname(name).toLowerCase()))):[];
84
+ if(candidates.length!==1)throw Error('EDL source_id '+JSON.stringify(id)+' does not uniquely resolve; specify source_src');
85
+ return confinedMediaSrc(videoPath,'input/media/'+candidates[0]);
86
+ }
87
+ const html=s=>String(s??'').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;').replace(/[\r\n]+/g,' ');
88
+ const short=(s,n=140)=>{const text=String(s??'').trim();return text.length>n?text.slice(0,n-1)+'…':text;};
89
+ function overlay(edit,index,src){
90
+ const fields=[edit.shot_purpose||edit.beat||edit.story_beat_id,edit.editor_reason||edit.cut_reason,edit.visual_relationship,edit.sound_decision||edit.audioIntent,edit.revision_note].filter(nonEmpty).map(s=>short(s));
91
+ const lines=['SOURCE: '+src+' ['+edit.in_seconds.toFixed(2)+'–'+edit.out_seconds.toFixed(2)+'s]',...fields].slice(0,5);
92
+ const body=lines.map((line,i)=>'<div style={{fontSize:'+(i===0?18:24)+',opacity:'+(i===0?0.7:1)+",marginTop:10,overflowWrap:'anywhere'}}>"+html(line)+'</div>').join('');
93
+ return "<div style={{boxSizing:'border-box',width:'100%',height:'100%',display:'flex',flexDirection:'column',justifyContent:'flex-end',padding:'5%',color:'white',fontFamily:'Arial,sans-serif',background:'linear-gradient(0deg,rgba(0,0,0,.94),rgba(0,0,0,.6) 45%,transparent 90%)'}}><div style={{fontSize:33,fontWeight:700}}>SHOT "+(index+1)+' · '+html(edit.shot_id)+'</div>'+body+'</div>';
94
+ }
95
+ export function editorDecisionToMarkdown(videoPath,edl,markdown=readFileSync(videoPath,'utf8')){
96
+ validateEditorDecision(edl);
97
+ const width=Number(/\bwidth:(\d+)/.exec(markdown)?.[1]||1080),height=Number(/\bheight:(\d+)/.exec(markdown)?.[1]||1920);
98
+ const fps=Number(/\bfps:(\d+)/.exec(markdown)?.[1]||30);
99
+ const out=['# video','width:'+width+' height:'+height+' fps:'+fps+' layout:series'];
100
+ if(nonEmpty(edl.editorial_intent)){
101
+ const jsx="<div style={{boxSizing:'border-box',width:'100%',height:'100%',background:'#111827',color:'white',display:'flex',alignItems:'center',justifyContent:'center',padding:'10%',fontSize:46,textAlign:'center'}}>"+html(short(edl.editorial_intent,320))+'</div>';
102
+ out.push('','## EditorialIntent','layout:parallel','- component duration:3 jsx:'+JSON.stringify(jsx));
103
+ }
104
+ for(const [i,e] of edl.edits.entries()){
105
+ const src=mediaSrc(videoPath,e),ext=extname(src).toLowerCase(),speed=e.playbackSpeed||1;
106
+ const duration=e.timelineDuration||(e.out_seconds-e.in_seconds)/speed;
107
+ if(!finite(duration)||duration<=0)throw Error('EDL shot '+e.shot_id+' has invalid duration');
108
+ out.push('','## Shot'+(i+1),'layout:parallel');
109
+ if(imageExts.has(ext))out.push('- image src:'+src+' duration:'+duration.toFixed(4)+' fit:cover');
110
+ else if(videoExts.has(ext))out.push('- video src:'+src+' startFrom:'+e.in_seconds+' endAt:'+e.out_seconds+' duration:'+duration.toFixed(4)+' playbackRate:'+speed+' volume:1 fit:cover');
111
+ else throw Error('Unsupported EDL media format: '+src);
112
+ out.push('- component duration:'+duration.toFixed(4)+' jsx:'+JSON.stringify(overlay(e,i,src)));
113
+ }
114
+ return out.join('\n')+'\n';
115
+ }
@@ -0,0 +1,63 @@
1
+ import {test} from 'vitest';
2
+ import assert from 'node:assert/strict';
3
+ import {mkdtempSync,mkdirSync,writeFileSync,rmSync,readFileSync} from 'node:fs';
4
+ import {tmpdir} from 'node:os';
5
+ import {join} from 'node:path';
6
+ import {frontmatterEdl,loadEditorDecision,resolveEditorDecisionPath,validateEditorDecision,editorDecisionToMarkdown} from './index.mjs';
7
+
8
+ const BASE='# video\nwidth:320 height:568 fps:24 layout:series\n## Main\n- video src:input/media/001.mp4 startFrom:0 endAt:1 duration:1\n';
9
+ const EDL={schema_version:1,editorial_intent:'An honest visual observation',edits:[
10
+ {shot_id:'wide',source_src:'input/media/001.mp4',in_seconds:0,out_seconds:1,shot_purpose:'Set geography',editor_reason:'Hold the wide frame long enough to orient viewers.'},
11
+ {shot_id:'reaction',source_id:'001',in_seconds:1,out_seconds:2,editor_reason:'Cut on the response, not on an arbitrary transition.',visual_relationship:'wide to close',sound_decision:'retain source sound'}
12
+ ]};
13
+ function setup(){
14
+ const folder=mkdtempSync(join(tmpdir(),'markcut-editor-decision-'));
15
+ mkdirSync(join(folder,'input','media'),{recursive:true});
16
+ writeFileSync(join(folder,'input','media','001.mp4'),'fixture');
17
+ const video=join(folder,'video.md');
18
+ writeFileSync(video,'---\nedl: ./video.edl.json\n---\n'+BASE);
19
+ writeFileSync(join(folder,'video.edl.json'),JSON.stringify(EDL));
20
+ return {folder,video,cleanup:()=>rmSync(folder,{recursive:true,force:true})};
21
+ }
22
+
23
+ test('frontmatter declares sidecar, same-basename sidecar is automatically discovered',()=>{
24
+ const f=setup();
25
+ try {
26
+ assert.equal(frontmatterEdl(readFileSync(f.video,'utf8')),'./video.edl.json');
27
+ assert.equal(loadEditorDecision(f.video)?.edl.edits.length,2);
28
+ writeFileSync(f.video,BASE);
29
+ assert.equal(resolveEditorDecisionPath(f.video),join(f.folder,'video.edl.json'));
30
+ rmSync(join(f.folder,'video.edl.json'));
31
+ assert.equal(loadEditorDecision(f.video),null);
32
+ } finally {f.cleanup();}
33
+ });
34
+
35
+ test('converts decisions into playable Markcut Markdown with original source and visible shot reasoning',()=>{
36
+ const f=setup();
37
+ try{
38
+ const md=editorDecisionToMarkdown(f.video,EDL);
39
+ assert.match(md,/# video\nwidth:320 height:568 fps:24 layout:series/);
40
+ assert.match(md,/## EditorialIntent/);
41
+ assert.match(md,/## Shot1/);
42
+ assert.match(md,/## Shot2/);
43
+ assert.match(md,/startFrom:1 endAt:2 duration:1.0000/);
44
+ assert.match(md,/Set geography/);
45
+ assert.match(md,/retain source sound/);
46
+ assert.match(md,/- component duration:1.0000 jsx:/);
47
+ assert.equal((md.match(/- video src:/g)||[]).length,2);
48
+ assert.doesNotMatch(md,/src:https?:/);
49
+ }finally{f.cleanup();}
50
+ });
51
+
52
+ test('refuses malformed timing, duplicate shots and path traversal rather than rendering invented footage',()=>{
53
+ const f=setup();
54
+ try{
55
+ assert.throws(()=>validateEditorDecision({...EDL,edits:[{...EDL.edits[0],out_seconds:0}]}),/invalid in\/out/);
56
+ assert.throws(()=>validateEditorDecision({...EDL,edits:[EDL.edits[0],{...EDL.edits[0]}]}),/unique shot_id/);
57
+ assert.throws(()=>editorDecisionToMarkdown(f.video,{...EDL,edits:[{...EDL.edits[0],source_src:'../../outside.mp4'}]}),/missing or outside/);
58
+ writeFileSync(f.video,'---\nedl: ../outside.json\n---\n'+BASE);
59
+ assert.throws(()=>loadEditorDecision(f.video),/escapes the video directory/);
60
+ writeFileSync(f.video,'---\nedl: ./missing.json\n---\n'+BASE);
61
+ assert.throws(()=>loadEditorDecision(f.video),/Declared EDL not found/);
62
+ }finally{f.cleanup();}
63
+ });
@@ -3,6 +3,11 @@ return `
3
3
  const feedback=document.getElementById('feedback'),status=document.getElementById('status'),pathLabel=document.getElementById('path-label');
4
4
  let nextId=0,identity=null,busy=false,expectedPath=null,activePath=null,activeReview={delivery:"text"},expectedDelivery="text",expectedReadonly=false,submittedRevision=null,submission=null;
5
5
  const comments=[];
6
+ let questions=[],questionAnswers={};
7
+ const isQuestionMode=()=>activeReview?.mode==='questions';
8
+ window.addEventListener('markcut:questions-change',event=>{
9
+ if(isQuestionMode())questionAnswers={...(event.detail?.answers||{})};
10
+ });
6
11
  let currentScene={sceneId:null,sceneName:null,sceneStart:0,timeSeconds:0},selectedId=0,nextCommentId=0;
7
12
  const mode=document.getElementById('comment-mode');
8
13
  const isViewOnly=()=>expectedReadonly||activeReview?.readonly===true;
@@ -238,9 +243,16 @@ function reviewReadonly(readonly,message){
238
243
  for(const id of ['approve','changes']){
239
244
  const button=document.getElementById(id);
240
245
  button.disabled=viewOnly||readonly;
241
- button.style.display=viewOnly?'none':'';
246
+ button.style.display=viewOnly||isQuestionMode()?'none':'';
242
247
  }
243
- document.getElementById('comment-entry').style.display=viewOnly?'none':'';
248
+ document.getElementById('comment-entry').style.display=viewOnly||isQuestionMode()?'none':'';
249
+ const actions=document.querySelector('.review-actions');
250
+ actions.style.display=isQuestionMode()?'flex':'';
251
+ actions.style.justifyContent=isQuestionMode()?'center':'';
252
+ actions.style.flexWrap=isQuestionMode()?'wrap':'';
253
+ const submitButton=document.getElementById('questions-submit');
254
+ submitButton.hidden=!isQuestionMode();
255
+ submitButton.disabled=!isQuestionMode()||viewOnly||readonly;
244
256
  if(readonly&&message)status.textContent=message;
245
257
  }
246
258
  async function renderRevision(data){
@@ -258,7 +270,7 @@ async function renderRevision(data){
258
270
  let compiled=data.compiled;
259
271
  if(data.compiledUrl){
260
272
  const url=new URL(data.compiledUrl);
261
- if(url.origin!==__MARKCUT_ORIGIN__||!url.pathname.startsWith('/files/_neoy/markcut/cache/')||!(/^[a-f0-9]{64}[.]json$/.test(url.pathname.split('/').pop())))
273
+ if(url.origin!==__MARKCUT_ORIGIN__||!url.pathname.startsWith('/files/_neoy/markcut/cache/')||!(/^[a-f0-9]{64}(?:-[a-f0-9]{16})?[.]json$/.test(url.pathname.split('/').pop())))
262
274
  throw new Error('Invalid immutable preview URL');
263
275
  const response=await fetch(url.href,{cache:'force-cache'});
264
276
  if(!response.ok)throw new Error('Static compiled scenes unavailable: HTTP '+response.status);
@@ -267,6 +279,8 @@ async function renderRevision(data){
267
279
  if(generation!==renderGeneration)return;
268
280
  document.getElementById('interactive-ui').hidden=false;
269
281
  window.__markcutRevision={...data,compiled};
282
+ questions=(compiled.root?.children||compiled.children||[]).filter(scene=>scene.type==='scene').map((scene,index)=>({name:String(scene.name||'Q'+(index+1)),id:scene.id}));
283
+ questionAnswers={};
270
284
  window.dispatchEvent(new CustomEvent('markcut:revision',{detail:window.__markcutRevision}));
271
285
  status.textContent='';
272
286
  if(!data.compiledUrl){
@@ -285,6 +299,27 @@ async function renderRevision(data){
285
299
  reviewReadonly(true,'Preview unavailable or review state unverified: '+String(e));
286
300
  }
287
301
  }
302
+ // Editor Decisions are an informational subview, not the film approval target.
303
+ // Hide film-review actions while the editor-decision timeline is active.
304
+ let editorReviewControls=null;
305
+ window.addEventListener('markcut:edl-view',event=>{
306
+ const edl=Boolean(event.detail?.active);
307
+ const ids=['approve','changes','comment-entry'];
308
+ if(edl&&!editorReviewControls){
309
+ editorReviewControls=ids.map(id=>{
310
+ const node=document.getElementById(id);
311
+ return {node,display:node?.style.display,disabled:node?.disabled};
312
+ });
313
+ for(const item of editorReviewControls){
314
+ if(item.node){item.node.style.display='none';if('disabled' in item.node)item.node.disabled=true;}
315
+ }
316
+ }else if(!edl&&editorReviewControls){
317
+ for(const item of editorReviewControls){
318
+ if(item.node){item.node.style.display=item.display;if('disabled' in item.node)item.node.disabled=item.disabled;}
319
+ }
320
+ editorReviewControls=null;
321
+ }
322
+ });
288
323
  window.addEventListener('message',event=>{
289
324
  if(event.source!==window.parent)return;
290
325
  const message=event.data;
@@ -302,20 +337,20 @@ async function initialize(){
302
337
  }
303
338
  async function submit(decision){
304
339
  if(busy||isViewOnly())return;
305
- if(document.getElementById(decision==='approved'?'approve':'changes').disabled){
340
+ if(document.getElementById(isQuestionMode()?'questions-submit':(decision==='approved'?'approve':'changes')).disabled){
306
341
  status.textContent='Review disabled for this revision or delivery configuration.';return;
307
342
  }
308
343
  // The submission button must save a draft, not silently require a second '+' action.
309
- if(feedback.value.trim()){
344
+ if(!isQuestionMode()&&feedback.value.trim()){
310
345
  if(decision==='approved'){
311
346
  status.textContent='You have draft feedback. Submit feedback or clear it before approving.';
312
347
  return;
313
348
  }
314
349
  if(!saveDraft({fallbackOverall:true}))return;
315
350
  }
316
- const preparedComments=allComments();
317
- if(decision==='changes_requested'&&!preparedComments.length){status.textContent='Feedback is required.';return;}
318
- if(decision==='approved'&&preparedComments.length){status.textContent='Submit or remove draft comments before approval.';return;}
351
+ const preparedComments=isQuestionMode()?questions.map(q=>({scope:'scene',text:questionAnswers[q.name]||'',playbackContext:{sceneId:q.id||null,sceneName:q.name,sceneStart:0,timeSeconds:0}})):allComments();
352
+ if(!isQuestionMode()&&decision==='changes_requested'&&!preparedComments.length){status.textContent='Feedback is required.';return;}
353
+ if(!isQuestionMode()&&decision==='approved'&&preparedComments.length){status.textContent='Submit or remove draft comments before approval.';return;}
319
354
  if(!identity){status.textContent='Preview identity unavailable.';return;}
320
355
  if(window.__markcutRevision?.compiledUrl){
321
356
  try{if(!await currentRevisionMatches(activePath,identity.contentHash)){reviewReadonly(true,'Historical Preview · Read-only');return;}}
@@ -325,6 +360,7 @@ async function submit(decision){
325
360
  sceneId:item.playbackContext?.sceneId||null,timeSeconds:Number(item.playbackContext?.timeSeconds)||0,
326
361
  text:item.text,scope:item.scope,playbackContext:item.playbackContext
327
362
  }))};
363
+ if(isQuestionMode()){result.status='submitted';result.answers=questions.map(q=>({questionId:q.name,answer:questionAnswers[q.name]||''}));}
328
364
  // Retain the same submission key across retries, including lost ACKs.
329
365
  const signature=JSON.stringify({result,delivery:activeReview.delivery});
330
366
  if(!submission || submission.signature!==signature)submission={signature,key:crypto.randomUUID()};
@@ -341,10 +377,11 @@ async function submit(decision){
341
377
  if(!delivered){busy=false;return;}
342
378
  if(identity?.revisionId===submittedId){submittedRevision=submittedId;status.textContent=activeReview.delivery==='event'
343
379
  ? 'Review event submitted (transport accepted; awaiting consumer).'
344
- : (decision==='approved'?'Review sent.':'Feedback sent. Waiting for the updated preview.');}
380
+ : (isQuestionMode()?'Answers submitted.':(decision==='approved'?'Review sent.':'Feedback sent. Waiting for the updated preview.'));}
345
381
  }
346
382
  catch(e){busy=false;status.textContent='Review not submitted: '+(e.message||'Unable to submit review');}
347
383
  }
384
+ document.getElementById('questions-submit').onclick=()=>submit('approved');
348
385
  document.getElementById('approve').onclick=()=>submit('approved');
349
386
  document.getElementById('changes').onclick=()=>submit('changes_requested');
350
387
  redrawComments();
@@ -14,10 +14,10 @@ try{
14
14
  if(actualHash!==sourceHash)throw new Error("Source changed while queued; retry preview");
15
15
  const result=await ensureVideoPreview(path,{onProgress:update});
16
16
  update("publishing");
17
- publishPreviewRevision(requestedPath,{...result,requestedPath});
17
+ publishPreviewRevision(requestedPath,{...result,requestedPath,...(review.title ? {title:review.title} : {})});
18
18
  // Markcut is a pure preview provider. The Neo MCP wrapper owns mobile delivery.
19
19
  writeOperation(id,{id,state:"ready",stage:"complete",startedAt,updatedAt:Date.now(),requestedPath,
20
- result:{...result,requestedPath,requestId:id,review}});
20
+ result:{...result,requestedPath,requestId:id,review,...(review.title ? {title:review.title} : {})}});
21
21
 
22
22
  }catch(e){
23
23
  writeOperation(id,{id,state:"failed",stage:"failed",startedAt,updatedAt:Date.now(),requestedPath,review,error:e?.message||String(e)});
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  /** Standalone terminal preview compiler. Notification is owned by the Neo MCP wrapper. */
3
3
  import {readFileSync,existsSync} from 'node:fs';
4
- import {join,resolve,basename} from 'node:path';
4
+ import {spawn,execFileSync} from 'node:child_process';
5
+ import {join,resolve,basename,dirname} from 'node:path';
5
6
  import {homedir} from 'node:os';
6
7
  import {pathToFileURL} from 'node:url';
7
8
  import {normalizeReviewConfig} from './review-delivery.mjs';
@@ -27,25 +28,39 @@ export function parseEventPreviewOptions(argv) {
27
28
  return options;
28
29
  }
29
30
 
30
- // The compiler stays platform-neutral. The explicit CLI review workflow
31
- // delivers to Neo.app's authenticated local Core REST boundary, never APNs or
32
- // the Agent-facing MCP tool surface. Inability to persist the inbox is fatal.
33
- export function neoReviewEndpoint(override=process.env.NEO_REVIEW_NOTIFY_URL,
34
- deploymentFile=join(homedir(),'Library','Application Support','NeoY','deployment.json')){
35
- let url;
36
- if(override)url=new URL(override);
37
- else{
38
- let port=6767;
39
- if(existsSync(deploymentFile)){
40
- const config=JSON.parse(readFileSync(deploymentFile,'utf8'));
41
- if(Number.isInteger(config.mcpPort)&&config.mcpPort>0&&config.mcpPort<=65535)port=config.mcpPort;
42
- }
43
- url=new URL('http://127.0.0.1:'+port+'/mobile/review/notify');
44
- }
45
- if(url.protocol!=='http:'||!['localhost','127.0.0.1'].includes(url.hostname)||
46
- url.pathname!=='/mobile/review/notify'||url.search||url.hash||url.username||url.password)
47
- throw Error('Neo Review delivery must use the local REST notify endpoint');
48
- return url.href;
31
+ // The explicit Neo Mobile delivery CLI resolves the installed Neo wrapper.
32
+ // No application-specific queue, APNs key or direct Review REST dependency
33
+ // is embedded in Markcut's compiler/server.
34
+ export function neoReviewWrapper(override=process.env.NEO_REVIEW_WRAPPER,
35
+ discover=execFileSync){
36
+ if(override){
37
+ const path=resolve(override);
38
+ if(!existsSync(path))throw Error('Neo preview wrapper is unavailable');
39
+ return path;
40
+ }
41
+ const catalog=JSON.parse(String(discover('neo',['skill','list'],
42
+ {encoding:'utf8',timeout:10000,maxBuffer:1024*1024})));
43
+ const entry=catalog.find(x=>x.name==='mcp-wrapper'&&typeof x.path==='string');
44
+ if(!entry)throw Error('Neo mcp-wrapper skill is unavailable');
45
+ const path=join(dirname(entry.path),'markcut.mjs');
46
+ if(!existsSync(path))throw Error('Neo preview wrapper is unavailable');
47
+ return path;
48
+ }
49
+ export async function deliverThroughNeoWrapper(request,{wrapper=neoReviewWrapper()}={}){
50
+ const child=spawn(process.execPath,[wrapper,'deliver'],{stdio:['pipe','pipe','pipe']});
51
+ return await new Promise((resolve,reject)=>{
52
+ let out='',err='';
53
+ const timer=setTimeout(()=>{child.kill();reject(Error('Neo review delivery timed out'))},20000);
54
+ child.stdout.on('data',bytes=>{out+=String(bytes);if(out.length>65536)child.kill();});
55
+ child.stderr.on('data',bytes=>{err+=String(bytes);if(err.length>2000)err=err.slice(0,2000);});
56
+ child.on('error',error=>{clearTimeout(timer);reject(error)});
57
+ child.on('close',code=>{
58
+ clearTimeout(timer);
59
+ if(code!==0){reject(Error('Neo review wrapper delivery failed: '+err.slice(0,300)));return;}
60
+ try{resolve(JSON.parse(out))}catch{reject(Error('Invalid Neo review receipt'))}
61
+ });
62
+ child.stdin.end(JSON.stringify(request));
63
+ });
49
64
  }
50
65
  export function buildReviewRequest(options,config,state,operationId){
51
66
  const data=state?.result;
@@ -60,19 +75,11 @@ export function buildReviewRequest(options,config,state,operationId){
60
75
  }else {request.contentHash=data.contentHash;request.revisionId=data.revisionId;request.groupId=options.file;}
61
76
  return request;
62
77
  }
63
- export async function submitNeoReview(request,{fetchImpl=fetch,url=neoReviewEndpoint()}={}){
64
- const destination=new URL(url);
65
- if(destination.protocol!=='http:'||!['127.0.0.1','localhost'].includes(destination.hostname)||
66
- destination.pathname!=='/mobile/review/notify'||destination.search||destination.hash)
67
- throw Error('Refusing a nonlocal Neo Review notification destination');
68
- const response=await fetchImpl(destination.href,{method:'POST',
69
- headers:{'Content-Type':'application/json','Accept':'application/json'},
70
- body:JSON.stringify(request),signal:AbortSignal.timeout(55000),redirect:'error'});
71
- if(!response.ok)throw Error('Neo Review REST rejected delivery: HTTP '+response.status);
72
- const receipt=await response.json();
73
- if(receipt?.stored!==true||receipt.requestId!==request.id)
74
- throw Error('Neo Review Core did not acknowledge durable Inbox storage');
75
- return receipt;
78
+ export async function submitNeoReview(request,{deliver=deliverThroughNeoWrapper}={}){
79
+ const receipt=await deliver(request);
80
+ if(receipt?.stored!==true||receipt.requestId!==request.id)
81
+ throw Error('Neo preview wrapper did not acknowledge durable delivery');
82
+ return receipt;
76
83
  }
77
84
 
78
85
  export async function runMobilePreview(argv){
@@ -1,6 +1,21 @@
1
+ #markcut-questions{background:#fff;color:#17202a}
2
+ #markcut-questions textarea{background:#fff;color:#17202a}
3
+ @media(prefers-color-scheme:dark){#markcut-questions{background:#161b22;color:#f2f5fb}#markcut-questions textarea{background:#242b36;color:#f2f5fb}}
4
+ /* The MCP iframe can be very short even when its card is wide on desktop.
5
+ * Never derive DESKTOP canvas width from iframe viewport height: it reduces a
6
+ * 1:1 model to ~300px in a wide review card. Limit the longest video dimension
7
+ * to 760px, with CSS aspect-ratio maintaining the source video proportions. */
8
+ #remotion-preview { display:flex; flex-direction:column; min-width:0; }
9
+ #remotion-canvas {
10
+ box-sizing: border-box;
11
+ width: min(100%, calc(760px * var(--markcut-player-ratio, 0.5625)));
12
+ max-width: 760px;
13
+ flex: 0 0 auto;
14
+ }
15
+
1
16
  /* ChatGPT MCP iframe on phones: keep scenes, video controls and review actions
2
17
  * in separate normal-flow rows. Never position the footer over the player. */
3
- @media (max-width: 640px), (max-height: 520px) {
18
+ @media (max-width: 640px), (max-width: 900px) and (max-height: 520px) {
4
19
  html, body { min-width: 0; width: 100%; overflow-x: hidden; }
5
20
  main { box-sizing: border-box; width: 100%; padding: 8px 10px 12px; }
6
21
  main > header { flex-wrap: wrap; gap: 4px 8px; min-width: 0; padding-bottom: 4px; }
@@ -10,14 +25,12 @@
10
25
  flex-wrap: wrap; justify-content: flex-end; }
11
26
  #review-delivery-mode, #player-version { font-size: 11px !important; }
12
27
  #remotion-preview { display: flex; flex-direction: column; min-width: 0; }
13
- /* A vertical 9:16 movie must scale BOTH dimensions together. The original
14
- width:100% / max-height:65vh combination filled the screen and clipped
15
- Remotion's bottom transport and the scene selector in mobile chat. */
28
+ /* Narrow phones and short, narrow landscape embeds limit height through
29
+ proportional WIDTH, not max-height (which clips native Remotion controls).
30
+ Square videos still use almost the whole available phone width. */
16
31
  #remotion-canvas {
17
- box-sizing: border-box;
18
- width: min(100%, calc(min(58dvh, 440px) * var(--markcut-player-ratio, 0.5625))) !important;
19
- max-height: min(58dvh, 440px) !important;
20
- flex: 0 0 auto;
32
+ width: min(100%, calc(min(76dvh, 520px) * var(--markcut-player-ratio, 0.5625)));
33
+ max-width: 100%;
21
34
  overflow: visible;
22
35
  }
23
36
  #scene-thumbnails { order: 0; min-width: 0; max-width: 100%; gap: 6px;