@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.
- package/README.md +20 -4
- package/bin/markcut +10 -0
- package/docs/developer-reference.md +41 -1
- package/package.json +8 -2
- package/recipes/markcut/map-cinematic-follow.json +17 -0
- package/recipes/markcut/map-location-reveal.json +17 -0
- package/recipes/markcut/map-route-journey.json +18 -0
- package/recipes/markcut/map-streetview-explore.json +17 -0
- package/skills/markcut/SKILL.md +5 -1
- package/skills/markcut/docs/markdown-descriptive.md +68 -1
- package/skills/markcut/docs/recipes.md +45 -0
- package/skills/markcut/references/mobile-event-preview-cli.md +9 -5
- package/src/descriptive/compiler.ts +38 -2
- package/src/descriptive/markdown.ts +30 -0
- package/src/descriptive/model3d.test.ts +38 -0
- package/src/editor-decision/cli.mjs +21 -0
- package/src/editor-decision/editor-decision.schema.json +41 -0
- package/src/editor-decision/index.mjs +115 -0
- package/src/editor-decision/index.test.mjs +63 -0
- package/src/mcp/bridge.mjs +46 -9
- package/src/mcp/compile-worker.mjs +2 -2
- package/src/mcp/mobile-review-cli.mjs +40 -33
- package/src/mcp/preview-mobile.css +21 -8
- package/src/mcp/preview.mjs +95 -57
- package/src/mcp/remote-assets.mjs +85 -7
- package/src/mcp/remotion-app.bundle.js +5013 -1117
- package/src/mcp/remotion-app.tsx +117 -10
- package/src/mcp/server.mjs +4 -2
- package/src/player/browser.tsx +1 -3
- package/src/player/bundle/player.js +73054 -17357
- package/src/player/components/HeaderBar.tsx +3 -1
- package/src/player/components/VariantBar.tsx +20 -21
- package/src/player/pipeline.mjs +133 -77
- package/src/player/server.mjs +43 -23
- package/src/recipes/catalog.mjs +115 -0
- package/src/recipes/cli.mjs +87 -0
- package/src/render/cli.mjs +38 -1
- package/src/schema/index.ts +21 -0
- package/src/types/Folder.tsx +2 -0
- package/src/types/Model3D.tsx +91 -0
- package/src/vision/cli.mjs +63 -50
- package/tests/mcp-editor-decisions-mobile.test.ts +35 -0
- package/tests/mcp-preview-bridge.test.ts +44 -3
- package/tests/mcp-preview-proxy-version.test.mjs +80 -0
- package/tests/mcp-preview.test.ts +41 -8
- package/tests/mcp-remote-assets.test.ts +17 -0
- package/tests/mcp-static-preview.test.ts +1 -1
- package/tests/mcp-video-selector.test.ts +55 -0
- package/tests/mobile-preview-cli.test.ts +10 -15
- package/tests/recipes-catalog.test.ts +141 -0
- package/tests/vision-generic-vtt-hooks.test.ts +7 -7
- package/tests/vision-normalized-metadata.test.ts +23 -0
package/src/player/server.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { isDescriptiveRoot, resolveAndCompile, resolveAndCompileMarkdown, parseI
|
|
|
18
18
|
import { bundleFromEntries } from "./bundler.mjs";
|
|
19
19
|
import { extractScenes, MIME, serveFile, handleShutdown } from "./server-shared.mjs";
|
|
20
20
|
import { DEFAULT_EDIT_CLI, DEFAULT_STT_CLI, GOOGLE_MAPS_API_KEY } from "../config.mjs";
|
|
21
|
+
import {loadEditorDecision,editorDecisionToMarkdown} from "../editor-decision/index.mjs";
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -74,6 +75,12 @@ function parseVariantConfigs() {
|
|
|
74
75
|
}));
|
|
75
76
|
}
|
|
76
77
|
const VARIANT_CONFIGS = parseVariantConfigs();
|
|
78
|
+
let editorSidecar=IS_MARKDOWN?loadEditorDecision(VIDEO_JSON):null;
|
|
79
|
+
if (editorSidecar) {
|
|
80
|
+
if (!VARIANT_CONFIGS.some(c=>c.label==="default")) VARIANT_CONFIGS.unshift({label:"default",chain:[]});
|
|
81
|
+
if (VARIANT_CONFIGS.some(c=>c.label==="editor-decisions")) throw Error("Reserved variant name: editor-decisions");
|
|
82
|
+
VARIANT_CONFIGS.push({label:"editor-decisions",chain:[]});
|
|
83
|
+
}
|
|
77
84
|
|
|
78
85
|
// ─── SSE clients for reload notifications ────────────────────────────────
|
|
79
86
|
const sseClients = new Set();
|
|
@@ -423,6 +430,11 @@ async function compileVariant(config, parsed, raw) {
|
|
|
423
430
|
|
|
424
431
|
if (IS_MARKDOWN) {
|
|
425
432
|
let descriptive = parsed.base;
|
|
433
|
+
if (config.label === "editor-decisions") {
|
|
434
|
+
if (!editorSidecar) throw Error("No Editor Decisions found for this video");
|
|
435
|
+
const {parseMarkdownDescriptive}=await import("./pipeline.mjs");
|
|
436
|
+
descriptive=parseMarkdownDescriptive(editorDecisionToMarkdown(VIDEO_JSON,editorSidecar.edl,raw));
|
|
437
|
+
}
|
|
426
438
|
|
|
427
439
|
if (config.chain.length > 0) {
|
|
428
440
|
// Merge root config from the first variant's section
|
|
@@ -520,6 +532,7 @@ async function compileVariant(config, parsed, raw) {
|
|
|
520
532
|
*/
|
|
521
533
|
async function compileAllVariants() {
|
|
522
534
|
const raw = readFileSync(VIDEO_JSON, "utf-8");
|
|
535
|
+
if (IS_MARKDOWN) editorSidecar=loadEditorDecision(VIDEO_JSON,raw);
|
|
523
536
|
let markdownParsed = null;
|
|
524
537
|
|
|
525
538
|
console.log(` 📄 ${VIDEO_JSON.split("/").pop()}`);
|
|
@@ -528,6 +541,19 @@ async function compileAllVariants() {
|
|
|
528
541
|
if (IS_MARKDOWN) {
|
|
529
542
|
const { parseMarkdownVariants } = await import("./pipeline.mjs");
|
|
530
543
|
markdownParsed = parseMarkdownVariants(raw);
|
|
544
|
+
// With no explicit --variant selection, show every authored video in the
|
|
545
|
+
// top-right selector. Explicit CLI variant flags retain their old scope.
|
|
546
|
+
const explicitVariants=process.argv.some(arg=>arg==="--variant"||arg.startsWith("--variant="));
|
|
547
|
+
if(!explicitVariants){
|
|
548
|
+
for(const label of markdownParsed.variants.keys()){
|
|
549
|
+
if(!/^[\p{L}\p{N}][\p{L}\p{N}_-]{0,63}$/u.test(label))continue;
|
|
550
|
+
if(["default","editor-decisions","__proto__","constructor","prototype"].includes(label))
|
|
551
|
+
throw Error("Reserved Markcut video variant name: "+label);
|
|
552
|
+
if(VARIANT_CONFIGS.some(config=>config.label===label))continue;
|
|
553
|
+
const at=VARIANT_CONFIGS.findIndex(config=>config.label==="editor-decisions");
|
|
554
|
+
VARIANT_CONFIGS.splice(at<0?VARIANT_CONFIGS.length:at,0,{label,chain:label.split("-")});
|
|
555
|
+
}
|
|
556
|
+
}
|
|
531
557
|
}
|
|
532
558
|
|
|
533
559
|
for (const config of VARIANT_CONFIGS) {
|
|
@@ -669,33 +695,31 @@ const initScenesPromise = compileAndExtractScenes();
|
|
|
669
695
|
|
|
670
696
|
// ─── Watch source file for changes (all modes) ──────────────────────────
|
|
671
697
|
let lastContent = readFileSync(VIDEO_JSON, "utf-8");
|
|
672
|
-
|
|
673
|
-
if (curr.mtimeMs === prev.mtimeMs) return;
|
|
698
|
+
async function recompileAfterChange() {
|
|
674
699
|
if (pipelineRunning) return;
|
|
675
|
-
const newContent = readFileSync(VIDEO_JSON, "utf-8");
|
|
676
|
-
if (newContent === lastContent) return;
|
|
677
|
-
lastContent = newContent;
|
|
678
700
|
pipelineRunning = true;
|
|
679
|
-
console.log(` 📁 ${VIDEO_JSON} changed, re-running all variants...`);
|
|
680
|
-
|
|
681
701
|
try {
|
|
682
702
|
compiledRootCache.clear();
|
|
683
703
|
scenesCache.clear();
|
|
684
704
|
await compileAllVariants();
|
|
685
|
-
|
|
686
705
|
for (const config of VARIANT_CONFIGS) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
scenesCache.set(config.label, extractScenes(root));
|
|
690
|
-
} catch {}
|
|
706
|
+
const root=await loadCompiledRoot(config.label);
|
|
707
|
+
scenesCache.set(config.label,extractScenes(root));
|
|
691
708
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
709
|
+
ssePush({type:"reload"});
|
|
710
|
+
} catch(e) {
|
|
711
|
+
console.error(" ⚠️ Failed to re-process after change:",e.message);
|
|
712
|
+
} finally { pipelineRunning=false; }
|
|
713
|
+
}
|
|
714
|
+
if (editorSidecar) watchFile(editorSidecar.path,{interval:1000},(curr,prev)=>{
|
|
715
|
+
if(curr.mtimeMs!==prev.mtimeMs)void recompileAfterChange();
|
|
716
|
+
});
|
|
717
|
+
watchFile(VIDEO_JSON, { interval: 1000 }, async (curr, prev) => {
|
|
718
|
+
if (curr.mtimeMs === prev.mtimeMs) return;
|
|
719
|
+
const newContent = readFileSync(VIDEO_JSON, "utf-8");
|
|
720
|
+
if (newContent === lastContent) return;
|
|
721
|
+
lastContent = newContent;
|
|
722
|
+
await recompileAfterChange();
|
|
699
723
|
});
|
|
700
724
|
// ─── MIME imported from ./server-shared.mjs ──────────────────────────────
|
|
701
725
|
|
|
@@ -763,10 +787,6 @@ function getHtml(variantLabel) {
|
|
|
763
787
|
#header-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
|
|
764
788
|
#close-btn { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.3); color: rgba(255,255,255,.4); font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; }
|
|
765
789
|
#close-btn:hover { background: rgba(255,60,60,.4); border-color: rgba(255,60,60,.5); color: #fff; }
|
|
766
|
-
#variant-bar { display: flex; gap: 4px; align-items: center; width: 100%; max-width: 500px; padding: 6px 12px; flex-shrink: 0; overflow-x: auto; }
|
|
767
|
-
.variant-link { font-size: 11px; padding: 3px 10px; border-radius: 12px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.4); text-decoration: none; white-space: nowrap; transition: all .15s; }
|
|
768
|
-
.variant-link:hover { background: rgba(255,255,255,.12); color: rgba(255,255,255,.7); }
|
|
769
|
-
.variant-link.active { background: rgba(74,158,255,.2); color: #4a9eff; }
|
|
770
790
|
#player-frame { flex: 1; width: 100%; max-width: 480px; min-height: 0; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); background: #000; box-shadow: 0 4px 40px rgba(0,0,0,.6); margin: 0 12px; position: relative; }
|
|
771
791
|
#root { width: 100%; height: 100%; }
|
|
772
792
|
#reload-toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(74,158,255,.9); color: #fff; padding: 12px 24px; border-radius: 10px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 200; backdrop-filter: blur(8px); }
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only recipe catalog. Markcut owns executable recipes under recipes/markcut.
|
|
3
|
+
* Video Shotcraft owns its gallery and shot card documents; we read the installed
|
|
4
|
+
* Skill in place without copying it into Markcut or treating its demos as native DSL.
|
|
5
|
+
*/
|
|
6
|
+
import {existsSync, readFileSync, readdirSync, realpathSync} from 'node:fs';
|
|
7
|
+
import {homedir} from 'node:os';
|
|
8
|
+
import {isAbsolute, join, relative, resolve, sep} from 'node:path';
|
|
9
|
+
import {fileURLToPath} from 'node:url';
|
|
10
|
+
|
|
11
|
+
const MARKCUT_RECIPE_DIR = fileURLToPath(new URL('../../recipes/markcut/',import.meta.url));
|
|
12
|
+
const SHOTCRAFT_LIBRARY = join('gallery','api','library.json');
|
|
13
|
+
const RECIPE_NAME = /^[a-z0-9][a-z0-9-]{1,90}$/;
|
|
14
|
+
|
|
15
|
+
function within(root, path) {
|
|
16
|
+
const rel=relative(root,path);
|
|
17
|
+
return rel === '' || (rel !== '..' && !rel.startsWith('..'+sep) && !isAbsolute(rel));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Find the external Skill without requiring Neo or silently installing anything. */
|
|
21
|
+
export function findShotcraftSkillRoot({env=process.env,home=homedir()}={}) {
|
|
22
|
+
const explicit=env.MARKCUT_SHOTCRAFT_SKILL_DIR || env.VIDEO_SHOTCRAFT_ROOT;
|
|
23
|
+
const candidates=explicit?[explicit]:[
|
|
24
|
+
join(home,'.agents','skills','video-shotcraft'),
|
|
25
|
+
join(home,'.codex','skills','video-shotcraft'),
|
|
26
|
+
join(home,'.claude','skills','video-shotcraft'),
|
|
27
|
+
];
|
|
28
|
+
return candidates.map(path=>resolve(path)).find(path=>existsSync(join(path,SHOTCRAFT_LIBRARY)))||null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function markcutRecipes(dir) {
|
|
32
|
+
if(!existsSync(dir))throw new Error(`Markcut recipes directory missing: ${dir}`);
|
|
33
|
+
return readdirSync(dir).filter(x=>x.endsWith('.json')).sort().map(filename=>{
|
|
34
|
+
const file=resolve(dir,filename);
|
|
35
|
+
const item=JSON.parse(readFileSync(file,'utf8'));
|
|
36
|
+
if(!RECIPE_NAME.test(item.name)||filename!==item.name+'.json' || !item.title ||
|
|
37
|
+
!item.description || !item.category || !item.snippet || !Array.isArray(item.parameters) ||
|
|
38
|
+
(item.category==='map' && !item.view)) {
|
|
39
|
+
throw new Error(`Invalid Markcut recipe: ${file}`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
id:`markcut:${item.name}`, name:item.name, title:item.title,source:'markcut',
|
|
43
|
+
category:item.category,description:item.description,use:item.use,
|
|
44
|
+
duration:item.duration, durationSeconds:item.durationSeconds,
|
|
45
|
+
implementation:'native-markcut', executable:true,
|
|
46
|
+
view:item.view,parameters:item.parameters,snippet:item.snippet,notes:item.notes||[],
|
|
47
|
+
sourceFile:file,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function shotcraftRecipes(root) {
|
|
53
|
+
if(!root)return [];
|
|
54
|
+
const library=JSON.parse(readFileSync(join(root,SHOTCRAFT_LIBRARY),'utf8'));
|
|
55
|
+
const trustedRoot=realpathSync(root);
|
|
56
|
+
if(!Array.isArray(library.cards))throw new Error(`Invalid Shotcraft card library at ${root}`);
|
|
57
|
+
return library.cards.filter(card=>card && RECIPE_NAME.test(card.name)).map(card=>{
|
|
58
|
+
const sourceFile=typeof card.source==='string'?resolve(root,card.source):null;
|
|
59
|
+
// Never follow user-supplied gallery source references outside the Skill.
|
|
60
|
+
const safeFile=sourceFile&&within(root,sourceFile)&&existsSync(sourceFile)&&
|
|
61
|
+
within(trustedRoot,realpathSync(sourceFile))?sourceFile:null;
|
|
62
|
+
return {
|
|
63
|
+
id:`shotcraft:${card.name}`,name:card.name,title:card.name,source:'shotcraft',
|
|
64
|
+
category:card.category||'uncategorized',description:card.summary||'',use:card.use||'',
|
|
65
|
+
duration:card.duration||'',implementation:'reference-shot-card',executable:false,
|
|
66
|
+
styles:(card.styles||[]).filter(s=>s&&typeof s.key==='string').map(s=>({key:s.key,label:s.label||s.key})),
|
|
67
|
+
sourceFile:safeFile,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function loadRecipeCatalog({markcutDir=MARKCUT_RECIPE_DIR,shotcraftRoot=undefined}={}) {
|
|
73
|
+
const own=markcutRecipes(resolve(markcutDir));
|
|
74
|
+
const skillRoot=shotcraftRoot===undefined?findShotcraftSkillRoot():shotcraftRoot;
|
|
75
|
+
// A broken optional third-party Skill must not hide Markcut's own recipes.
|
|
76
|
+
let shotcraft=[], shotcraftStatus=skillRoot?'ready':'not-installed', shotcraftError=null;
|
|
77
|
+
if(skillRoot){
|
|
78
|
+
try{shotcraft=shotcraftRecipes(skillRoot);}
|
|
79
|
+
catch(e){shotcraftStatus='unavailable';shotcraftError=String(e.message||e);}
|
|
80
|
+
}
|
|
81
|
+
const recipes=[...own,...shotcraft].sort((a,b)=>a.id.localeCompare(b.id,'en'));
|
|
82
|
+
const seen=new Set();
|
|
83
|
+
for(const item of recipes){if(seen.has(item.id))throw new Error(`Duplicate recipe: ${item.id}`);seen.add(item.id);}
|
|
84
|
+
return {
|
|
85
|
+
recipes,
|
|
86
|
+
sources:{
|
|
87
|
+
markcut:{count:own.length,location:resolve(markcutDir),status:'ready'},
|
|
88
|
+
shotcraft:{count:shotcraft.length,location:skillRoot||null,status:shotcraftStatus,...(shotcraftError?{error:shotcraftError}:{})},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function filterRecipes(catalog,{source,category,query}={}) {
|
|
94
|
+
const lower=(query||'').trim().toLocaleLowerCase();
|
|
95
|
+
return catalog.recipes.filter(r=>
|
|
96
|
+
(!source||r.source===source)&&(!category||r.category===category)&&
|
|
97
|
+
(!lower||[r.id,r.title,r.description,r.use,r.category,r.view,...(r.styles||[]).map(s=>s.key)]
|
|
98
|
+
.filter(Boolean).some(v=>String(v).toLocaleLowerCase().includes(lower)))
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Explicit source prefix avoids name collisions between independent libraries. */
|
|
103
|
+
export function getRecipe(catalog,id) {
|
|
104
|
+
const found=catalog.recipes.filter(r=>r.id===id || r.name===id);
|
|
105
|
+
if(found.length>1)throw new Error(`Ambiguous recipe '${id}'; use markcut: or shotcraft: prefix.`);
|
|
106
|
+
return found[0]||null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function readRecipeDetail(recipe) {
|
|
110
|
+
if(!recipe)throw new Error('Recipe not found');
|
|
111
|
+
const guide=recipe.source==='shotcraft'&&recipe.sourceFile
|
|
112
|
+
?readFileSync(recipe.sourceFile,'utf8')
|
|
113
|
+
:null;
|
|
114
|
+
return {...recipe,...(guide?{guide}:{})};
|
|
115
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {filterRecipes,getRecipe,loadRecipeCatalog,readRecipeDetail} from './catalog.mjs';
|
|
3
|
+
import {resolve} from 'node:path';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
5
|
+
|
|
6
|
+
const HELP=`Usage: markcut recipes [list|show <recipe-id>] [options]
|
|
7
|
+
|
|
8
|
+
List Markcut-owned native recipes together with dynamically discovered video-shotcraft
|
|
9
|
+
Skill cards. Shotcraft cards are reference motions, not automatically executable
|
|
10
|
+
Markcut nodes. No Shotcraft source files are copied into Markcut.
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
--json Machine-readable JSON (includes provenance)
|
|
14
|
+
--source markcut|shotcraft
|
|
15
|
+
--category <category> e.g. map, camera, transition, typography
|
|
16
|
+
--search <query> Search recipe name, description and style variants
|
|
17
|
+
--help Show usage
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
markcut recipes list --source markcut
|
|
21
|
+
markcut recipes list --category map --json
|
|
22
|
+
markcut recipes list --source shotcraft --category camera
|
|
23
|
+
markcut recipes show markcut:map-route-journey
|
|
24
|
+
markcut recipes show shotcraft:cursor-flyover
|
|
25
|
+
|
|
26
|
+
External skill override: MARKCUT_SHOTCRAFT_SKILL_DIR=/absolute/path/to/video-shotcraft
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
function parse(argv) {
|
|
30
|
+
const out={operation:'list',id:null,json:false,source:null,category:null,query:null};
|
|
31
|
+
const args=[...argv];
|
|
32
|
+
if(args[0]&&!args[0].startsWith('-'))out.operation=args.shift();
|
|
33
|
+
if(out.operation!=='list'&&out.operation!=='show'&&out.operation!=='help')throw new Error(`Unknown recipe action: ${out.operation}`);
|
|
34
|
+
if(out.operation==='show'){
|
|
35
|
+
out.id=args.shift();
|
|
36
|
+
if(!out.id||out.id.startsWith('-'))throw new Error('recipes show needs a recipe name');
|
|
37
|
+
}
|
|
38
|
+
while(args.length){
|
|
39
|
+
const flag=args.shift();
|
|
40
|
+
if(flag==='--json'){out.json=true;continue;}
|
|
41
|
+
if(flag==='--help'||flag==='-h'){out.operation='help';continue;}
|
|
42
|
+
if(['--source','--category','--search'].includes(flag)){
|
|
43
|
+
const value=args.shift();
|
|
44
|
+
if(!value||value.startsWith('--'))throw new Error(`${flag} needs a value`);
|
|
45
|
+
out[{'--source':'source','--category':'category','--search':'query'}[flag]]=value;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Unknown recipes option: ${flag}`);
|
|
49
|
+
}
|
|
50
|
+
if(out.source&&!['markcut','shotcraft'].includes(out.source))throw new Error('--source must be markcut or shotcraft');
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function main(argv=process.argv.slice(2),{write=console.log,error=console.error}={}) {
|
|
55
|
+
let options;
|
|
56
|
+
try{options=parse(argv);}catch(e){error(e.message);error(HELP);return 2;}
|
|
57
|
+
if(options.operation==='help'){write(HELP);return 0;}
|
|
58
|
+
let catalog;
|
|
59
|
+
try{catalog=loadRecipeCatalog();}catch(e){error('Could not read recipes: '+e.message);return 1;}
|
|
60
|
+
if(options.operation==='show'){
|
|
61
|
+
let recipe;
|
|
62
|
+
try{recipe=getRecipe(catalog,options.id);}catch(e){error(e.message);return 2;}
|
|
63
|
+
if(!recipe){error(`Unknown recipe: ${options.id}`);return 2;}
|
|
64
|
+
const result=readRecipeDetail(recipe);
|
|
65
|
+
if(options.json){write(JSON.stringify(result,null,2));return 0;}
|
|
66
|
+
write(`${result.id} · ${result.title}\nSource: ${result.source} · ${result.category} · ${result.implementation}\nDuration: ${result.duration}\n${result.description}\nUse: ${result.use}`);
|
|
67
|
+
if(result.snippet)write(`\nMarkcut Markdown scene (replace example coordinates):\n${result.snippet}`);
|
|
68
|
+
if(result.parameters)write(`\nEditable parameters: ${result.parameters.join(', ')}`);
|
|
69
|
+
if(result.notes?.length)write(`\nNotes:\n${result.notes.map(x=>'- '+x).join('\n')}`);
|
|
70
|
+
if(result.styles?.length)write(`\nShotcraft styles: ${result.styles.map(s=>s.key).join(', ')}`);
|
|
71
|
+
if(result.guide)write(`\nSource card (read-only reference):\n${result.guide}`);
|
|
72
|
+
else if(result.source==='shotcraft')write('\nSource card unavailable at the installed Skill path.');
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
const selected=filterRecipes(catalog,options);
|
|
76
|
+
if(options.json){write(JSON.stringify({recipes:selected, count:selected.length, sources:catalog.sources},null,2));return 0;}
|
|
77
|
+
write(`Recipes (${selected.length}) — Markcut native: ${catalog.sources.markcut.count}; video-shotcraft reference: ${catalog.sources.shotcraft.count}`);
|
|
78
|
+
if(catalog.sources.shotcraft.status==='not-installed')write('video-shotcraft Skill not installed (optional); set MARKCUT_SHOTCRAFT_SKILL_DIR to its root.');
|
|
79
|
+
if(catalog.sources.shotcraft.status==='unavailable')write(`video-shotcraft catalog unavailable (${catalog.sources.shotcraft.error}); Markcut recipes remain usable.`);
|
|
80
|
+
for(const recipe of selected){
|
|
81
|
+
const kind=recipe.executable?'native':'reference';
|
|
82
|
+
write(`${recipe.id.padEnd(43)} ${recipe.category.padEnd(13)} ${kind.padEnd(9)} ${recipe.duration}`);
|
|
83
|
+
}
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if(process.argv[1]&&resolve(process.argv[1])===fileURLToPath(import.meta.url))process.exitCode=main();
|
package/src/render/cli.mjs
CHANGED
|
@@ -62,7 +62,13 @@ global options:
|
|
|
62
62
|
|
|
63
63
|
Commands:
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
recipes [list|show <recipe-id>] Browse Markcut native + installed Shotcraft recipes
|
|
66
|
+
--json JSON catalog for agents and scripts
|
|
67
|
+
--source markcut|shotcraft Filter by recipe owner
|
|
68
|
+
--category <name> Filter by category (e.g. map, camera)
|
|
69
|
+
--search <text> Search by intent or motion
|
|
70
|
+
|
|
71
|
+
verify <file> Parse + validate descriptive file and linked EDL\n edl <video.md> [--output <file>] Convert Editor Decision sidecar to playable Markcut Markdown
|
|
66
72
|
|
|
67
73
|
preview <file.json|.md> Open player with live preview
|
|
68
74
|
--delivery event Headless human review via Neo Mobile (requires .md)
|
|
@@ -135,6 +141,11 @@ console.log(`\n▶ Rendering → ${outputPath}`);
|
|
|
135
141
|
// Serve local media (TTS, subtitles, images) from the .markcut base dir.
|
|
136
142
|
const renderArgs = ["remotion", "render", "Root", outputPath, "--props", tmpProps, "--config", "remotion.config.ts"];
|
|
137
143
|
if (publicDir) renderArgs.push("--public-dir", publicDir);
|
|
144
|
+
// ThreeCanvas needs a WebGL-capable Chromium backend for deterministic MP4.
|
|
145
|
+
const has3D = (node) => node?.type === "model3d" ||
|
|
146
|
+
(Array.isArray(node?.children) && node.children.some(has3D));
|
|
147
|
+
if (has3D(streamTree)) renderArgs.push("--gl=angle");
|
|
148
|
+
|
|
138
149
|
const proc = spawn("npx", renderArgs, spawnOpts);
|
|
139
150
|
|
|
140
151
|
let lastLoggedFrame = 0;
|
|
@@ -482,6 +493,17 @@ function hasScript(root) {
|
|
|
482
493
|
emitInfo(`File: ${filePath}`);
|
|
483
494
|
emitInfo(`Format: ${isMarkdown ? "Markdown" : "JSON"}`);
|
|
484
495
|
|
|
496
|
+
if (isMarkdown) {
|
|
497
|
+
// EDL is optional; a declared or present sidecar must be valid and resolvable.
|
|
498
|
+
const {loadEditorDecision,editorDecisionToMarkdown} = await import("../editor-decision/index.mjs");
|
|
499
|
+
try {
|
|
500
|
+
const sidecar=loadEditorDecision(filePath,raw);
|
|
501
|
+
if (sidecar) {
|
|
502
|
+
const generated=editorDecisionToMarkdown(filePath,sidecar.edl,raw);
|
|
503
|
+
if(!generated.includes("# video"))throw Error("Invalid EDL visualization");
|
|
504
|
+
}
|
|
505
|
+
} catch(e) { emitError("Editor Decision: "+e.message);process.exit(1); }
|
|
506
|
+
}
|
|
485
507
|
const { compileDescriptiveRoot, parseMarkdownDescriptive, parseMarkdownVariants, parseImportsBlock } = await import("../player/pipeline.mjs");
|
|
486
508
|
|
|
487
509
|
try {
|
|
@@ -550,6 +572,21 @@ function hasScript(root) {
|
|
|
550
572
|
}
|
|
551
573
|
walkMedia(descriptive.children);
|
|
552
574
|
|
|
575
|
+
// GLB/GLTF is a renderer contract, not a media-generation prompt.
|
|
576
|
+
// Fail verify before reaching Remotion for unsupported USDZ and typos.
|
|
577
|
+
function verifyModels(nodes) {
|
|
578
|
+
for (const n of nodes || []) {
|
|
579
|
+
if (n.type === "model3d") {
|
|
580
|
+
if (typeof n.src !== "string" || !/\.(glb|gltf)(?:[?#].*)?$/i.test(n.src))
|
|
581
|
+
errors.push('model3d requires a .glb or .gltf src (USDZ must be converted to GLB)');
|
|
582
|
+
if (n.motion && !["none", "turntable", "orbit"].includes(n.motion))
|
|
583
|
+
errors.push('model3d motion must be none, turntable, or orbit');
|
|
584
|
+
}
|
|
585
|
+
if (n.children) verifyModels(n.children);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
verifyModels(descriptive.children);
|
|
589
|
+
|
|
553
590
|
// ── Check: all assets relative to baseDir ───────────────────────────
|
|
554
591
|
// Every local asset must be a path relative to the source file's folder
|
|
555
592
|
// (the render publicDir). Absolute paths, "/..." and ".." escapes would
|
package/src/schema/index.ts
CHANGED
|
@@ -125,6 +125,26 @@ export const image = base.extend({
|
|
|
125
125
|
});
|
|
126
126
|
export type Image = z.infer<typeof image>;
|
|
127
127
|
|
|
128
|
+
/** A deterministic, timeline-synchronized GLB/GLTF scene. Positions and
|
|
129
|
+
* rotations are in Three.js Y-up coordinates; rotation angles are degrees. */
|
|
130
|
+
const modelVector = z.tuple([z.number(), z.number(), z.number()]);
|
|
131
|
+
export const model3d = base.extend({
|
|
132
|
+
type: z.literal("model3d"),
|
|
133
|
+
src: z.string().min(1).regex(/\.(glb|gltf)(?:[?#].*)?$/i, "model3d requires a .glb or .gltf asset; convert USDZ first"),
|
|
134
|
+
motion: z.enum(["none", "turntable", "orbit"]).default("none"),
|
|
135
|
+
turns: z.number().finite().default(1).describe("full revolutions over this stream's duration"),
|
|
136
|
+
rotation: modelVector.default([0, 0, 0]).describe("initial Euler rotation in degrees (XYZ)"),
|
|
137
|
+
position: modelVector.default([0, 0, 0]).describe("offset after model is centered"),
|
|
138
|
+
scale: z.number().positive().default(1),
|
|
139
|
+
autoFit: z.boolean().default(true).describe("center and normalize model to fit view"),
|
|
140
|
+
camera: z.object({
|
|
141
|
+
position: modelVector.default([0, 0, 4.5]),
|
|
142
|
+
fov: z.number().min(1).max(150).default(40),
|
|
143
|
+
}).optional(),
|
|
144
|
+
background: z.string().optional().describe("3D canvas background CSS color, default transparent"),
|
|
145
|
+
});
|
|
146
|
+
export type Model3D = z.infer<typeof model3d>;
|
|
147
|
+
|
|
128
148
|
/**
|
|
129
149
|
* Component node — JSX usage expression compiled at runtime.
|
|
130
150
|
*
|
|
@@ -311,6 +331,7 @@ export const stream = z.discriminatedUnion("type", [
|
|
|
311
331
|
video,
|
|
312
332
|
audio,
|
|
313
333
|
image,
|
|
334
|
+
model3d,
|
|
314
335
|
component,
|
|
315
336
|
effect,
|
|
316
337
|
rhythm,
|
package/src/types/Folder.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import type { Folder as FolderStream, Stream } from "../schema/index";
|
|
|
14
14
|
import { VideoLeaf } from "./Video";
|
|
15
15
|
import { AudioLeaf } from "./Audio";
|
|
16
16
|
import { ImageLeaf } from "./Image";
|
|
17
|
+
import { Model3DLeaf } from "./Model3D";
|
|
17
18
|
import { ComponentLeaf } from "./Component";
|
|
18
19
|
import { RhythmLeaf } from "./Rhythm";
|
|
19
20
|
import { MapLeaf } from "./Map";
|
|
@@ -25,6 +26,7 @@ const Leaves: Record<string, React.ComponentType<{ stream: any }>> = {
|
|
|
25
26
|
video: VideoLeaf,
|
|
26
27
|
audio: AudioLeaf,
|
|
27
28
|
image: ImageLeaf,
|
|
29
|
+
model3d: Model3DLeaf,
|
|
28
30
|
component: ComponentLeaf,
|
|
29
31
|
rhythm: RhythmLeaf,
|
|
30
32
|
map: MapLeaf,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThreeCanvas } from "@remotion/three";
|
|
3
|
+
import { useLoader, useThree } from "@react-three/fiber";
|
|
4
|
+
import { Box3, Vector3 } from "three";
|
|
5
|
+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
6
|
+
import { staticFile, useCurrentFrame, useVideoConfig } from "remotion";
|
|
7
|
+
import { useFrameEvents } from "../context/index";
|
|
8
|
+
import type { Model3D } from "../schema/index";
|
|
9
|
+
|
|
10
|
+
/** The same asset rule as image/video: relative source paths use Remotion's
|
|
11
|
+
* static-file server; hosted previews use their already resolved URL. */
|
|
12
|
+
export function resolveModel3DSrc(src: string): string {
|
|
13
|
+
return /^(https?:|data:|blob:|file:|\/)/i.test(src) ? src : staticFile(src);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Pure frame-based animation, independent of playback history and wall clock. */
|
|
17
|
+
export function model3dAngle(frame: number, durationFrames: number, turns: number): number {
|
|
18
|
+
return 2 * Math.PI * turns * Math.max(0, Math.min(1, frame / Math.max(1, durationFrames - 1)));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const radians = (degrees: number) => degrees * Math.PI / 180;
|
|
22
|
+
|
|
23
|
+
const CameraAim: React.FC<{ position: [number, number, number] }> = ({ position }) => {
|
|
24
|
+
const { camera } = useThree();
|
|
25
|
+
React.useLayoutEffect(() => {
|
|
26
|
+
camera.position.set(...position);
|
|
27
|
+
camera.lookAt(0, 0, 0);
|
|
28
|
+
camera.updateProjectionMatrix();
|
|
29
|
+
}, [camera, position[0], position[1], position[2]]);
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Suspends while GLB and embedded textures load; ThreeCanvas supplies the
|
|
34
|
+
* Remotion-aware Suspense render blocker so MP4 never captures the placeholder. */
|
|
35
|
+
const LoadedModel: React.FC<{ stream: Model3D; angle: number }> = ({ stream, angle }) => {
|
|
36
|
+
const gltf = useLoader(GLTFLoader, resolveModel3DSrc(stream.src));
|
|
37
|
+
const copy = React.useMemo(() => gltf.scene.clone(true), [gltf.scene]);
|
|
38
|
+
const { center, factor } = React.useMemo(() => {
|
|
39
|
+
if (!stream.autoFit) return { center: new Vector3(), factor: 1 };
|
|
40
|
+
const box = new Box3().setFromObject(copy);
|
|
41
|
+
const size = box.getSize(new Vector3());
|
|
42
|
+
const maxSize = Math.max(size.x, size.y, size.z);
|
|
43
|
+
if (!Number.isFinite(maxSize) || maxSize <= 0) {
|
|
44
|
+
return { center: new Vector3(), factor: 1 };
|
|
45
|
+
}
|
|
46
|
+
return { center: box.getCenter(new Vector3()), factor: 2 / maxSize };
|
|
47
|
+
}, [copy, stream.autoFit]);
|
|
48
|
+
|
|
49
|
+
const rx = radians(stream.rotation[0]);
|
|
50
|
+
const ry = radians(stream.rotation[1]);
|
|
51
|
+
const rz = radians(stream.rotation[2]);
|
|
52
|
+
return (
|
|
53
|
+
<group position={stream.position} rotation={[rx, ry, rz]}>
|
|
54
|
+
<group rotation={[0, stream.motion === "turntable" ? angle : 0, 0]} scale={factor * stream.scale}>
|
|
55
|
+
<primitive object={copy} position={[-center.x, -center.y, -center.z]} />
|
|
56
|
+
</group>
|
|
57
|
+
</group>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Model3DLeaf: React.FC<{ stream: Model3D }> = ({ stream }) => {
|
|
62
|
+
const frame = useCurrentFrame();
|
|
63
|
+
const { width, height, fps } = useVideoConfig();
|
|
64
|
+
const durationFrames = Math.max(1, Math.round((stream.durationInSeconds ?? stream.duration ?? 4) * fps));
|
|
65
|
+
useFrameEvents(stream.on, durationFrames);
|
|
66
|
+
const angle = model3dAngle(frame, durationFrames, stream.turns);
|
|
67
|
+
const baseCamera = stream.camera?.position ?? [0, 0, 4.5];
|
|
68
|
+
const cameraPos: [number, number, number] = stream.motion === "orbit"
|
|
69
|
+
? [
|
|
70
|
+
baseCamera[0] * Math.cos(angle) + baseCamera[2] * Math.sin(angle),
|
|
71
|
+
baseCamera[1],
|
|
72
|
+
baseCamera[2] * Math.cos(angle) - baseCamera[0] * Math.sin(angle),
|
|
73
|
+
]
|
|
74
|
+
: baseCamera;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<ThreeCanvas
|
|
78
|
+
width={width}
|
|
79
|
+
height={height}
|
|
80
|
+
camera={{ fov: stream.camera?.fov ?? 40, position: cameraPos, near: 0.05, far: 100 }}
|
|
81
|
+
gl={{ antialias: true, alpha: true }}
|
|
82
|
+
style={{ width: "100%", height: "100%", backgroundColor: stream.background ?? "transparent" }}
|
|
83
|
+
>
|
|
84
|
+
<CameraAim position={cameraPos} />
|
|
85
|
+
<ambientLight intensity={1.4} />
|
|
86
|
+
<directionalLight position={[-3, 5, 4]} intensity={2.3} />
|
|
87
|
+
<directionalLight position={[3, 1, -4]} intensity={1.1} />
|
|
88
|
+
<LoadedModel stream={stream} angle={angle} />
|
|
89
|
+
</ThreeCanvas>
|
|
90
|
+
);
|
|
91
|
+
};
|