@tora-editor/tora 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +322 -28
- package/crates/packer/trusted/native-3d-meta.json +4 -3
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +4 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -95
- package/docs/TORA_CREATION_API.md +63 -348
- package/docs/reference/CORE_AUTHORING.md +10 -3
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +11 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +372 -9
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +256 -68
- package/scripts/lean/editor/review-editor.js +1834 -1086
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +39 -62
- package/scripts/lean/native/api.mjs +161 -136
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +38 -7
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +16 -11
- package/scripts/lean/native/creative-qa.mjs +365 -128
- package/scripts/lean/native/demos.mjs +53 -18
- package/scripts/lean/native/document.mjs +50 -12
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/local-bundle.mjs +7 -3
- package/scripts/lean/native/mcp-server.mjs +42 -74
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/project-bundle.mjs +6 -5
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review.mjs +205 -571
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +378 -79
- package/scripts/lean/native/starters.mjs +563 -0
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
- package/scripts/lean/native/check-salvage.mjs +0 -197
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -165
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1623
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -818
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
package/bin/tora.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/** Unified Tora CLI: init, mcp, editor, doctor, check. */
|
|
3
|
-
import {spawnSync} from 'node:child_process';
|
|
3
|
+
import {execFile,spawn,spawnSync} from 'node:child_process';
|
|
4
4
|
import {copyFileSync,existsSync,realpathSync} from 'node:fs';
|
|
5
5
|
import {access,constants as fsConstants,mkdir,readFile,rename,rm,writeFile} from 'node:fs/promises';
|
|
6
6
|
import {homedir} from 'node:os';
|
|
@@ -14,10 +14,10 @@ import {assertStorePath} from '../scripts/lean/native/store-path.mjs';
|
|
|
14
14
|
const HELP=`Usage: tora <command> [options]
|
|
15
15
|
|
|
16
16
|
Commands:
|
|
17
|
-
tora init [--client claude-code|
|
|
17
|
+
tora init [--client gemini|codex|claude-code|claude-desktop|all|print] [--global]
|
|
18
18
|
[--workspace <dir>] [--install-browsers|--skip-browsers] [--no-download] [--dry-run]
|
|
19
19
|
tora mcp [--workspace <dir>] [--store <dir>]
|
|
20
|
-
tora editor [--port 8001] [--workspace <dir>] [--store <dir>]
|
|
20
|
+
tora editor [--port 8001] [--no-open] [--workspace <dir>] [--store <dir>]
|
|
21
21
|
tora doctor [--workspace <dir>] [--json]
|
|
22
22
|
tora check <artifact|rules|assets> ...
|
|
23
23
|
tora --version | --help
|
|
@@ -36,7 +36,7 @@ function parseFlags(argv){
|
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
38
|
const key=arg.slice(2);
|
|
39
|
-
if(['global','dry-run','skip-browsers','install-browsers','no-download','json','local-bin'].includes(key)){
|
|
39
|
+
if(['global','dry-run','skip-browsers','install-browsers','no-download','no-open','json','local-bin'].includes(key)){
|
|
40
40
|
flags[key]=true;
|
|
41
41
|
}else{
|
|
42
42
|
const next=argv[i+1];
|
|
@@ -66,6 +66,32 @@ async function detectChromiumPath(){
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
export function claudeDesktopConfigPath({platform=process.platform,home=homedir(),env=process.env}={}){
|
|
70
|
+
if(platform==='darwin')return resolve(home,'Library','Application Support','Claude','claude_desktop_config.json');
|
|
71
|
+
if(platform==='win32'){
|
|
72
|
+
const appData=env.APPDATA||resolve(home,'AppData','Roaming');
|
|
73
|
+
return resolve(appData,'Claude','claude_desktop_config.json');
|
|
74
|
+
}
|
|
75
|
+
return resolve(home,'.config','Claude','claude_desktop_config.json');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function openBrowser(url){
|
|
79
|
+
if(typeof url!=='string'||!/^http:\/\/127\.0\.0\.1:\d+\/[a-zA-Z0-9/?=._-]*$/.test(url))return false;
|
|
80
|
+
try{
|
|
81
|
+
const [cmd,args]=process.platform==='darwin'
|
|
82
|
+
?['open',[url]]
|
|
83
|
+
:process.platform==='win32'
|
|
84
|
+
?['cmd',['/c','start','',url]]
|
|
85
|
+
:['xdg-open',[url]];
|
|
86
|
+
const child=spawn(cmd,args,{detached:true,stdio:'ignore',windowsHide:true});
|
|
87
|
+
child.on('error',()=>{});
|
|
88
|
+
child.unref();
|
|
89
|
+
return true;
|
|
90
|
+
}catch{
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
69
95
|
export function buildMcpClientEntry({workspaceRoot,localBin=IS_SOURCE_CHECKOUT}={}){
|
|
70
96
|
const ws=resolveWorkspaceRoot(workspaceRoot);
|
|
71
97
|
if(localBin){
|
|
@@ -80,37 +106,235 @@ export function buildMcpClientEntry({workspaceRoot,localBin=IS_SOURCE_CHECKOUT}=
|
|
|
80
106
|
};
|
|
81
107
|
}
|
|
82
108
|
|
|
83
|
-
export
|
|
84
|
-
|
|
109
|
+
export function opencodeConfigPath({workspaceRoot,global=false,env=process.env,home=homedir()}={}){
|
|
110
|
+
if(global)return resolve(env.XDG_CONFIG_HOME||resolve(home,'.config'),'opencode','opencode.json');
|
|
111
|
+
return resolve(resolveWorkspaceRoot(workspaceRoot),'opencode.json');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function hermesConfigPath({env=process.env,home=homedir()}={}){
|
|
115
|
+
return resolve(env.HERMES_HOME||resolve(home,'.hermes'),'config.yaml');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function dshConfigPath({profile='web',env=process.env,home=homedir()}={}){
|
|
119
|
+
const name=String(profile||'web').trim();
|
|
120
|
+
if(!/^[a-z0-9][a-z0-9._-]{0,63}$/i.test(name))throw Error(`Invalid --profile "${profile}".`);
|
|
121
|
+
return resolve(env.DSH_HOME||resolve(home,'.dsh'),'profiles',name,'cordis.patch.yml');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function buildOpenCodeEntry(entry){
|
|
125
|
+
return {
|
|
126
|
+
type:'local',
|
|
127
|
+
command:[entry.command,...(entry.args??[])],
|
|
128
|
+
...(entry.env&&Object.keys(entry.env).length?{environment:entry.env}:{}),
|
|
129
|
+
enabled:true,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function writeAtomicWithBackup(filePath,serialized,{existed,dryRun}){
|
|
134
|
+
if(dryRun)return;
|
|
135
|
+
await mkdir(dirname(filePath),{recursive:true});
|
|
136
|
+
const backupPath=filePath+'.bak';
|
|
137
|
+
if(existed&&!existsSync(backupPath))copyFileSync(filePath,backupPath);
|
|
138
|
+
const tmp=`${filePath}.${process.pid}.tmp`;
|
|
139
|
+
try{
|
|
140
|
+
await writeFile(tmp,serialized,'utf8');
|
|
141
|
+
await rename(tmp,filePath);
|
|
142
|
+
}finally{
|
|
143
|
+
await rm(tmp,{force:true});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export async function mergeJsonMcpConfig(filePath,serverName,entry,{dryRun=false,serverKey='mcpServers',defaultRoot}={}){
|
|
148
|
+
let existing=defaultRoot?{...defaultRoot}:{};
|
|
85
149
|
const existed=existsSync(filePath);
|
|
86
150
|
if(existed){
|
|
87
151
|
const raw=await readFile(filePath,'utf8');
|
|
88
|
-
existing=raw.trim()?JSON.parse(raw):{};
|
|
152
|
+
existing=raw.trim()?JSON.parse(raw):(defaultRoot?{...defaultRoot}:{});
|
|
89
153
|
if(!existing||typeof existing!=='object'||Array.isArray(existing)){
|
|
90
154
|
throw Error(`Config file is not a JSON object: ${filePath}`);
|
|
91
155
|
}
|
|
92
156
|
}
|
|
157
|
+
const servers=existing[serverKey];
|
|
158
|
+
if((serverKey==='servers'||serverKey==='mcp')&&servers!==undefined&&(!servers||typeof servers!=='object'||Array.isArray(servers))){
|
|
159
|
+
throw Error(`Config field "${serverKey}" is not a JSON object: ${filePath}`);
|
|
160
|
+
}
|
|
93
161
|
const next={
|
|
94
162
|
...existing,
|
|
95
|
-
|
|
96
|
-
...(
|
|
163
|
+
[serverKey]:{
|
|
164
|
+
...(servers&&typeof servers==='object'&&!Array.isArray(servers)?servers:{}),
|
|
97
165
|
[serverName]:entry,
|
|
98
166
|
},
|
|
99
167
|
};
|
|
100
168
|
const serialized=JSON.stringify(next,null,2)+'\n';
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
169
|
+
await writeAtomicWithBackup(filePath,serialized,{existed,dryRun});
|
|
170
|
+
return {path:filePath,existed,dryRun,config:next};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function renderHermesServerYaml(serverName,entry,indent=2){
|
|
174
|
+
const pad=n=>' '.repeat(indent+n);
|
|
175
|
+
const lines=[
|
|
176
|
+
`${pad(0)}${serverName}:`,
|
|
177
|
+
`${pad(2)}command: ${JSON.stringify(entry.command)}`,
|
|
178
|
+
`${pad(2)}args:`,
|
|
179
|
+
...(entry.args??[]).map(arg=>`${pad(4)}- ${JSON.stringify(arg)}`),
|
|
180
|
+
];
|
|
181
|
+
if(entry.env&&Object.keys(entry.env).length){
|
|
182
|
+
lines.push(`${pad(2)}env:`);
|
|
183
|
+
for(const [k,v] of Object.entries(entry.env))lines.push(`${pad(4)}${k}: ${JSON.stringify(v)}`);
|
|
184
|
+
}
|
|
185
|
+
lines.push(`${pad(2)}timeout: 120`);
|
|
186
|
+
return lines.join('\n');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export async function mergeHermesYamlConfig(filePath,serverName,entry,{dryRun=false}={}){
|
|
190
|
+
const existed=existsSync(filePath);
|
|
191
|
+
const raw=existed?(await readFile(filePath,'utf8')).replace(/\r\n/g,'\n'):'';
|
|
192
|
+
let serialized;
|
|
193
|
+
if(!raw.trim()){
|
|
194
|
+
serialized=`mcp_servers:\n${renderHermesServerYaml(serverName,entry,2)}\n`;
|
|
195
|
+
}else{
|
|
196
|
+
const lines=raw.split('\n');
|
|
197
|
+
if(lines.at(-1)==='')lines.pop();
|
|
198
|
+
const sectionStart=lines.findIndex(line=>/^mcp_servers\s*:/.test(line));
|
|
199
|
+
if(sectionStart===-1){
|
|
200
|
+
serialized=[...lines,'','mcp_servers:',renderHermesServerYaml(serverName,entry,2)].join('\n')+'\n';
|
|
201
|
+
}else{
|
|
202
|
+
let sectionEnd=lines.length;
|
|
203
|
+
for(let i=sectionStart+1;i<lines.length;i++){
|
|
204
|
+
if(/^[^#\s]/.test(lines[i])){sectionEnd=i;break;}
|
|
205
|
+
}
|
|
206
|
+
const inlineRest=lines[sectionStart].replace(/^mcp_servers\s*:/,'').trim();
|
|
207
|
+
if(inlineRest==='{}'||inlineRest==='null'||inlineRest==='~'){
|
|
208
|
+
lines[sectionStart]='mcp_servers:';
|
|
209
|
+
lines.splice(sectionStart+1,0,...renderHermesServerYaml(serverName,entry,2).split('\n'));
|
|
210
|
+
}else{
|
|
211
|
+
const escaped=serverName.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');
|
|
212
|
+
const entryRe=new RegExp(`^(\\s+)${escaped}\\s*:`);
|
|
213
|
+
let entryStart=-1,indent=2;
|
|
214
|
+
for(let i=sectionStart+1;i<sectionEnd;i++){
|
|
215
|
+
const match=entryRe.exec(lines[i]);
|
|
216
|
+
if(match){entryStart=i;indent=match[1].length;break;}
|
|
217
|
+
}
|
|
218
|
+
if(entryStart!==-1){
|
|
219
|
+
let entryEnd=sectionEnd;
|
|
220
|
+
for(let i=entryStart+1;i<sectionEnd;i++){
|
|
221
|
+
if(!lines[i].trim()||/^\s*#/.test(lines[i]))continue;
|
|
222
|
+
const spaces=lines[i].match(/^(\s*)/)[1].length;
|
|
223
|
+
if(spaces<=indent){entryEnd=i;break;}
|
|
224
|
+
}
|
|
225
|
+
while(entryEnd>entryStart+1&&!lines[entryEnd-1].trim())entryEnd--;
|
|
226
|
+
lines.splice(entryStart,entryEnd-entryStart,...renderHermesServerYaml(serverName,entry,indent).split('\n'));
|
|
227
|
+
}else{
|
|
228
|
+
let insertAt=sectionEnd;
|
|
229
|
+
while(insertAt>sectionStart+1&&(!lines[insertAt-1].trim()||/^\s*#/.test(lines[insertAt-1])))insertAt--;
|
|
230
|
+
lines.splice(insertAt,0,...renderHermesServerYaml(serverName,entry,2).split('\n'));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
serialized=lines.join('\n')+'\n';
|
|
111
234
|
}
|
|
112
235
|
}
|
|
113
|
-
|
|
236
|
+
await writeAtomicWithBackup(filePath,serialized,{existed,dryRun});
|
|
237
|
+
return {path:filePath,existed,dryRun,text:serialized};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function renderDshPluginItem(entry,serverName='tora',baseIndent=4){
|
|
241
|
+
const pad=n=>' '.repeat(baseIndent+n);
|
|
242
|
+
const lines=[
|
|
243
|
+
`${pad(0)}- id: mcp-${serverName}`,
|
|
244
|
+
`${pad(2)}name: "@deepseek-ai/dsh-mcp-client"`,
|
|
245
|
+
`${pad(2)}config:`,
|
|
246
|
+
`${pad(4)}serverName: ${JSON.stringify(serverName)}`,
|
|
247
|
+
`${pad(4)}transport: "stdio"`,
|
|
248
|
+
`${pad(4)}command: ${JSON.stringify(entry.command)}`,
|
|
249
|
+
`${pad(4)}args:`,
|
|
250
|
+
...(entry.args??[]).map(arg=>`${pad(6)}- ${JSON.stringify(arg)}`),
|
|
251
|
+
];
|
|
252
|
+
if(entry.env&&Object.keys(entry.env).length){
|
|
253
|
+
lines.push(`${pad(4)}env:`);
|
|
254
|
+
for(const [k,v] of Object.entries(entry.env))lines.push(`${pad(6)}${k}: ${JSON.stringify(v)}`);
|
|
255
|
+
}
|
|
256
|
+
return lines.join('\n');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export async function mergeDshPatchYaml(filePath,entry,{dryRun=false,serverName='tora'}={}){
|
|
260
|
+
const existed=existsSync(filePath);
|
|
261
|
+
const raw=existed?(await readFile(filePath,'utf8')).replace(/\r\n/g,'\n'):'';
|
|
262
|
+
let serialized;
|
|
263
|
+
if(!raw.trim()){
|
|
264
|
+
serialized=`- insert:\n${renderDshPluginItem(entry,serverName,4)}\n`;
|
|
265
|
+
}else{
|
|
266
|
+
const lines=raw.split('\n');
|
|
267
|
+
if(lines.at(-1)==='')lines.pop();
|
|
268
|
+
const escaped=serverName.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');
|
|
269
|
+
const itemRe=new RegExp(`^(\\s*)-\\s+id\\s*:\\s*['"]?mcp-${escaped}['"]?\\s*$`);
|
|
270
|
+
let entryStart=-1,indent=4;
|
|
271
|
+
for(let i=0;i<lines.length;i++){
|
|
272
|
+
const match=itemRe.exec(lines[i]);
|
|
273
|
+
if(match){entryStart=i;indent=match[1].length;break;}
|
|
274
|
+
}
|
|
275
|
+
if(entryStart!==-1){
|
|
276
|
+
let entryEnd=lines.length;
|
|
277
|
+
for(let i=entryStart+1;i<lines.length;i++){
|
|
278
|
+
if(!lines[i].trim()||/^\s*#/.test(lines[i]))continue;
|
|
279
|
+
const spaces=lines[i].match(/^(\s*)/)[1].length;
|
|
280
|
+
if(spaces<=indent){entryEnd=i;break;}
|
|
281
|
+
}
|
|
282
|
+
while(entryEnd>entryStart+1&&!lines[entryEnd-1].trim())entryEnd--;
|
|
283
|
+
lines.splice(entryStart,entryEnd-entryStart,...renderDshPluginItem(entry,serverName,indent).split('\n'));
|
|
284
|
+
serialized=lines.join('\n')+'\n';
|
|
285
|
+
}else{
|
|
286
|
+
serialized=[...lines,'','- insert:',renderDshPluginItem(entry,serverName,4)].join('\n')+'\n';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
await writeAtomicWithBackup(filePath,serialized,{existed,dryRun});
|
|
290
|
+
return {path:filePath,existed,dryRun,text:serialized};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async function verifyPerchMcp(entry,workspace){
|
|
294
|
+
const request=(id,method,params={})=>({jsonrpc:'2.0',id,method,params});
|
|
295
|
+
const messages=[
|
|
296
|
+
request(1,'initialize',{protocolVersion:'2025-11-25',capabilities:{},clientInfo:{name:'tora-init',version:'1'}}),
|
|
297
|
+
{jsonrpc:'2.0',method:'notifications/initialized'},
|
|
298
|
+
request(2,'tools/call',{name:'tora_brief'}),
|
|
299
|
+
request(3,'tools/call',{name:'tora_capabilities',arguments:{summary:true}}),
|
|
300
|
+
];
|
|
301
|
+
const output=await new Promise((resolveOutput,reject)=>{
|
|
302
|
+
const child=execFile(entry.command,entry.args,{
|
|
303
|
+
cwd:workspace,encoding:'utf8',timeout:20_000,maxBuffer:12*1024*1024,windowsHide:true,
|
|
304
|
+
},(error,stdout)=>{
|
|
305
|
+
if(error)reject(Error(`Could not start the Tora server for Perch (${error.code??'startup failed'}). Run \`npx @tora-editor/tora doctor\` in this folder.`));
|
|
306
|
+
else resolveOutput(stdout);
|
|
307
|
+
});
|
|
308
|
+
child.stdin.on('error',()=>{});
|
|
309
|
+
child.stdin.end(messages.map(message=>JSON.stringify(message)).join('\n')+'\n');
|
|
310
|
+
});
|
|
311
|
+
try{
|
|
312
|
+
const responses=new Map(output.trim().split('\n').map(line=>{
|
|
313
|
+
const response=JSON.parse(line);
|
|
314
|
+
return [response.id,response.result];
|
|
315
|
+
}));
|
|
316
|
+
const brief=responses.get(2),capabilities=responses.get(3);
|
|
317
|
+
if(responses.get(1)?.serverInfo?.name==='tora'&&!brief?.isError&&!capabilities?.isError){
|
|
318
|
+
const documents=JSON.parse(brief.content[0].text).documents;
|
|
319
|
+
const packs=JSON.parse(capabilities.content[0].text).packs;
|
|
320
|
+
if(documents.some(doc=>doc.name==='authoring')&&packs.some(pack=>pack.id==='core'))return;
|
|
321
|
+
}
|
|
322
|
+
}catch{
|
|
323
|
+
// Report only the failing handshake. Brief contents may be private.
|
|
324
|
+
}
|
|
325
|
+
throw Error('The Tora server did not return its brief and capabilities. Check the installation and any TORA_PLAYABLE_BRIEF setting, then rerun init.');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async function writePerchProjectRule(configPath){
|
|
329
|
+
const rulesDir=resolve(dirname(configPath),'rules');
|
|
330
|
+
await mkdir(rulesDir,{recursive:true});
|
|
331
|
+
const path=resolve(rulesDir,'tora.md');
|
|
332
|
+
const content=`# Authoring with Tora
|
|
333
|
+
|
|
334
|
+
When asked to create a playable with Tora, call \`tora_brief\` and \`tora_starters\` first. For a cooking brief, call \`tora_compose_starter\` with \`starter: "stack-and-serve"\` and \`deliver: true\`. This gives you the browser ad, editable source, and a QA report and recording in one call. For custom mechanics or edits, discover the matching contracts with \`tora_capabilities\` and use the supported Tora tools. Inspect the packaged playthrough with an available preview tool. If this model or client cannot view stills or footage, give the creator the resulting file paths and report the QA and the missing creative review. After QA passes, share the draft and editable project before optional refinements. If the Tora tools are missing, ask the user to run \`npx @tora-editor/tora init --client perch\` in this folder and reopen Perch here. The installed tools provide the authoring contracts and assets, so a source checkout is unnecessary.
|
|
335
|
+
`;
|
|
336
|
+
try{await writeFile(path,content,{encoding:'utf8',flag:'wx'});}
|
|
337
|
+
catch(error){if(error.code!=='EEXIST')throw error;}
|
|
114
338
|
}
|
|
115
339
|
|
|
116
340
|
async function runDoctor(flags){
|
|
@@ -138,10 +362,17 @@ async function runDoctor(flags){
|
|
|
138
362
|
const ffmpeg=commandExists('ffmpeg');
|
|
139
363
|
const gstreamer=commandExists('gst-launch-1.0');
|
|
140
364
|
const clientConfigs={
|
|
365
|
+
claudeDesktop:existsSync(claudeDesktopConfigPath()),
|
|
141
366
|
cursorProject:existsSync(resolve(ws,'.cursor/mcp.json')),
|
|
142
367
|
cursorGlobal:existsSync(resolve(homedir(),'.cursor/mcp.json')),
|
|
143
368
|
geminiGlobal:existsSync(resolve(homedir(),'.gemini/settings.json')),
|
|
144
369
|
claudeProject:existsSync(resolve(ws,'.mcp.json')),
|
|
370
|
+
perchProject:existsSync(resolve(ws,'.perch/mcp.json')),
|
|
371
|
+
perchGlobal:existsSync(resolve(homedir(),'.perch/mcp.json')),
|
|
372
|
+
opencodeProject:existsSync(opencodeConfigPath({workspaceRoot:ws,global:false})),
|
|
373
|
+
opencodeGlobal:existsSync(opencodeConfigPath({workspaceRoot:ws,global:true})),
|
|
374
|
+
hermes:existsSync(hermesConfigPath()),
|
|
375
|
+
deepseekHarness:existsSync(dshConfigPath({profile:flags.profile??'web'})),
|
|
145
376
|
};
|
|
146
377
|
const ok=nodeOk&&Boolean(nativeInfo)&&!nativeError&&storeSafe&&journalSafe;
|
|
147
378
|
const report={
|
|
@@ -175,9 +406,10 @@ async function runDoctor(flags){
|
|
|
175
406
|
async function runInit(flags){
|
|
176
407
|
const ws=resolveWorkspaceRoot(flags.workspace);
|
|
177
408
|
const dryRun=Boolean(flags['dry-run']);
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
409
|
+
const rawClient=String(flags.client??'print').toLowerCase();
|
|
410
|
+
const client=rawClient==='dsh'?'deepseek-harness':rawClient;
|
|
411
|
+
const validClients=new Set(['claude-desktop','claude-code','cursor','codex','gemini','perch','opencode','hermes','deepseek-harness','all','print']);
|
|
412
|
+
if(!validClients.has(client))throw Error(`Unsupported --client "${rawClient}". Choose claude-desktop, claude-code, codex, gemini, all, or print.`);
|
|
181
413
|
|
|
182
414
|
const nodeMajor=Number(process.versions.node.split('.')[0]);
|
|
183
415
|
if(!Number.isInteger(nodeMajor)||nodeMajor<22)throw Error(`Node >= 22 is required (found ${process.versions.node})`);
|
|
@@ -210,14 +442,27 @@ async function runInit(flags){
|
|
|
210
442
|
}
|
|
211
443
|
|
|
212
444
|
const entry=buildMcpClientEntry({workspaceRoot:ws,localBin:Boolean(flags['local-bin']||IS_SOURCE_CHECKOUT)});
|
|
213
|
-
const targets=client==='all'?['cursor','gemini','claude-code','codex']:client==='print'?[]:[client];
|
|
445
|
+
const targets=client==='all'?['claude-desktop','cursor','gemini','claude-code','codex','perch']:client==='print'?[]:[client];
|
|
446
|
+
// GUI apps (Perch, Claude Desktop) often launch without shell PATH shims for npx, so bind the verified Node path directly.
|
|
447
|
+
const directEntry=buildMcpClientEntry({workspaceRoot:ws,localBin:true});
|
|
448
|
+
const perchEntry={type:'stdio',...directEntry};
|
|
449
|
+
if(targets.includes('perch')&&!dryRun)await verifyPerchMcp(perchEntry,ws);
|
|
214
450
|
const results=[];
|
|
215
451
|
|
|
216
452
|
for(const target of targets){
|
|
217
|
-
if(target==='
|
|
453
|
+
if(target==='claude-desktop'){
|
|
454
|
+
const cfgPath=claudeDesktopConfigPath();
|
|
455
|
+
const merged=await mergeJsonMcpConfig(cfgPath,'tora',directEntry,{dryRun});
|
|
456
|
+
results.push({client:'claude-desktop',action:dryRun?'dry-run':'written',path:merged.path});
|
|
457
|
+
}else if(target==='cursor'){
|
|
218
458
|
const cfgPath=flags.global?resolve(homedir(),'.cursor/mcp.json'):resolve(ws,'.cursor/mcp.json');
|
|
219
459
|
const merged=await mergeJsonMcpConfig(cfgPath,'tora',entry,{dryRun});
|
|
220
460
|
results.push({client:'cursor',action:dryRun?'dry-run':'written',path:merged.path});
|
|
461
|
+
}else if(target==='perch'){
|
|
462
|
+
const cfgPath=resolve(flags.global?homedir():ws,'.perch/mcp.json');
|
|
463
|
+
const merged=await mergeJsonMcpConfig(cfgPath,'tora',perchEntry,{dryRun,serverKey:'servers'});
|
|
464
|
+
if(!dryRun&&!flags.global)await writePerchProjectRule(cfgPath);
|
|
465
|
+
results.push({client:'perch',action:dryRun?'dry-run':'written',path:merged.path});
|
|
221
466
|
}else if(target==='gemini'){
|
|
222
467
|
const cfgPath=resolve(homedir(),'.gemini/settings.json');
|
|
223
468
|
const merged=await mergeJsonMcpConfig(cfgPath,'tora',entry,{dryRun});
|
|
@@ -230,6 +475,18 @@ async function runInit(flags){
|
|
|
230
475
|
const cfgPath=flags.global?resolve(homedir(),'.claude.json'):resolve(ws,'.mcp.json');
|
|
231
476
|
const merged=await mergeJsonMcpConfig(cfgPath,'tora',entry,{dryRun});
|
|
232
477
|
results.push({client:'claude-code',action:dryRun?'dry-run':'written',path:merged.path});
|
|
478
|
+
}else if(target==='opencode'){
|
|
479
|
+
const cfgPath=opencodeConfigPath({workspaceRoot:ws,global:Boolean(flags.global)});
|
|
480
|
+
const merged=await mergeJsonMcpConfig(cfgPath,'tora',buildOpenCodeEntry(entry),{dryRun,serverKey:'mcp',defaultRoot:{$schema:'https://opencode.ai/config.json'}});
|
|
481
|
+
results.push({client:'opencode',action:dryRun?'dry-run':'written',path:merged.path});
|
|
482
|
+
}else if(target==='hermes'){
|
|
483
|
+
const cfgPath=hermesConfigPath();
|
|
484
|
+
const merged=await mergeHermesYamlConfig(cfgPath,'tora',entry,{dryRun});
|
|
485
|
+
results.push({client:'hermes',action:dryRun?'dry-run':'written',path:merged.path});
|
|
486
|
+
}else if(target==='deepseek-harness'){
|
|
487
|
+
const cfgPath=dshConfigPath({profile:flags.profile??'web'});
|
|
488
|
+
const merged=await mergeDshPatchYaml(cfgPath,entry,{dryRun,serverName:'tora'});
|
|
489
|
+
results.push({client:'deepseek-harness',action:dryRun?'dry-run':'written',path:merged.path});
|
|
233
490
|
}else if(target==='codex'){
|
|
234
491
|
if(!dryRun&&commandExists('codex')){
|
|
235
492
|
const res=spawnSync('codex',['mcp','add','tora','--',entry.command,...entry.args],{cwd:ws,stdio:'inherit'});
|
|
@@ -240,14 +497,46 @@ async function runInit(flags){
|
|
|
240
497
|
}
|
|
241
498
|
}
|
|
242
499
|
|
|
243
|
-
if(client==='print'||dryRun){
|
|
500
|
+
if(client==='print'||(dryRun&&!['perch','opencode','hermes','deepseek-harness'].includes(client))){
|
|
501
|
+
const previewEntry=client==='claude-desktop'?directEntry:entry;
|
|
244
502
|
globalThis.console.log('\nMCP server entry:');
|
|
245
|
-
globalThis.console.log(JSON.stringify({mcpServers:{tora:
|
|
503
|
+
globalThis.console.log(JSON.stringify({mcpServers:{tora:previewEntry}},null,2));
|
|
504
|
+
}
|
|
505
|
+
if(dryRun&&targets.includes('perch')){
|
|
506
|
+
globalThis.console.log('\nPerch server entry:');
|
|
507
|
+
globalThis.console.log(JSON.stringify({servers:{tora:perchEntry}},null,2));
|
|
508
|
+
}
|
|
509
|
+
if(dryRun&&targets.includes('opencode')){
|
|
510
|
+
globalThis.console.log('\nOpenCode MCP entry:');
|
|
511
|
+
globalThis.console.log(JSON.stringify({mcp:{tora:buildOpenCodeEntry(entry)}},null,2));
|
|
512
|
+
}
|
|
513
|
+
if(dryRun&&targets.includes('hermes')){
|
|
514
|
+
globalThis.console.log('\nHermes config.yaml entry:');
|
|
515
|
+
globalThis.console.log(`mcp_servers:\n${renderHermesServerYaml('tora',entry,2)}`);
|
|
516
|
+
}
|
|
517
|
+
if(dryRun&&targets.includes('deepseek-harness')){
|
|
518
|
+
globalThis.console.log('\nDeepSeek Harness cordis.patch.yml entry:');
|
|
519
|
+
globalThis.console.log(`- insert:\n${renderDshPluginItem(entry,'tora',4)}`);
|
|
246
520
|
}
|
|
247
521
|
for(const r of results){
|
|
248
522
|
if(r.command)globalThis.console.log(`[${r.client}] Run: ${r.command}`);
|
|
249
523
|
else globalThis.console.log(`[${r.client}] ${r.action}${r.path?`: ${r.path}`:''}`);
|
|
250
524
|
}
|
|
525
|
+
if(!dryRun&&targets.includes('perch')){
|
|
526
|
+
globalThis.console.log('Verified Tora brief and capabilities. Reopen Perch in this folder, then describe the playable you want.');
|
|
527
|
+
}
|
|
528
|
+
if(!dryRun&&targets.includes('claude-desktop')){
|
|
529
|
+
globalThis.console.log('Claude Desktop configured. Quit and reopen Claude Desktop, then type: "Create a cooking playable ad with Tora."');
|
|
530
|
+
}
|
|
531
|
+
if(!dryRun&&targets.includes('opencode')){
|
|
532
|
+
globalThis.console.log('OpenCode configured. Restart OpenCode (or run `opencode mcp`) to verify Tora tools.');
|
|
533
|
+
}
|
|
534
|
+
if(!dryRun&&targets.includes('hermes')){
|
|
535
|
+
globalThis.console.log('Hermes configured. Restart Hermes (or run `/reload-mcp`), then check `hermes tools list`.');
|
|
536
|
+
}
|
|
537
|
+
if(!dryRun&&targets.includes('deepseek-harness')){
|
|
538
|
+
globalThis.console.log('DeepSeek Harness configured. Restart DeepSeek Harness (e.g. `npx @deepseek-ai/dsh web`) to load Tora MCP tools.');
|
|
539
|
+
}
|
|
251
540
|
return 0;
|
|
252
541
|
}
|
|
253
542
|
|
|
@@ -284,7 +573,12 @@ export async function runCli(argv=process.argv.slice(2)){
|
|
|
284
573
|
const {startEditor}=await import('../scripts/serve-editor.mjs');
|
|
285
574
|
const port=flags.port!==undefined?Number(flags.port):Number(process.env.EDITOR_PORT??8001);
|
|
286
575
|
const {url}=await startEditor({port,workspaceRoot:flags.workspace,storeRoot:flags.store});
|
|
287
|
-
|
|
576
|
+
const studioUrl=url+'/?view=new';
|
|
577
|
+
globalThis.console.log('Tora editor: '+studioUrl);
|
|
578
|
+
const shouldOpen=!flags['no-open']&&!process.env.CI&&Boolean(process.stdout.isTTY);
|
|
579
|
+
if(shouldOpen&&openBrowser(studioUrl)){
|
|
580
|
+
globalThis.console.log('Opening Tora Studio in your browser… (Press Ctrl+C here to stop Studio)');
|
|
581
|
+
}
|
|
288
582
|
return 0;
|
|
289
583
|
}
|
|
290
584
|
if(sub==='doctor')return runDoctor(flags);
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"globalName": "ToraNative"
|
|
28
28
|
},
|
|
29
29
|
"inputs": [
|
|
30
|
-
"scripts/lean/
|
|
30
|
+
"scripts/lean/matrix.mjs",
|
|
31
31
|
"scripts/lean/native/match-board.mjs",
|
|
32
32
|
"scripts/lean/native/interaction-gestures.mjs",
|
|
33
33
|
"scripts/lean/native/instance-steering.mjs",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"scripts/lean/native/physics-3d.mjs",
|
|
38
38
|
"node_modules/three/build/three.core.js",
|
|
39
39
|
"node_modules/three/build/three.module.js",
|
|
40
|
+
"scripts/lean/native/glb-loader.mjs",
|
|
40
41
|
"scripts/lean/native/stage-3d.mjs",
|
|
41
42
|
"scripts/lean/native/path-network.mjs",
|
|
42
43
|
"scripts/lean/native/pixel-text.mjs",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"packages/adapters/src/tiktok.ts",
|
|
52
53
|
"scripts/lean/native/runtime.mjs"
|
|
53
54
|
],
|
|
54
|
-
"javascriptBytes":
|
|
55
|
-
"sha256": "sha256:
|
|
55
|
+
"javascriptBytes": 888259,
|
|
56
|
+
"sha256": "sha256:551ce22177e6290a2b8b83fb38d5819ff7ee4157b4b36e6ab38329444ebb7243",
|
|
56
57
|
"externalImports": []
|
|
57
58
|
}
|