@tora-editor/tora 0.2.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 +5 -6
- package/bin/tora.mjs +255 -29
- package/crates/packer/trusted/native-3d-meta.json +3 -3
- package/crates/packer/trusted/native-3d.js +180 -180
- 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 +3 -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 -106
- package/docs/TORA_CREATION_API.md +63 -365
- package/docs/reference/CORE_AUTHORING.md +8 -2
- package/docs/reference/PLAYABLE_STARTERS.md +1 -1
- package/docs/reference/packs/3d.md +2 -0
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +108 -1
- 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 +246 -68
- package/scripts/lean/editor/review-editor.js +1731 -1099
- 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 +35 -58
- package/scripts/lean/native/api.mjs +148 -134
- 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 +36 -5
- package/scripts/lean/native/contracts.mjs +8 -6
- package/scripts/lean/native/creative-qa.mjs +66 -12
- package/scripts/lean/native/demos.mjs +11 -20
- package/scripts/lean/native/document.mjs +14 -2
- package/scripts/lean/native/local-bundle.mjs +4 -2
- package/scripts/lean/native/mcp-server.mjs +16 -35
- 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/project-bundle.mjs +3 -2
- 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/review.mjs +203 -572
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +1 -1
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +242 -70
- package/scripts/lean/native/starters.mjs +135 -8
- 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 +1 -1
- 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 -143
- package/scripts/lean/native/author-fps.mjs +0 -545
- 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 -875
- 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 -190
- package/scripts/lean/native/check-salvage.mjs +0 -200
- 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/glb-loader.mjs +0 -468
- 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 -218
- 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-fps-assets.mjs +0 -330
- 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 -1809
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -1121
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Tora — Local MCP-First Playable Ad Framework
|
|
2
2
|
[](https://m8ven.ai/mcp/moosama76-tora-engine-cd3fcm?s=readme)
|
|
3
3
|
|
|
4
|
-
**Build editable, responsive 2D & 3D HTML5 playable ads directly from Claude Code,
|
|
4
|
+
**Build editable, responsive 2D & 3D HTML5 playable ads directly from Claude Code, OpenAI Codex, or Gemini CLI.**
|
|
5
5
|
|
|
6
6
|
- **Fast Local Setup:** Install with `npx` using Node.js `>= 22`. Native binaries and headless Chromium set up automatically.
|
|
7
7
|
- **Works With Your Existing AI Agent:** Connects locally over MCP — no cloud credit burn, no vendor lock-in, and your assets never leave your machine.
|
|
@@ -49,8 +49,6 @@ Run **one** setup command for the AI client you use:
|
|
|
49
49
|
|
|
50
50
|
| AI Client | Command | What it configures |
|
|
51
51
|
|---|---|---|
|
|
52
|
-
| **Perch** | `npx @tora-editor/tora init --client perch` | `.perch/mcp.json` |
|
|
53
|
-
| **Cursor** | `npx @tora-editor/tora init --client cursor` | `.cursor/mcp.json` |
|
|
54
52
|
| **Claude Code** | `npx @tora-editor/tora init --client claude-code` | `claude mcp add` (or `.mcp.json`) |
|
|
55
53
|
| **OpenAI Codex** | `npx @tora-editor/tora init --client codex` | `codex mcp add` |
|
|
56
54
|
| **Gemini CLI** | `npx @tora-editor/tora init --client gemini` | `~/.gemini/settings.json` |
|
|
@@ -59,7 +57,7 @@ Run **one** setup command for the AI client you use:
|
|
|
59
57
|
|
|
60
58
|
`tora init` automatically downloads/verifies the native binary, installs Playwright Chromium if missing, and merges `tora` into your MCP config without overwriting other servers (saving a `.bak` backup).
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
Run `npx @tora-editor/tora doctor` to verify that the local Tora tools return their brief and capabilities. Once that check passes, reopen your AI client in `my-playable` and say **“Create a cooking playable ad with Tora.”** The cooking starter can save a browser draft, an editable project, and a playthrough recording together. Open the HTML to play it and hear the result.
|
|
63
61
|
|
|
64
62
|
Verify your setup, then **restart your AI coding client**:
|
|
65
63
|
|
|
@@ -87,7 +85,7 @@ Launch the local browser Studio UI anytime:
|
|
|
87
85
|
npx @tora-editor/tora editor
|
|
88
86
|
```
|
|
89
87
|
|
|
90
|
-
Open `http://127.0.0.1:8001/?view=new` to
|
|
88
|
+
Open `http://127.0.0.1:8001/?view=new` to open or import projects, create either starter, test your builds at phone aspect ratios, upload assets visually, and pin scoped review notes for your external MCP agent. Tora runs no embedded model provider. The lean npm installation omits showcase asset packs; use the hosted showcase or a source checkout for demos.
|
|
91
89
|
|
|
92
90
|
---
|
|
93
91
|
|
|
@@ -157,7 +155,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
|
157
155
|
|
|
158
156
|
## Documentation
|
|
159
157
|
|
|
160
|
-
- [`docs/TORA_AGENT_SETUP.md`](docs/TORA_AGENT_SETUP.md) — Detailed MCP client setup &
|
|
158
|
+
- [`docs/TORA_AGENT_SETUP.md`](docs/TORA_AGENT_SETUP.md) — Detailed MCP client setup & 20-tool workflow
|
|
159
|
+
- [`docs/MIGRATION_0_3.md`](docs/MIGRATION_0_3.md) — Removed interfaces and 0.3.0 upgrade notes
|
|
161
160
|
- [`docs/PLAYABLE_BRIEF.md`](docs/PLAYABLE_BRIEF.md) — Creative, audio, and game-feel quality brief
|
|
162
161
|
- [`docs/TORA_CREATION_API.md`](docs/TORA_CREATION_API.md) — HTTP and document authoring contract
|
|
163
162
|
- [`docs/NATIVE_AGENT_TOOLS.md`](docs/NATIVE_AGENT_TOOLS.md) — Compact deterministic agent CLI
|
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 {execFile,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,18 +106,56 @@ 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
|
}
|
|
93
157
|
const servers=existing[serverKey];
|
|
94
|
-
if(serverKey==='servers'&&servers!==undefined&&(!servers||typeof servers!=='object'||Array.isArray(servers))){
|
|
158
|
+
if((serverKey==='servers'||serverKey==='mcp')&&servers!==undefined&&(!servers||typeof servers!=='object'||Array.isArray(servers))){
|
|
95
159
|
throw Error(`Config field "${serverKey}" is not a JSON object: ${filePath}`);
|
|
96
160
|
}
|
|
97
161
|
const next={
|
|
@@ -102,19 +166,128 @@ export async function mergeJsonMcpConfig(filePath,serverName,entry,{dryRun=false
|
|
|
102
166
|
},
|
|
103
167
|
};
|
|
104
168
|
const serialized=JSON.stringify(next,null,2)+'\n';
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
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';
|
|
115
234
|
}
|
|
116
235
|
}
|
|
117
|
-
|
|
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};
|
|
118
291
|
}
|
|
119
292
|
|
|
120
293
|
async function verifyPerchMcp(entry,workspace){
|
|
@@ -189,12 +362,17 @@ async function runDoctor(flags){
|
|
|
189
362
|
const ffmpeg=commandExists('ffmpeg');
|
|
190
363
|
const gstreamer=commandExists('gst-launch-1.0');
|
|
191
364
|
const clientConfigs={
|
|
365
|
+
claudeDesktop:existsSync(claudeDesktopConfigPath()),
|
|
192
366
|
cursorProject:existsSync(resolve(ws,'.cursor/mcp.json')),
|
|
193
367
|
cursorGlobal:existsSync(resolve(homedir(),'.cursor/mcp.json')),
|
|
194
368
|
geminiGlobal:existsSync(resolve(homedir(),'.gemini/settings.json')),
|
|
195
369
|
claudeProject:existsSync(resolve(ws,'.mcp.json')),
|
|
196
370
|
perchProject:existsSync(resolve(ws,'.perch/mcp.json')),
|
|
197
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'})),
|
|
198
376
|
};
|
|
199
377
|
const ok=nodeOk&&Boolean(nativeInfo)&&!nativeError&&storeSafe&&journalSafe;
|
|
200
378
|
const report={
|
|
@@ -228,9 +406,10 @@ async function runDoctor(flags){
|
|
|
228
406
|
async function runInit(flags){
|
|
229
407
|
const ws=resolveWorkspaceRoot(flags.workspace);
|
|
230
408
|
const dryRun=Boolean(flags['dry-run']);
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
|
|
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.`);
|
|
234
413
|
|
|
235
414
|
const nodeMajor=Number(process.versions.node.split('.')[0]);
|
|
236
415
|
if(!Number.isInteger(nodeMajor)||nodeMajor<22)throw Error(`Node >= 22 is required (found ${process.versions.node})`);
|
|
@@ -263,14 +442,19 @@ async function runInit(flags){
|
|
|
263
442
|
}
|
|
264
443
|
|
|
265
444
|
const entry=buildMcpClientEntry({workspaceRoot:ws,localBin:Boolean(flags['local-bin']||IS_SOURCE_CHECKOUT)});
|
|
266
|
-
const targets=client==='all'?['cursor','gemini','claude-code','codex','perch']:client==='print'?[]:[client];
|
|
267
|
-
// Perch
|
|
268
|
-
const
|
|
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};
|
|
269
449
|
if(targets.includes('perch')&&!dryRun)await verifyPerchMcp(perchEntry,ws);
|
|
270
450
|
const results=[];
|
|
271
451
|
|
|
272
452
|
for(const target of targets){
|
|
273
|
-
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'){
|
|
274
458
|
const cfgPath=flags.global?resolve(homedir(),'.cursor/mcp.json'):resolve(ws,'.cursor/mcp.json');
|
|
275
459
|
const merged=await mergeJsonMcpConfig(cfgPath,'tora',entry,{dryRun});
|
|
276
460
|
results.push({client:'cursor',action:dryRun?'dry-run':'written',path:merged.path});
|
|
@@ -291,6 +475,18 @@ async function runInit(flags){
|
|
|
291
475
|
const cfgPath=flags.global?resolve(homedir(),'.claude.json'):resolve(ws,'.mcp.json');
|
|
292
476
|
const merged=await mergeJsonMcpConfig(cfgPath,'tora',entry,{dryRun});
|
|
293
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});
|
|
294
490
|
}else if(target==='codex'){
|
|
295
491
|
if(!dryRun&&commandExists('codex')){
|
|
296
492
|
const res=spawnSync('codex',['mcp','add','tora','--',entry.command,...entry.args],{cwd:ws,stdio:'inherit'});
|
|
@@ -301,14 +497,27 @@ async function runInit(flags){
|
|
|
301
497
|
}
|
|
302
498
|
}
|
|
303
499
|
|
|
304
|
-
if(client==='print'||(dryRun
|
|
500
|
+
if(client==='print'||(dryRun&&!['perch','opencode','hermes','deepseek-harness'].includes(client))){
|
|
501
|
+
const previewEntry=client==='claude-desktop'?directEntry:entry;
|
|
305
502
|
globalThis.console.log('\nMCP server entry:');
|
|
306
|
-
globalThis.console.log(JSON.stringify({mcpServers:{tora:
|
|
503
|
+
globalThis.console.log(JSON.stringify({mcpServers:{tora:previewEntry}},null,2));
|
|
307
504
|
}
|
|
308
505
|
if(dryRun&&targets.includes('perch')){
|
|
309
506
|
globalThis.console.log('\nPerch server entry:');
|
|
310
507
|
globalThis.console.log(JSON.stringify({servers:{tora:perchEntry}},null,2));
|
|
311
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)}`);
|
|
520
|
+
}
|
|
312
521
|
for(const r of results){
|
|
313
522
|
if(r.command)globalThis.console.log(`[${r.client}] Run: ${r.command}`);
|
|
314
523
|
else globalThis.console.log(`[${r.client}] ${r.action}${r.path?`: ${r.path}`:''}`);
|
|
@@ -316,6 +525,18 @@ async function runInit(flags){
|
|
|
316
525
|
if(!dryRun&&targets.includes('perch')){
|
|
317
526
|
globalThis.console.log('Verified Tora brief and capabilities. Reopen Perch in this folder, then describe the playable you want.');
|
|
318
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
|
+
}
|
|
319
540
|
return 0;
|
|
320
541
|
}
|
|
321
542
|
|
|
@@ -352,7 +573,12 @@ export async function runCli(argv=process.argv.slice(2)){
|
|
|
352
573
|
const {startEditor}=await import('../scripts/serve-editor.mjs');
|
|
353
574
|
const port=flags.port!==undefined?Number(flags.port):Number(process.env.EDITOR_PORT??8001);
|
|
354
575
|
const {url}=await startEditor({port,workspaceRoot:flags.workspace,storeRoot:flags.store});
|
|
355
|
-
|
|
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
|
+
}
|
|
356
582
|
return 0;
|
|
357
583
|
}
|
|
358
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",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"packages/adapters/src/tiktok.ts",
|
|
53
53
|
"scripts/lean/native/runtime.mjs"
|
|
54
54
|
],
|
|
55
|
-
"javascriptBytes":
|
|
56
|
-
"sha256": "sha256:
|
|
55
|
+
"javascriptBytes": 888259,
|
|
56
|
+
"sha256": "sha256:551ce22177e6290a2b8b83fb38d5819ff7ee4157b4b36e6ab38329444ebb7243",
|
|
57
57
|
"externalImports": []
|
|
58
58
|
}
|