@lalalic/markcut 3.2.47 → 3.2.49
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/README.md +15 -7
- package/docs/developer-reference.md +4 -0
- package/package.json +1 -1
- package/src/mcp/bridge.mjs +48 -18
- package/src/mcp/mobile-review-cli.mjs +66 -8
- package/src/mcp/preview.mjs +5 -6
- package/src/mcp/remotion-app.bundle.js +73 -73
- package/src/mcp/remotion-app.tsx +2 -3
- package/src/mcp/review-delivery.mjs +6 -5
- package/src/mcp/server.mjs +2 -2
- package/src/render/cli.mjs +1 -0
- package/src/vision/cli.mjs +37 -3
- package/tests/mcp-preview-bridge.test.ts +41 -28
- package/tests/mcp-preview-delivery.test.ts +7 -6
- package/tests/mcp-preview.test.ts +14 -0
- package/tests/mobile-preview-cli.test.ts +40 -2
- package/tests/vision-normalize-only.test.ts +55 -0
package/src/mcp/remotion-app.tsx
CHANGED
|
@@ -16,7 +16,7 @@ function App(){
|
|
|
16
16
|
const [currentTime,setCurrentTime]=React.useState(0);
|
|
17
17
|
const [browserTts,setBrowserTts]=React.useState(true);
|
|
18
18
|
const [commentedScenes,setCommentedScenes]=React.useState<string[]>([]);
|
|
19
|
-
const [spotMarkers,setSpotMarkers]=React.useState<Array<{id:number;scope:'overall'|'scene'|'spot';text:string;context:{timeSeconds:number;sceneName?:string};selected:boolean;placeholder?:boolean}>>([{id:0,scope:'overall',text:'',context:{timeSeconds:0},selected:
|
|
19
|
+
const [spotMarkers,setSpotMarkers]=React.useState<Array<{id:number;scope:'overall'|'scene'|'spot';text:string;context:{timeSeconds:number;sceneName?:string};selected:boolean;placeholder?:boolean}>>([{id:0,scope:'overall',text:'',context:{timeSeconds:0},selected:true,placeholder:true}]);
|
|
20
20
|
const [seekBar,setSeekBar]=React.useState<HTMLElement|null>(null);
|
|
21
21
|
React.useEffect(()=>{
|
|
22
22
|
const listener=(event:Event)=>setCommentedScenes((event as CustomEvent).detail?.sceneNames||[]);
|
|
@@ -31,7 +31,7 @@ function App(){
|
|
|
31
31
|
React.useEffect(()=>{const receive=(e:Event)=>setRevision((e as CustomEvent).detail);window.addEventListener('markcut:revision',receive);return ()=>window.removeEventListener('markcut:revision',receive)},[]);
|
|
32
32
|
const data=revision?.compiled?.root||revision?.compiled;
|
|
33
33
|
const useBrowserTts=browserTts&&Boolean(data?.subtitle?.src);
|
|
34
|
-
const {playbackRoot:generatedRoot
|
|
34
|
+
const {playbackRoot:generatedRoot}=useWebAudioPreview(data,ref);
|
|
35
35
|
const playbackRoot=React.useMemo(()=>{
|
|
36
36
|
if(!useBrowserTts)return generatedRoot;
|
|
37
37
|
return withoutRecordedNarration(generatedRoot);
|
|
@@ -112,7 +112,6 @@ function App(){
|
|
|
112
112
|
onPointerDown={e=>e.stopPropagation()} onClick={e=>{e.stopPropagation();window.dispatchEvent(new CustomEvent('markcut:spot-select',{detail:{id:note.id}}));}}/>;
|
|
113
113
|
})}
|
|
114
114
|
</>,seekBar)}
|
|
115
|
-
{status && !/initializing|ready|paused/i.test(status) && <div id="preview-audio-status" role="status" style={{fontSize:12,padding:'4px 0'}}>{status.replace(/^Web Audio /,'Audio ')}</div>}
|
|
116
115
|
</div>;
|
|
117
116
|
}
|
|
118
117
|
const el=document.getElementById('remotion-root');
|
|
@@ -3,7 +3,7 @@ const ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
|
3
3
|
const SOURCE = /^job\/[A-Za-z0-9_-]+\/task\/[A-Za-z0-9_-]+\/execution\/[A-Za-z0-9_-]+$/;
|
|
4
4
|
const RECORD = value => value && typeof value === "object" && !Array.isArray(value);
|
|
5
5
|
const INTERACTIVE_TYPE = "task.interactive_decision";
|
|
6
|
-
const REVIEW_FIELDS = ["decision","feedback","comments","revision","revisionId","contentHash","previewId","requestId","idempotencyKey"];
|
|
6
|
+
const REVIEW_FIELDS = ["decision","feedback","comments","revision","revisionId","contentHash","commitSha","previewId","requestId","idempotencyKey"];
|
|
7
7
|
function copyData(value) {
|
|
8
8
|
if (!RECORD(value)) throw new Error("eventTemplate.data must be an object");
|
|
9
9
|
// No executable values or reserved overrides can be shipped in a template.
|
|
@@ -40,25 +40,26 @@ export function normalizeReviewConfig(value) {
|
|
|
40
40
|
!ID.test(interactive.invocationId||"") ||
|
|
41
41
|
REVIEW_FIELDS.some(field=>Object.hasOwn(interactive,field)))
|
|
42
42
|
throw new Error("Invalid task.interactive_decision event template");
|
|
43
|
-
|
|
43
|
+
if (!/^[a-f0-9]{40}$/.test(value.commitSha||"")) throw new Error("Event review requires full Git Commit SHA");
|
|
44
|
+
return {delivery:"event",commitSha:value.commitSha,eventTemplate:{
|
|
44
45
|
type:template.type,source:template.source,data,
|
|
45
46
|
}};
|
|
46
47
|
}
|
|
47
48
|
export function eventForReview(config,review) {
|
|
48
49
|
const {eventTemplate:template}=normalizeReviewConfig(config);
|
|
49
50
|
if (!template) throw new Error("Event mode required");
|
|
50
|
-
if (!RECORD(review) || !ID.test(review.requestId || "") ||
|
|
51
|
-
|| !/^[a-f0-9]{64}$/.test(review.contentHash || "")
|
|
51
|
+
if (!RECORD(review) || !ID.test(review.requestId || "") || !/^[a-f0-9]{40}$/.test(review.commitSha || "")
|
|
52
52
|
|| !["approved","changes_requested"].includes(review.decision)
|
|
53
53
|
|| !ID.test(review.idempotencyKey || "") || !Array.isArray(review.comments))
|
|
54
54
|
throw new Error("Invalid review result");
|
|
55
|
+
if (review.commitSha !== config.commitSha)throw new Error("Review Commit SHA differs from immutable preview request");
|
|
55
56
|
const details=template.data.interactive;
|
|
56
57
|
const feedback=typeof review.feedback==="string" ? review.feedback :
|
|
57
58
|
review.comments.map(comment=>comment.text).filter(value=>typeof value==="string").join("\n");
|
|
58
59
|
return {type:INTERACTIVE_TYPE,source:template.source,data:{
|
|
59
60
|
...template.data,
|
|
60
61
|
interactive:{...details,
|
|
61
|
-
revision:review.
|
|
62
|
+
revision:review.commitSha,commitSha:review.commitSha,
|
|
62
63
|
previewId:review.previewId,requestId:review.requestId,
|
|
63
64
|
decision:review.decision,feedback,comments:structuredClone(review.comments),
|
|
64
65
|
idempotencyKey:review.idempotencyKey},
|
package/src/mcp/server.mjs
CHANGED
|
@@ -47,10 +47,10 @@ registerAppTool(
|
|
|
47
47
|
server,
|
|
48
48
|
TOOL_NAME,
|
|
49
49
|
{
|
|
50
|
-
description: "Compile and publish an immutable Markcut preview revision for this ChatGPT conversation. Review delivery defaults to ui/message, or submits an authorized caller-bound event when explicitly configured.
|
|
50
|
+
description: "Compile and publish an immutable Markcut preview revision for this ChatGPT conversation. Review delivery defaults to ui/message, or submits an authorized caller-bound event when explicitly configured. Event-mode decisions bind the verified 40-character Git Commit SHA, not the compiled-media cache hash.",
|
|
51
51
|
inputSchema: z.object({
|
|
52
52
|
path: z.string().describe("Absolute .md path or NeoY HTTPS mounted file URL"),
|
|
53
|
-
review: z.object({delivery:z.enum(["text","event"]).optional(),eventTemplate:z.object({type:z.string(),source:z.string(),data:z.record(z.string(),z.unknown())}).optional()}).optional(),
|
|
53
|
+
review: z.object({delivery:z.enum(["text","event"]).optional(),commitSha:z.string().regex(/^[a-f0-9]{40}$/).optional(),eventTemplate:z.object({type:z.string(),source:z.string(),data:z.record(z.string(),z.unknown())}).optional()}).optional(),
|
|
54
54
|
relay: z.object({jobId:z.string(),taskId:z.union([z.string(),z.number()]),executionId:z.string().optional()}).optional().describe("Optional Agents Relay task correlation. No Relay dependency for standalone ChatGPT/Work reviews."),
|
|
55
55
|
}),
|
|
56
56
|
_meta: {
|
package/src/render/cli.mjs
CHANGED
|
@@ -85,6 +85,7 @@ Commands:
|
|
|
85
85
|
--verbose Show full per-frame progress (default: compact)
|
|
86
86
|
|
|
87
87
|
vision <folder> Full pipeline: extract → normalize → percept → segments
|
|
88
|
+
--normalize-only Produce lightweight Vision Understanding files without AI
|
|
88
89
|
--label Add interactive labeling step before AI pipeline
|
|
89
90
|
--instruct "text" Background context about people/places (injected into prompts)
|
|
90
91
|
|
package/src/vision/cli.mjs
CHANGED
|
@@ -282,7 +282,7 @@ function normalizeImage(srcPath, normDir, maxDim = MAX_IMAGE_DIMENSION) {
|
|
|
282
282
|
const outPath = join(normDir, outName);
|
|
283
283
|
if (existsSync(outPath)) return outPath;
|
|
284
284
|
const filter = `scale='min(${maxDim},iw)':'min(${maxDim},ih)':force_original_aspect_ratio=decrease`;
|
|
285
|
-
const cmd = `ffmpeg -y -i ${shQuote(srcPath)} -vf ${shQuote(filter)} -q:v 3 -update 1 ${shQuote(outPath)}`;
|
|
285
|
+
const cmd = `ffmpeg -y -i ${shQuote(srcPath)} -map_metadata -1 -vf ${shQuote(filter)} -q:v 3 -update 1 ${shQuote(outPath)}`;
|
|
286
286
|
try { run(cmd); return outPath; }
|
|
287
287
|
catch (e) { emitWarn(`Failed to normalize image ${basename(srcPath)}: ${e.message}`); return srcPath; }
|
|
288
288
|
}
|
|
@@ -299,7 +299,7 @@ function normalizeVideo(srcPath, normDir, duration, maxDim = MAX_VIDEO_DIMENSION
|
|
|
299
299
|
const outPath = join(normDir, outName);
|
|
300
300
|
if (existsSync(outPath)) return { path: outPath, trimmedDuration: totalDur, timeHint };
|
|
301
301
|
const filter = `scale='min(${maxDim},iw)':'min(${maxDim},ih)':force_original_aspect_ratio=decrease,pad='ceil(iw/2)*2':'ceil(ih/2)*2':-1:-1`;
|
|
302
|
-
const cmd = `ffmpeg -y -i ${shQuote(srcPath)} -t ${totalDur} -vf ${shQuote(filter)} -c:v libx264 -preset fast -crf 28 -c:a aac -b:a 64k ${shQuote(outPath)}`;
|
|
302
|
+
const cmd = `ffmpeg -y -i ${shQuote(srcPath)} -t ${totalDur} -map_metadata -1 -map_chapters -1 -vf ${shQuote(filter)} -c:v libx264 -preset fast -crf 28 -c:a aac -b:a 64k ${shQuote(outPath)}`;
|
|
303
303
|
try { run(cmd, { timeout: 600_000 }); return { path: outPath, trimmedDuration: totalDur, timeHint }; }
|
|
304
304
|
catch (e) { emitWarn(`Failed to normalize video ${basename(srcPath)}: ${e.message}`); return { path: srcPath, trimmedDuration: totalDur, timeHint }; }
|
|
305
305
|
}
|
|
@@ -313,7 +313,7 @@ function normalizeVideo(srcPath, normDir, duration, maxDim = MAX_VIDEO_DIMENSION
|
|
|
313
313
|
const step = Math.max(1, Math.floor(frameCount / maxSamples));
|
|
314
314
|
const actualSamples = Math.min(maxSamples, Math.ceil(frameCount / step));
|
|
315
315
|
const filter = `select='not(mod(n,${step}))',setpts=N/TB,scale='min(${maxDim},iw)':'min(${maxDim},ih)':force_original_aspect_ratio=decrease,pad='ceil(iw/2)*2':'ceil(ih/2)*2':-1:-1`;
|
|
316
|
-
const cmd = `ffmpeg -y -i ${shQuote(srcPath)} -vf ${shQuote(filter)} -c:v libx264 -preset fast -crf 28 -an -t ${actualSamples} -r 1 ${shQuote(outPath)}`;
|
|
316
|
+
const cmd = `ffmpeg -y -i ${shQuote(srcPath)} -map_metadata -1 -map_chapters -1 -vf ${shQuote(filter)} -c:v libx264 -preset fast -crf 28 -an -t ${actualSamples} -r 1 ${shQuote(outPath)}`;
|
|
317
317
|
try {
|
|
318
318
|
emitInfo(` Sampling ${actualSamples} frames across ${totalDur.toFixed(1)}s video`);
|
|
319
319
|
run(cmd, { timeout: 600_000 });
|
|
@@ -1152,9 +1152,11 @@ markcut vision — Analyze images and videos in a folder for video generation
|
|
|
1152
1152
|
Usage:
|
|
1153
1153
|
markcut vision <folder> Full pipeline: extract → normalize → percept → segments
|
|
1154
1154
|
markcut vision <folder> --label Same as default, plus interactive labeling step before AI
|
|
1155
|
+
markcut vision <folder> --normalize-only Produce token-efficient Vision Understanding inputs without AI
|
|
1155
1156
|
|
|
1156
1157
|
Options:
|
|
1157
1158
|
--label Open interactive labeling preview before running AI pipeline
|
|
1159
|
+
--normalize-only 360px video / 384px image inputs, full input-time mapping; long videos sampled; no AI
|
|
1158
1160
|
--instruct "text" Background context about people/places (injected into prompts)
|
|
1159
1161
|
--prompts-file <path> Path to prompts markdown file (default: vision_prompts.md)
|
|
1160
1162
|
--vtt-sample-interval <n> Sample one video frame every N seconds (default: 5)
|
|
@@ -1180,6 +1182,7 @@ export async function main(args) {
|
|
|
1180
1182
|
let skipSTT = false;
|
|
1181
1183
|
let dryRun = false;
|
|
1182
1184
|
let doLabel = false;
|
|
1185
|
+
let normalizeOnly = false;
|
|
1183
1186
|
let candidateMode = false;
|
|
1184
1187
|
let output = "";
|
|
1185
1188
|
let modelCommand = "";
|
|
@@ -1199,6 +1202,7 @@ export async function main(args) {
|
|
|
1199
1202
|
const flag = args[i++];
|
|
1200
1203
|
if (flag === "--help") { printUsage(); return; }
|
|
1201
1204
|
else if (flag === "--label") { doLabel = true; }
|
|
1205
|
+
else if (flag === "--normalize-only") { normalizeOnly = true; }
|
|
1202
1206
|
else if (["--itt", "--vtt", "--agent", "--stt", "--tts", "--tti", "--ttv", "--edit-cli"].includes(flag) && args[i]) { i++; }
|
|
1203
1207
|
else if (flag === "--candidate") { candidateMode = true; }
|
|
1204
1208
|
else if (flag === "--output" && args[i]) { output = resolve(args[i++]); }
|
|
@@ -1248,6 +1252,36 @@ export async function main(args) {
|
|
|
1248
1252
|
return;
|
|
1249
1253
|
}
|
|
1250
1254
|
|
|
1255
|
+
if (normalizeOnly) {
|
|
1256
|
+
if (doLabel || candidateMode || dryRun || pickSet.size > 0) {
|
|
1257
|
+
throw new Error('--normalize-only cannot be combined with label, candidate, pick or dry-run');
|
|
1258
|
+
}
|
|
1259
|
+
// Reuse exactly the normalization used by the VTT/ITT pipeline. No AI
|
|
1260
|
+
// inference or full-resolution media is sent to an understanding model.
|
|
1261
|
+
const media = scanMedia(folder);
|
|
1262
|
+
if (media.images.length + media.videos.length === 0) throw new Error('No Vision Understanding source media');
|
|
1263
|
+
const normDir = join(folder, '.normalized');
|
|
1264
|
+
mkdirSync(normDir, { recursive: true });
|
|
1265
|
+
const files = [];
|
|
1266
|
+
for (const original of media.images) {
|
|
1267
|
+
const normalized = normalizeImage(original, normDir);
|
|
1268
|
+
if (normalized === original || !existsSync(normalized)) throw new Error(`Failed to normalize Vision image: ${original}`);
|
|
1269
|
+
files.push({ source: basename(original), path: normalized, kind: 'image', sampled: false,
|
|
1270
|
+
maxDimension: MAX_IMAGE_DIMENSION });
|
|
1271
|
+
}
|
|
1272
|
+
for (const original of media.videos) {
|
|
1273
|
+
const duration = getVideoDuration(original);
|
|
1274
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error(`Video has no usable duration: ${original}`);
|
|
1275
|
+
const info = normalizeVideo(original, normDir, duration);
|
|
1276
|
+
if (info.path === original || !existsSync(info.path)) throw new Error(`Failed to normalize Vision video: ${original}`);
|
|
1277
|
+
files.push({ source: basename(original), path: info.path, kind: 'video',
|
|
1278
|
+
sampled: duration > MAX_VIDEO_DURATION, sourceDurationSeconds: duration,
|
|
1279
|
+
maxDimension: MAX_VIDEO_DIMENSION });
|
|
1280
|
+
}
|
|
1281
|
+
console.log(JSON.stringify({ status: 'PASS', usage: 'vision-understanding-only',
|
|
1282
|
+
profile: 'markcut-vision-normalized-v1', files }));
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1251
1285
|
if (doLabel) {
|
|
1252
1286
|
// Full pipeline with interactive labeling
|
|
1253
1287
|
await runFullPipeline(folder, prompts, context, pickSet, vttSampleInterval, skipSTT, dryRun);
|
|
@@ -12,7 +12,7 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>, too
|
|
|
12
12
|
replaceChildren(){this.children=[]},append(...items:any[]){this.children.push(...items)}
|
|
13
13
|
});
|
|
14
14
|
const nodes:Record<string,ReturnType<typeof element>>={
|
|
15
|
-
feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes:element(),'save-spot':element(),'remove-spot':element(),'comment-target':element(),'comment-
|
|
15
|
+
feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes:element(),'save-spot':element(),'remove-spot':element(),'comment-target':element(),'comment-mode':element(),'overall-mode':element(),'review-delivery-mode':element()
|
|
16
16
|
};
|
|
17
17
|
nodes['comment-mode'].value='spot';
|
|
18
18
|
let dispatch:(message:any,source?:any)=>void;
|
|
@@ -29,6 +29,7 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>, too
|
|
|
29
29
|
const result=(data:any)=>dispatch({method:'ui/notifications/tool-result',params:{result:{structuredContent:{...data}}}});
|
|
30
30
|
const respond=(id:number,result:any={})=>dispatch({id,result});
|
|
31
31
|
vm.runInContext(buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify("https://neoy.qili2.com")),context);
|
|
32
|
+
events.length=0; // Ignore the initial Overall marker/selection render in tests about later events.
|
|
32
33
|
return {messages,nodes,events,dispatch,result,respond,scene:(detail:any)=>(listeners['markcut:scene-change']||[]).forEach(listener=>listener({detail})),selectSpot:(id:number)=>(listeners['markcut:spot-select']||[]).forEach(listener=>listener({detail:{id}}))};
|
|
33
34
|
}
|
|
34
35
|
const nextTick=()=>new Promise(resolve=>setTimeout(resolve,0));
|
|
@@ -79,6 +80,20 @@ describe('MCP Remotion bridge',()=>{
|
|
|
79
80
|
await nextTick();
|
|
80
81
|
expect(h.nodes.status.textContent).toBe('Review sent.');
|
|
81
82
|
});
|
|
83
|
+
it('shows Text mode by default, Event mode only with a provider-bound template',()=>{
|
|
84
|
+
const h=harness();
|
|
85
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Text mode');
|
|
86
|
+
const eventTemplate={type:'task.interactive_decision',source:'job/1/task/2/execution/3',
|
|
87
|
+
data:{interactive:{jobId:'1',taskId:'2',executionId:'3',invocationId:'i1'}}};
|
|
88
|
+
h.dispatch({method:'ui/notifications/tool-input',params:{arguments:{path:'/test.md',review:{delivery:'event'}}}});
|
|
89
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Event mode · unavailable');
|
|
90
|
+
h.result({path:'/test.md',id:'one',revisionId:'r1',contentHash:'a'.repeat(64),
|
|
91
|
+
compiled:{children:[]},review:{delivery:'event',eventTemplate}});
|
|
92
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Event mode');
|
|
93
|
+
h.result({path:'/test.md',id:'two',revisionId:'r2',contentHash:'b'.repeat(64),
|
|
94
|
+
compiled:{children:[]},review:{delivery:'text'}});
|
|
95
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Event mode · unavailable');
|
|
96
|
+
});
|
|
82
97
|
it('retries ui/message delivery errors and never reports success before delivery',async()=>{
|
|
83
98
|
let failed=0;const h=harness(undefined,undefined,(m)=>{if(m.method==='ui/message'&&failed++<2)return {rpcError:{message:'temporary delivery failure'}};return {content:[]};});
|
|
84
99
|
h.result({id:'retry',revisionId:'retry-r1',contentHash:'c'.repeat(64),path:'/retry.md',compiled:{children:[]}});
|
|
@@ -97,7 +112,6 @@ describe('MCP Remotion bridge',()=>{
|
|
|
97
112
|
a.nodes.changes.onclick?.();
|
|
98
113
|
expect(a.nodes.status.textContent).toBe('Feedback is required.');
|
|
99
114
|
expect(a.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
100
|
-
a.selectSpot(0);
|
|
101
115
|
a.nodes.feedback.value='Shorten the opening';
|
|
102
116
|
a.nodes['save-spot'].onclick?.();
|
|
103
117
|
a.nodes.changes.onclick?.();
|
|
@@ -137,7 +151,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
137
151
|
const h=harness();
|
|
138
152
|
const relay={jobId:'job-7',taskId:19,executionId:'exec-1'};
|
|
139
153
|
h.result({id:'r',revisionId:'r',contentHash:'hash',path:'/video.md',relay,compiled:{children:[]}});
|
|
140
|
-
h.
|
|
154
|
+
h.nodes.feedback.value='shorter title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
141
155
|
await nextTick();
|
|
142
156
|
expect(JSON.parse(h.messages.find(m=>m.method==='ui/message').params.content[0].text).relay).toEqual(relay);
|
|
143
157
|
});
|
|
@@ -146,7 +160,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
146
160
|
const first={id:'first',revisionId:'r1',contentHash:'sha1',path:'/video.md',compiled:{children:[{name:'First'}]}};
|
|
147
161
|
const next={id:'second',revisionId:'r2',contentHash:'sha2',path:'/video.md',compiled:{children:[{name:'Next'}]}};
|
|
148
162
|
h.result(first);
|
|
149
|
-
h.
|
|
163
|
+
h.nodes.feedback.value='lowercase title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
150
164
|
expect(JSON.parse(h.messages.find(m=>m.method==='ui/message').params.content[0].text)).toMatchObject({decision:'changes_requested'});
|
|
151
165
|
await nextTick();
|
|
152
166
|
h.respond(3);await nextTick();
|
|
@@ -163,36 +177,37 @@ describe('MCP Remotion bridge',()=>{
|
|
|
163
177
|
});
|
|
164
178
|
|
|
165
179
|
|
|
166
|
-
it('
|
|
180
|
+
it('preselects Overall by default, with no extra comment-count row',()=>{
|
|
167
181
|
const h=harness();
|
|
168
182
|
expect(h.nodes['comment-mode'].value).toBe('spot');
|
|
169
|
-
h.selectSpot(0);
|
|
170
183
|
expect(h.nodes['comment-mode'].hidden).toBe(true);
|
|
184
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Text mode');
|
|
171
185
|
expect(h.nodes['overall-mode'].hidden).toBe(false);
|
|
172
186
|
expect(h.nodes['remove-spot'].disabled).toBe(true);
|
|
173
187
|
h.nodes.feedback.value='Overall note';h.nodes['save-spot'].onclick?.();
|
|
174
188
|
let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
175
189
|
expect(dots.filter((x:any)=>x.scope==='overall')).toHaveLength(1);
|
|
176
190
|
expect(dots[0].placeholder).toBeUndefined();
|
|
177
|
-
h.
|
|
191
|
+
h.nodes['remove-spot'].onclick?.();
|
|
178
192
|
dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
179
193
|
expect(dots[0]).toMatchObject({id:0,scope:'overall',placeholder:true});
|
|
180
194
|
});
|
|
181
|
-
it('toggles
|
|
195
|
+
it('toggles default Overall marker off and back on',()=>{
|
|
182
196
|
const h=harness();
|
|
183
|
-
h.selectSpot(0);
|
|
184
|
-
let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
185
|
-
expect(dots[0].selected).toBe(true);
|
|
186
197
|
expect(h.nodes['overall-mode'].hidden).toBe(false);
|
|
187
198
|
h.selectSpot(0);
|
|
188
|
-
dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
199
|
+
let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
189
200
|
expect(dots[0].selected).toBe(false);
|
|
190
201
|
expect(h.nodes['comment-mode'].hidden).toBe(false);
|
|
191
202
|
expect(h.nodes['overall-mode'].hidden).toBe(true);
|
|
192
203
|
expect(h.nodes.feedback.value).toBe('');
|
|
204
|
+
h.selectSpot(0);
|
|
205
|
+
expect(h.nodes['overall-mode'].hidden).toBe(false);
|
|
206
|
+
expect(h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots[0].selected).toBe(true);
|
|
193
207
|
});
|
|
194
208
|
it('auto-saves edits and new overall drafts when switching marker selection',()=>{
|
|
195
209
|
const h=harness();
|
|
210
|
+
h.selectSpot(0); // Leave default Overall to create timeline-specific spots.
|
|
196
211
|
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:0,timeSeconds:0});
|
|
197
212
|
h.nodes.feedback.value='First spot';h.nodes['save-spot'].onclick?.();
|
|
198
213
|
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:0,timeSeconds:5});
|
|
@@ -215,8 +230,8 @@ describe('MCP Remotion bridge',()=>{
|
|
|
215
230
|
});
|
|
216
231
|
it('saves overall, scene and spot scopes at their canonical timeline positions',async()=>{
|
|
217
232
|
const h=harness();h.result({id:'multi',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
218
|
-
h.selectSpot(0);
|
|
219
233
|
h.nodes.feedback.value='Improve pacing';h.nodes['save-spot'].onclick?.();
|
|
234
|
+
h.selectSpot(0); // Deselect Overall before creating scene/spot comments.
|
|
220
235
|
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:3,timeSeconds:4});
|
|
221
236
|
h.nodes['comment-mode'].value='scene';
|
|
222
237
|
h.nodes.feedback.value='Improve intro';h.nodes['save-spot'].onclick?.();
|
|
@@ -233,6 +248,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
233
248
|
});
|
|
234
249
|
it('supports multiple timed notes on one scene and restores a saved note',async()=>{
|
|
235
250
|
const h=harness();
|
|
251
|
+
h.selectSpot(0);
|
|
236
252
|
h.result({id:'spots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
237
253
|
h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
|
|
238
254
|
h.nodes.feedback.value='Trim opening';
|
|
@@ -253,27 +269,24 @@ describe('MCP Remotion bridge',()=>{
|
|
|
253
269
|
await nextTick();
|
|
254
270
|
const payload=JSON.parse(h.messages.at(-1).params.content[0].text);
|
|
255
271
|
expect(payload.comments).toHaveLength(2);
|
|
256
|
-
expect(h.nodes['comment-count'].textContent).toBe('2 comments');
|
|
257
272
|
expect(payload.comments.map((x:any)=>x.text)).toContain('Trim first second');
|
|
258
273
|
expect(payload.comments.map((x:any)=>x.text)).toContain('Keep reaction');
|
|
259
274
|
});
|
|
260
|
-
it('
|
|
275
|
+
it('submits typed unsaved text immediately as Overall feedback without an extra plus click',async()=>{
|
|
261
276
|
const h=harness();h.result({id:'draft',revisionId:'r',contentHash:'hash',compiled:{children:[]}});
|
|
262
|
-
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:2,timeSeconds:3});
|
|
263
277
|
h.nodes.feedback.value='Keep this text';
|
|
264
|
-
h.nodes['comment-mode'].value='scene';h.nodes['comment-mode'].onchange?.();
|
|
265
|
-
expect(h.nodes.feedback.value).toBe('Keep this text');
|
|
266
|
-
h.nodes.changes.onclick?.();
|
|
267
|
-
expect(h.nodes.status.textContent).toContain('Add or remove');
|
|
268
|
-
h.nodes['save-spot'].onclick?.();
|
|
269
|
-
const note=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots.find((x:any)=>!x.placeholder);
|
|
270
|
-
h.selectSpot(note.id);
|
|
271
278
|
h.nodes.changes.onclick?.();
|
|
272
279
|
await nextTick();
|
|
273
|
-
|
|
280
|
+
const sent=h.messages.filter(m=>m.method==='ui/message');
|
|
281
|
+
expect(sent).toHaveLength(1);
|
|
282
|
+
expect(JSON.parse(sent[0].params.content[0].text)).toMatchObject({
|
|
283
|
+
decision:'changes_requested',feedback:'Keep this text',comments:[{scope:'overall',text:'Keep this text'}]
|
|
284
|
+
});
|
|
285
|
+
expect(h.nodes.status.textContent).not.toContain('Add or remove');
|
|
274
286
|
});
|
|
275
287
|
it('deletes only the selected timeline marker',async()=>{
|
|
276
|
-
const h=harness();
|
|
288
|
+
const h=harness();
|
|
289
|
+
h.selectSpot(0);h.result({id:'dots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
277
290
|
h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
|
|
278
291
|
h.nodes.feedback.value='First';h.nodes['save-spot'].onclick?.();
|
|
279
292
|
h.scene({sceneId:'s2',sceneName:'Scene-B',timeSeconds:3});
|
|
@@ -364,10 +377,10 @@ describe('Review event delivery',()=>{
|
|
|
364
377
|
const template={type:'task.interactive_decision',
|
|
365
378
|
source:'job/551/task/producer/execution/e1',data:{interactive:{jobId:'551',taskId:'producer',executionId:'e1',invocationId:'review-551'},purpose:'video'}};
|
|
366
379
|
const media={id:'video1',requestId:'d9b2006a-0618-45aa-a3d8-31363fa629ca',revisionId:'rv1',
|
|
367
|
-
contentHash:'a'.repeat(64),path:'/tmp/video.md',compiled:{children:[]},review:{delivery:'event',eventTemplate:template}};
|
|
380
|
+
contentHash:'a'.repeat(64),path:'/tmp/video.md',compiled:{children:[]},review:{delivery:'event',commitSha:'c'.repeat(40),eventTemplate:template}};
|
|
368
381
|
it('does not publish until explicit Submit, preserves fixed envelope and scoped comments',async()=>{
|
|
369
382
|
const h=harness(undefined,undefined, m=> m.method==='tools/call'?{published:true,event:{event_id:'ack'}}:undefined);
|
|
370
|
-
h.result(media);h.scene({sceneId:'intro',timeSeconds:2.25,sceneStart:0});
|
|
383
|
+
h.result(media);h.selectSpot(0);h.scene({sceneId:'intro',timeSeconds:2.25,sceneStart:0});
|
|
371
384
|
h.nodes.feedback.value='Trim opening';h.nodes['save-spot'].onclick?.();
|
|
372
385
|
expect(h.messages.filter(m=>m.method==='tools/call')).toHaveLength(0);
|
|
373
386
|
h.nodes.changes.onclick?.();await nextTick();
|
|
@@ -376,7 +389,7 @@ describe('Review event delivery',()=>{
|
|
|
376
389
|
expect(calls[0]).toMatchObject({params:{name:'events',arguments:{command:'publish',
|
|
377
390
|
args:{type:template.type,source:template.source,data:{purpose:'video',
|
|
378
391
|
interactive:{jobId:'551',taskId:'producer',executionId:'e1',invocationId:'review-551',
|
|
379
|
-
requestId:media.requestId,
|
|
392
|
+
requestId:media.requestId,revision:'c'.repeat(40),commitSha:'c'.repeat(40),
|
|
380
393
|
decision:'changes_requested',feedback:'Trim opening',comments:[{sceneId:'intro',timeSeconds:2.25,text:'Trim opening'}]}}}}}});
|
|
381
394
|
expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
382
395
|
expect(h.nodes.status.textContent).toContain('submitted');
|
|
@@ -3,7 +3,8 @@ import {normalizeReviewConfig,eventForReview} from '../src/mcp/review-delivery.m
|
|
|
3
3
|
|
|
4
4
|
const template={type:'task.interactive_decision',source:'job/j1/task/t1/execution/e1',
|
|
5
5
|
data:{interactive:{jobId:'j1',taskId:'t1',executionId:'e1',invocationId:'review-r1'},meta:{source:'ok'}}};
|
|
6
|
-
const
|
|
6
|
+
const sha='c'.repeat(40);
|
|
7
|
+
const review={requestId:'r1',previewId:'p1',commitSha:sha,
|
|
7
8
|
decision:'changes_requested',comments:[{sceneId:'intro',timeSeconds:3.2,text:'Shorter intro'}],idempotencyKey:'key1'};
|
|
8
9
|
|
|
9
10
|
describe('Provider-bound preview delivery',()=>{
|
|
@@ -22,22 +23,22 @@ describe('Provider-bound preview delivery',()=>{
|
|
|
22
23
|
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
23
24
|
data:{interactive:{...template.data.interactive,taskId:'forged'}}}})).toThrow();
|
|
24
25
|
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
25
|
-
data:{interactive:{...template.data.interactive,revision:
|
|
26
|
+
data:{interactive:{...template.data.interactive,revision:sha}}}})).toThrow();
|
|
26
27
|
});
|
|
27
28
|
it('freezes caller-owned identity and fills only data.interactive fields on human submit',()=>{
|
|
28
|
-
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
29
|
+
const config=normalizeReviewConfig({delivery:'event',commitSha:sha,eventTemplate:template});
|
|
29
30
|
template.data.meta.source='changed after validation';
|
|
30
31
|
const event=eventForReview(config,review);
|
|
31
32
|
expect(event).toMatchObject({type:'task.interactive_decision',source:template.source,
|
|
32
33
|
data:{meta:{source:'ok'},interactive:{jobId:'j1',taskId:'t1',executionId:'e1',
|
|
33
|
-
invocationId:'review-r1',revision:
|
|
34
|
+
invocationId:'review-r1',revision:sha,commitSha:sha,
|
|
34
35
|
decision:'changes_requested',feedback:'Shorter intro',comments:review.comments,
|
|
35
36
|
idempotencyKey:'key1'}}});
|
|
36
37
|
expect(template.data.interactive).not.toHaveProperty('decision');
|
|
37
38
|
});
|
|
38
39
|
it('refuses malformed review identity or unauthorized decision',()=>{
|
|
39
|
-
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
40
|
-
expect(()=>eventForReview(config,{...review,
|
|
40
|
+
const config=normalizeReviewConfig({delivery:'event',commitSha:sha,eventTemplate:template});
|
|
41
|
+
expect(()=>eventForReview(config,{...review,commitSha:'bogus'})).toThrow();
|
|
41
42
|
expect(()=>eventForReview(config,{...review,decision:'task.completed'})).toThrow();
|
|
42
43
|
});
|
|
43
44
|
});
|
|
@@ -5,6 +5,7 @@ import {buildPreviewBridgeScript} from '../src/mcp/bridge.mjs';
|
|
|
5
5
|
import {mkdtemp,writeFile,rm} from 'node:fs/promises';
|
|
6
6
|
import {tmpdir} from 'node:os';
|
|
7
7
|
import {join} from 'node:path';
|
|
8
|
+
import {readFileSync} from 'node:fs';
|
|
8
9
|
describe('Markcut Remotion MCP App',()=>{
|
|
9
10
|
it('requires absolute Markdown path',()=>{expect(()=>validateMarkdownPath('a.md')).toThrow(/absolute/);expect(()=>validateMarkdownPath('/tmp/a.txt')).toThrow(/Markdown/);});
|
|
10
11
|
it('loads the React Remotion bundle from remote HTTPS',()=>{
|
|
@@ -16,6 +17,12 @@ describe('Markcut Remotion MCP App',()=>{
|
|
|
16
17
|
expect(html).toContain('<textarea id="feedback" rows="3"');
|
|
17
18
|
expect(html).toContain('id="comment-tools"');
|
|
18
19
|
expect(html).toContain('id="overall-mode" hidden>Overall');
|
|
20
|
+
expect(html).toContain('id="review-delivery-mode"');
|
|
21
|
+
expect(html).toContain('Text mode');
|
|
22
|
+
expect(html).toContain('Submit feedback');
|
|
23
|
+
expect(html).not.toContain('Submit all feedback');
|
|
24
|
+
expect(html).not.toContain('id="comment-count"');
|
|
25
|
+
expect(html).not.toContain('Add or remove the current comment before submitting.');
|
|
19
26
|
expect(html).not.toContain('<option value="overall"');
|
|
20
27
|
expect(html).toContain('#comment-tools>*{width:30px;height:28px;padding:0;border:0');
|
|
21
28
|
expect(html).toContain('https://neoy.example.test/files/_neoy/markcut/player/');
|
|
@@ -27,6 +34,13 @@ describe('Markcut Remotion MCP App',()=>{
|
|
|
27
34
|
expect(html).not.toContain('127.0.0.1');
|
|
28
35
|
expect(html).not.toContain('src="/player.js"');
|
|
29
36
|
});
|
|
37
|
+
it('omits the developer BGM decode-status row while preserving Web Audio playback',()=>{
|
|
38
|
+
const renderer=readFileSync(new URL('../src/mcp/remotion-app.tsx',import.meta.url),'utf8');
|
|
39
|
+
const audio=readFileSync(new URL('../src/mcp/web-audio-preview.ts',import.meta.url),'utf8');
|
|
40
|
+
expect(renderer).not.toContain('id="preview-audio-status"');
|
|
41
|
+
expect(audio).toContain('ctx.decodeAudioData(bytes)');
|
|
42
|
+
expect(audio).toContain("p.addEventListener('play',play)");
|
|
43
|
+
});
|
|
30
44
|
it('registers latest resource at startup and aliases previous URIs',()=>{
|
|
31
45
|
for(const uri of [RESOURCE_URI,...LEGACY_RESOURCE_URIS]){
|
|
32
46
|
const result=buildPreviewResourceResult(uri);
|
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
import {describe,it,expect} from 'vitest';
|
|
2
|
-
import {parseEventPreviewOptions} from '../src/mcp/mobile-review-cli.mjs';
|
|
2
|
+
import {parseEventPreviewOptions,neoReviewEndpoint,buildReviewRequest,submitNeoReview} from '../src/mcp/mobile-review-cli.mjs';
|
|
3
3
|
|
|
4
4
|
describe('Standalone Markcut CLI preview (notification belongs to Neo)',()=>{
|
|
5
5
|
it('accepts externally supplied event templates without a phone or APNs URL',()=>{
|
|
6
|
-
expect(parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','template.json']).delivery).toBe('event');
|
|
6
|
+
expect(parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','template.json','--commit-sha','a'.repeat(40)]).delivery).toBe('event');
|
|
7
7
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','event'])).toThrow();
|
|
8
8
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','a','--phone-url','http://phone'])).toThrow();
|
|
9
9
|
expect(parseEventPreviewOptions(['preview','video.md','--delivery','text']).delivery).toBe('text');
|
|
10
10
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','text','--event-template','a'])).toThrow();
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
describe('Neo-owned REST notification from standalone CLI',()=>{
|
|
15
|
+
const id='82ba2e6c-6432-4ecd-83ee-cb78ba87c668';
|
|
16
|
+
const hash='f'.repeat(64);
|
|
17
|
+
const options={file:'/tmp/preview.md'};
|
|
18
|
+
const eventOptions={...options,commitSha:'a'.repeat(40)};
|
|
19
|
+
const state={result:{id:'preview-123',contentHash:hash,revisionId:'revision-123'}};
|
|
20
|
+
it('builds a durable, immutable text request for phone view-only sync',()=>{
|
|
21
|
+
const request=buildReviewRequest(options,{delivery:'text'},state,id);
|
|
22
|
+
expect(request).toMatchObject({id,contentHash:hash,revisionId:'revision-123',
|
|
23
|
+
previewId:'preview-123',title:'preview',delivery:'text',groupId:'/tmp/preview.md'});
|
|
24
|
+
});
|
|
25
|
+
it('uses exact caller-bound template for Relay event review',()=>{
|
|
26
|
+
const template={type:'task.interactive_decision',source:'job/12/task/prod/execution/ex1',
|
|
27
|
+
data:{interactive:{jobId:'12',taskId:'prod',executionId:'ex1',invocationId:'i1'}}};
|
|
28
|
+
const request=buildReviewRequest(eventOptions,{delivery:'event',eventTemplate:template},state,id);
|
|
29
|
+
expect(request).toMatchObject({id,commitSha:eventOptions.commitSha,mediaHash:hash,eventTemplate:template,jobId:'12',groupId:'job/12/task/prod'});
|
|
30
|
+
expect(request).not.toHaveProperty('revisionId');expect(request).not.toHaveProperty('contentHash');
|
|
31
|
+
});
|
|
32
|
+
it('POSTs to local Neo Core REST and requires persisted matching ACK',async()=>{
|
|
33
|
+
const request=buildReviewRequest(options,{delivery:'text'},state,id);
|
|
34
|
+
const seen:any[]=[];
|
|
35
|
+
const fetchImpl=async (url:string,init:any)=>{
|
|
36
|
+
seen.push({url,init});return {ok:true,json:async()=>({stored:true,requestId:id,accepted:false})};
|
|
37
|
+
};
|
|
38
|
+
const receipt=await submitNeoReview(request,{url:'http://127.0.0.1:6767/mobile/review/notify',fetchImpl} as any);
|
|
39
|
+
expect(receipt.stored).toBe(true);
|
|
40
|
+
expect(seen[0].init.method).toBe('POST');
|
|
41
|
+
expect(JSON.parse(seen[0].init.body)).toEqual(request);
|
|
42
|
+
expect(seen[0].init.headers['Content-Type']).toBe('application/json');
|
|
43
|
+
await expect(submitNeoReview(request,{url:'http://127.0.0.1:6767/mobile/review/notify',fetchImpl:async()=>({ok:true,json:async()=>({stored:false,requestId:id})})} as any)).rejects.toThrow('acknowledge');
|
|
44
|
+
await expect(submitNeoReview(request,{url:'http://127.0.0.1:6767/mobile/review/notify',fetchImpl:async()=>({ok:false,status:403})} as any)).rejects.toThrow('403');
|
|
45
|
+
});
|
|
46
|
+
it('rejects delivery to remote origins and non-review routes',async()=>{
|
|
47
|
+
expect(()=>neoReviewEndpoint('https://evil.example/mobile/review/notify')).toThrow('local REST');
|
|
48
|
+
await expect(submitNeoReview({id} as any,{url:'http://127.0.0.1:6767/mcp'})).rejects.toThrow('nonlocal');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {afterEach,describe,expect,it} from 'vitest';
|
|
2
|
+
import {execFileSync} from 'node:child_process';
|
|
3
|
+
import {createHash} from 'node:crypto';
|
|
4
|
+
import {existsSync,mkdtempSync,readFileSync,rmSync} from 'node:fs';
|
|
5
|
+
import {tmpdir} from 'node:os';
|
|
6
|
+
import {join} from 'node:path';
|
|
7
|
+
import {main} from '../src/vision/cli.mjs';
|
|
8
|
+
|
|
9
|
+
const roots:string[]=[];
|
|
10
|
+
const probe=(file:string)=>JSON.parse(execFileSync('ffprobe',[
|
|
11
|
+
'-v','error','-show_entries','stream=codec_name,codec_type,width,height:format=duration:format_tags',
|
|
12
|
+
'-of','json',file],{encoding:'utf8'}));
|
|
13
|
+
const hash=(f:string)=>createHash('sha256').update(readFileSync(f)).digest('hex');
|
|
14
|
+
afterEach(()=>{for(const p of roots.splice(0))rmSync(p,{recursive:true,force:true});});
|
|
15
|
+
|
|
16
|
+
describe('Markcut Vision native normalization-only mode',()=>{
|
|
17
|
+
it('normalizes images and video for understanding without touching originals or running AI',async()=>{
|
|
18
|
+
const dir=mkdtempSync(join(tmpdir(),'markcut-vision-tiny-'));roots.push(dir);
|
|
19
|
+
const inputVideo=join(dir,'source.mov'),inputImage=join(dir,'photo.png');
|
|
20
|
+
execFileSync('ffmpeg',['-hide_banner','-loglevel','error','-y',
|
|
21
|
+
'-f','lavfi','-i','testsrc2=size=1600x900:duration=2:rate=10',
|
|
22
|
+
'-f','lavfi','-i','sine=frequency=440:duration=2',
|
|
23
|
+
'-metadata','location=+45.5000-075.7500/',
|
|
24
|
+
'-c:v','libx264','-preset','ultrafast','-crf','18','-c:a','aac','-shortest',inputVideo]);
|
|
25
|
+
execFileSync('ffmpeg',['-hide_banner','-loglevel','error','-y',
|
|
26
|
+
'-f','lavfi','-i','color=c=blue:s=1600x900:d=1','-frames:v','1',inputImage]);
|
|
27
|
+
const before=[hash(inputVideo),hash(inputImage)];
|
|
28
|
+
let text='';const old=console.log;
|
|
29
|
+
console.log=(value:unknown)=>{text+=String(value)+'\n';};
|
|
30
|
+
try{await main(['node','cli.mjs','vision',dir,'--normalize-only']);}
|
|
31
|
+
finally{console.log=old;}
|
|
32
|
+
const result=JSON.parse(text.trim().split('\n').at(-1)!);
|
|
33
|
+
expect(result).toMatchObject({status:'PASS',profile:'markcut-vision-normalized-v1',usage:'vision-understanding-only'});
|
|
34
|
+
expect(result.files).toHaveLength(2);
|
|
35
|
+
const videos=result.files.filter((x:{kind:string})=>x.kind==='video');
|
|
36
|
+
const images=result.files.filter((x:{kind:string})=>x.kind==='image');
|
|
37
|
+
expect(videos).toHaveLength(1);expect(images).toHaveLength(1);
|
|
38
|
+
expect(videos[0].sampled).toBe(false);
|
|
39
|
+
expect(videos[0].sourceDurationSeconds).toBeGreaterThanOrEqual(1.9);
|
|
40
|
+
for(const item of result.files){
|
|
41
|
+
expect(existsSync(item.path)).toBe(true);
|
|
42
|
+
expect(item.path).toContain('/.normalized/');
|
|
43
|
+
const metadata=probe(item.path),stream=metadata.streams.find((x:{codec_type:string})=>x.codec_type==='video');
|
|
44
|
+
expect(Math.max(stream.width,stream.height)).toBeLessThanOrEqual(item.maxDimension);
|
|
45
|
+
expect(JSON.stringify(metadata.format?.tags||{}).toLowerCase()).not.toContain('location');
|
|
46
|
+
if(item.kind==='video'){
|
|
47
|
+
expect(stream.codec_name).toBe('h264');
|
|
48
|
+
expect(metadata.streams.some((x:{codec_type:string})=>x.codec_type==='audio')).toBe(true);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
expect([hash(inputVideo),hash(inputImage)]).toEqual(before);
|
|
52
|
+
// Native cache is re-usable with the same source filenames.
|
|
53
|
+
const t=JSON.parse(text.trim()); expect(t.files.length).toBe(2);
|
|
54
|
+
});
|
|
55
|
+
});
|