create-threenative 0.2.18 → 0.2.21
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/agent-docs/references/assertion-reference.md +1 -1
- package/agent-docs/references/capability-reference.md +792 -5
- package/agent-docs/references/kit-racing.md +4 -2
- package/agent-docs/references/performance-basics.md +2 -1
- package/agent-docs/references/terrain-authoring.md +25 -7
- package/agent-files/.agents/skills/prd-creator/SKILL.md +24 -0
- package/dist/index.js +268 -237
- package/dist/quality.d.ts +5 -1
- package/dist/quality.js +75 -6
- package/dist/terrain-kit.js +1 -1
- package/dist/threenative.js +7 -5
- package/dist/web-engine-post-effects.js +6 -0
- package/dist/web-engine-runtime.js +407 -38
- package/package.json +6 -6
- package/template-assets/assets/floor-fern-0.glb +0 -0
- package/template-assets/assets/floor-litter-0.glb +0 -0
- package/template-assets/assets/floor-log-0.glb +0 -0
- package/template-assets/assets/floor-log-1.glb +0 -0
- package/template-assets/assets/floor-stump-0.glb +0 -0
- package/template-assets/assets/floor-twig-0.glb +0 -0
- package/template-assets/patches/three@0.187.0.patch +108 -21
- package/template-assets/quality/eslint.config.js +1 -1
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/src/loot/drops.ts +3 -7
- package/templates/action-rpg/src/render/camera.ts +2 -2
- package/templates/action-rpg/src/render/clouds.ts +3 -1
- package/templates/action-rpg/src/render/materials.ts +3 -2
- package/templates/action-rpg/src/render/touch-controls.ts +7 -6
- package/templates/action-rpg/src/scenes/Play.ts +1 -15
- package/templates/adventure/AGENTS.md +3 -3
- package/templates/adventure/CLAUDE.md +3 -3
- package/templates/adventure/native-playtests/survives.playtest.json +12 -0
- package/templates/adventure/native-playtests/woodland-floor.playtest.json +61 -0
- package/templates/adventure/package.json +7 -7
- package/templates/adventure/playtests/grass.playtest.json +61 -0
- package/templates/adventure/playtests/performance.playtest.json +1 -1
- package/templates/adventure/playtests/survives.playtest.json +2 -2
- package/templates/adventure/playtests/woodland-floor.playtest.json +61 -0
- package/templates/adventure/src/entities/LockOn.ts +42 -4
- package/templates/adventure/src/entities/Warden.ts +12 -3
- package/templates/adventure/src/level/Vale.ts +241 -16
- package/templates/adventure/src/render/camera.ts +2 -2
- package/templates/adventure/src/render/foliage.ts +64 -20
- package/templates/adventure/src/render/grass.ts +325 -0
- package/templates/adventure/src/render/materials.ts +3 -2
- package/templates/adventure/src/render/palette.ts +3 -0
- package/templates/adventure/src/render/touch-controls.ts +4 -1
- package/templates/adventure/src/scenes/Play.ts +96 -1
- package/templates/collectathon/package.json +7 -7
- package/templates/collectathon/src/level/Course.ts +2 -7
- package/templates/collectathon/src/level/terrain.ts +2 -1
- package/templates/collectathon/src/render/camera.ts +2 -2
- package/templates/collectathon/src/render/ground.ts +4 -4
- package/templates/collectathon/src/render/hero.ts +1 -1
- package/templates/collectathon/src/render/materials.ts +0 -1
- package/templates/collectathon/src/render/sky.ts +4 -3
- package/templates/kart/package.json +6 -6
- package/templates/kart/src/entities/Kart.ts +2 -1
- package/templates/kart/src/render/course.ts +2 -1
- package/templates/kart/src/track/Course.ts +3 -1
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/src/render/camera.ts +2 -2
- package/templates/minimal/src/render/clouds.ts +3 -1
- package/templates/minimal/src/render/materials.ts +3 -2
- package/templates/minimal/src/render/touch-controls.ts +7 -6
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/collect.playtest.json +4 -1
- package/templates/platformer/src/level/Stage.ts +2 -6
- package/templates/platformer/src/scenes/Play.ts +2 -1
- package/templates/puzzle/package.json +7 -7
- package/templates/puzzle/src/entities/Warden.ts +3 -3
- package/templates/puzzle/src/render/camera.ts +2 -2
- package/templates/puzzle/src/render/touch-controls.ts +7 -6
- package/templates/racing/AGENTS.md +2 -2
- package/templates/racing/CLAUDE.md +2 -2
- package/templates/racing/CREDITS.md +29 -0
- package/templates/racing/assets/engine-loop.wav +0 -0
- package/templates/racing/assets/grass/Grass004_color.jpg +0 -0
- package/templates/racing/assets/grass/Grass004_normal.jpg +0 -0
- package/templates/racing/assets/grass/Grass004_roughness.jpg +0 -0
- package/templates/racing/assets/nitro-burst.wav +0 -0
- package/templates/racing/assets/tyre-squeal.wav +0 -0
- package/templates/racing/package.json +7 -7
- package/templates/racing/playtests/drift-natural.playtest.json +68 -0
- package/templates/racing/playtests/drift.playtest.json +100 -0
- package/templates/racing/playtests/hud.playtest.json +117 -0
- package/templates/racing/playtests/launch-pose.playtest.json +34 -0
- package/templates/racing/playtests/nitro.playtest.json +158 -0
- package/templates/racing/playtests/outcome.playtest.json +4 -4
- package/templates/racing/playtests/performance.playtest.json +1 -1
- package/templates/racing/playtests/steady-camera.playtest.json +88 -0
- package/templates/racing/src/audio/engine.ts +138 -0
- package/templates/racing/src/entities/CarBody.ts +83 -10
- package/templates/racing/src/entities/Drift.ts +243 -0
- package/templates/racing/src/entities/LineDriver.ts +2 -2
- package/templates/racing/src/entities/Nitro.ts +72 -0
- package/templates/racing/src/entities/RacingCar.ts +86 -21
- package/templates/racing/src/entities/Rival.ts +35 -21
- package/templates/racing/src/game.ts +6 -0
- package/templates/racing/src/gauges.ts +74 -0
- package/templates/racing/src/render/camera.ts +29 -4
- package/templates/racing/src/render/clouds.ts +3 -1
- package/templates/racing/src/render/effects.ts +244 -0
- package/templates/racing/src/render/materials.ts +43 -8
- package/templates/racing/src/render/shapes.ts +37 -0
- package/templates/racing/src/render/skids.ts +84 -0
- package/templates/racing/src/render/touch-controls.ts +10 -10
- package/templates/racing/src/scenes/Race.ts +277 -25
- package/templates/racing/src/state.ts +35 -0
- package/templates/racing/src/style.css +3 -0
- package/templates/racing/src/track/Ranking.ts +8 -4
- package/templates/racing/src/track/Track.ts +132 -58
- package/templates/racing/src/track/TrackSector.ts +19 -1
- package/templates/racing/src/track/circuit.ts +21 -15
- package/templates/racing/src/ui/GameUi.tsx +0 -2
- package/templates/racing/src/ui/Hud.tsx +417 -50
- package/templates/racing/threenative.config.ts +15 -0
- package/templates/racing/tools/make-racing-audio.mjs +388 -0
- package/templates/rain/package.json +6 -6
- package/templates/rain/src/render/noise-volume.ts +2 -1
- package/templates/rain/src/state.ts +3 -1
- package/templates/rain/src/ui/GameUi.tsx +1 -1
- package/templates/rain/src/ui/automation.ts +10 -8
- package/templates/rain/src/ui/tempest.ts +3 -4
- package/templates/rts/package.json +6 -6
- package/templates/rts/src/sim/terrain.ts +1 -0
- package/templates/rts/src/sim/types.ts +1 -0
- package/templates/runner/package.json +7 -7
- package/templates/runner/src/render/clouds.ts +3 -1
- package/templates/runner/src/render/materials.ts +3 -2
- package/templates/runner/src/render/touch-controls.ts +7 -6
- package/templates/runner/src/scenes/Run.ts +4 -9
- package/templates/sailing/package.json +7 -7
- package/templates/sailing/src/render/touch-controls.ts +7 -6
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/src/render/clouds.ts +3 -1
- package/templates/snow/package.json +7 -7
- package/templates/snow/src/entities/Explorer.ts +6 -12
- package/templates/snow/src/render/bootPrint.ts +3 -1
- package/templates/snow/src/render/camera.ts +3 -2
- package/templates/snow/src/render/scenery.ts +3 -3
- package/templates/snow/src/render/touch-controls.ts +7 -6
- package/templates/snow/src/render/weather.ts +3 -5
- package/templates/snow/src/terrain.ts +2 -1
- package/templates/starter/native-playtests/render-chain.playtest.json +9 -9
- package/templates/starter/package.json +7 -7
- package/templates/starter/src/entities/Player.ts +10 -2
- package/templates/starter/src/render/camera.ts +2 -2
- package/templates/starter/src/render/clouds.ts +3 -1
- package/templates/starter/src/render/materials.ts +3 -2
- package/templates/starter/src/render/touch-controls.ts +7 -6
- package/templates/starter/src/scenes/Play.ts +1 -14
- package/templates/tower-defense/package.json +7 -7
- package/templates/tower-defense/src/render/shapes.ts +1 -2
- package/templates/tower-defense/src/scenes/Battle.ts +3 -8
- package/template-assets/terrain/alpine/assets.json +0 -12
- package/template-assets/terrain/alpine/bake.mjs +0 -6
- package/template-assets/terrain/alpine/credits.json +0 -164
- package/template-assets/terrain/alpine/heightmap.r16 +0 -0
- package/template-assets/terrain/alpine/recipe.json +0 -119
- package/template-assets/terrain/alpine/surface.json +0 -53
- package/template-assets/terrain/coastal/assets.json +0 -11
- package/template-assets/terrain/coastal/bake.mjs +0 -6
- package/template-assets/terrain/coastal/credits.json +0 -117
- package/template-assets/terrain/coastal/heightmap.r16 +0 -0
- package/template-assets/terrain/coastal/recipe.json +0 -113
- package/template-assets/terrain/coastal/surface.json +0 -41
- package/template-assets/terrain/desert/assets.json +0 -12
- package/template-assets/terrain/desert/bake.mjs +0 -6
- package/template-assets/terrain/desert/credits.json +0 -164
- package/template-assets/terrain/desert/heightmap.r16 +0 -0
- package/template-assets/terrain/desert/recipe.json +0 -108
- package/template-assets/terrain/desert/surface.json +0 -54
- package/template-assets/terrain/forest/assets.json +0 -65
- package/template-assets/terrain/forest/bake.mjs +0 -8
- package/template-assets/terrain/forest/credits.json +0 -225
- package/template-assets/terrain/forest/heightmap.r16 +0 -0
- package/template-assets/terrain/forest/recipe.json +0 -350
- package/template-assets/terrain/forest/surface.json +0 -79
- package/template-assets/terrain/tundra/assets.json +0 -12
- package/template-assets/terrain/tundra/bake.mjs +0 -6
- package/template-assets/terrain/tundra/credits.json +0 -164
- package/template-assets/terrain/tundra/heightmap.r16 +0 -0
- package/template-assets/terrain/tundra/recipe.json +0 -277
- package/template-assets/terrain/tundra/surface.json +0 -54
- package/templates/racing/src/ui/Menu.tsx +0 -7
package/dist/index.js
CHANGED
|
@@ -12,6 +12,259 @@ import { createRequire as createRequire$1 } from 'module';
|
|
|
12
12
|
import { parsePng, parseAudioConfig } from '@threenative/assets';
|
|
13
13
|
|
|
14
14
|
createRequire(import.meta.url);
|
|
15
|
+
|
|
16
|
+
// ../core/mcp/servers.mjs
|
|
17
|
+
var MCP_SERVERS = Object.freeze({
|
|
18
|
+
"threenative-assets": Object.freeze({
|
|
19
|
+
command: "node",
|
|
20
|
+
args: Object.freeze(["./node_modules/@threenative/core/mcp/assets.mjs"]),
|
|
21
|
+
// Entries rather than an object literal: these are environment variable names, not identifiers,
|
|
22
|
+
// and written as property names they read as names the naming rule must judge.
|
|
23
|
+
env: Object.freeze(
|
|
24
|
+
Object.fromEntries([
|
|
25
|
+
["ASSET_DOWNLOAD_DIR", "./public/assets"],
|
|
26
|
+
["AUDIO_DOWNLOAD_DIR", "./public/audio"]
|
|
27
|
+
])
|
|
28
|
+
)
|
|
29
|
+
}),
|
|
30
|
+
"threenative-sculpt": Object.freeze({
|
|
31
|
+
command: "node",
|
|
32
|
+
args: Object.freeze(["./node_modules/@threenative/core/mcp/sculpt.mjs"])
|
|
33
|
+
}),
|
|
34
|
+
"threenative-engine": Object.freeze({
|
|
35
|
+
command: "node",
|
|
36
|
+
args: Object.freeze(["./node_modules/@threenative/core/mcp/engine.mjs"])
|
|
37
|
+
}),
|
|
38
|
+
// Cooks a starter terrain kit into a world.glb. The server lives in the optional
|
|
39
|
+
// `@threenative/terrain` package, which the shim resolves from the project at launch.
|
|
40
|
+
"threenative-terrain": Object.freeze({
|
|
41
|
+
command: "node",
|
|
42
|
+
args: Object.freeze(["./node_modules/@threenative/core/mcp/terrain.mjs"])
|
|
43
|
+
}),
|
|
44
|
+
// Inspects, attaches, edits and verifies character animation. Every operation is a build-time
|
|
45
|
+
// edit of one GLB, so a game that animates nothing pays for nothing.
|
|
46
|
+
"threenative-animation": Object.freeze({
|
|
47
|
+
command: "node",
|
|
48
|
+
args: Object.freeze(["./node_modules/@threenative/core/mcp/animation.mjs"])
|
|
49
|
+
}),
|
|
50
|
+
// Google's Chrome DevTools server: performance traces, GPU timing, network, heap and console of
|
|
51
|
+
// the running game. It starts Chrome only on its first tool call, so a project that never
|
|
52
|
+
// inspects a page pays nothing. Its async stack capture inflates CPU time several times, so
|
|
53
|
+
// `trace-a-slow-frame.md` sends absolute CPU questions to `playtest trace` first.
|
|
54
|
+
"threenative-devtools": Object.freeze({
|
|
55
|
+
command: "node",
|
|
56
|
+
args: Object.freeze(["./node_modules/@threenative/core/mcp/devtools.mjs"])
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
var SERVER_FORMATS = Object.freeze({
|
|
60
|
+
// Claude Code (`.mcp.json`), Cursor and the Gemini CLI all read this one.
|
|
61
|
+
mcpServers: Object.freeze({
|
|
62
|
+
key: "mcpServers",
|
|
63
|
+
entry: (server) => ({
|
|
64
|
+
command: server.command,
|
|
65
|
+
args: [...server.args],
|
|
66
|
+
...server.env === void 0 ? {} : { env: { ...server.env } }
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
69
|
+
// VS Code names the table `servers` and requires an explicit transport per server.
|
|
70
|
+
vscode: Object.freeze({
|
|
71
|
+
key: "servers",
|
|
72
|
+
entry: (server) => ({
|
|
73
|
+
type: "stdio",
|
|
74
|
+
command: server.command,
|
|
75
|
+
args: [...server.args],
|
|
76
|
+
...server.env === void 0 ? {} : { env: { ...server.env } }
|
|
77
|
+
})
|
|
78
|
+
}),
|
|
79
|
+
// opencode folds the command and its arguments into one array and spells the environment
|
|
80
|
+
// `environment`. A server it does not mark enabled is written down and never started.
|
|
81
|
+
opencode: Object.freeze({
|
|
82
|
+
key: "mcp",
|
|
83
|
+
entry: (server) => ({
|
|
84
|
+
type: "local",
|
|
85
|
+
command: [server.command, ...server.args],
|
|
86
|
+
enabled: true,
|
|
87
|
+
...server.env === void 0 ? {} : { environment: { ...server.env } }
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
// Zed calls them context servers and needs `source: "custom"` to accept a command of our own.
|
|
91
|
+
zed: Object.freeze({
|
|
92
|
+
key: "context_servers",
|
|
93
|
+
entry: (server) => ({
|
|
94
|
+
source: "custom",
|
|
95
|
+
command: server.command,
|
|
96
|
+
args: [...server.args],
|
|
97
|
+
...server.env === void 0 ? {} : { env: { ...server.env } }
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
Object.freeze(Object.keys(SERVER_FORMATS));
|
|
102
|
+
function mergeMcpServers(existing, format = "mcpServers") {
|
|
103
|
+
const shape = SERVER_FORMATS[format];
|
|
104
|
+
if (shape === void 0) throw new Error(`Unknown MCP config format '${format}'.`);
|
|
105
|
+
const malformed = existing !== void 0 && (typeof existing !== "object" || existing === null || Array.isArray(existing));
|
|
106
|
+
if (malformed) {
|
|
107
|
+
throw new Error("MCP config root must be an object.");
|
|
108
|
+
}
|
|
109
|
+
const previous = existing ?? {};
|
|
110
|
+
const existingServers = previous[shape.key];
|
|
111
|
+
if (existingServers !== void 0 && (typeof existingServers !== "object" || existingServers === null || Array.isArray(existingServers))) {
|
|
112
|
+
throw new Error(`MCP config '${shape.key}' must be an object.`);
|
|
113
|
+
}
|
|
114
|
+
const servers = { ...existingServers ?? {} };
|
|
115
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
116
|
+
if (typeof server !== "object" || server === null || Array.isArray(server)) {
|
|
117
|
+
throw new Error(`MCP server '${name}' in '${shape.key}' must be an object.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let changed = false;
|
|
121
|
+
const conflicts = [];
|
|
122
|
+
for (const [name, server] of Object.entries(MCP_SERVERS)) {
|
|
123
|
+
const wanted = shape.entry(server);
|
|
124
|
+
if (Object.hasOwn(servers, name)) {
|
|
125
|
+
if (JSON.stringify(servers[name]) !== JSON.stringify(wanted)) conflicts.push(name);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
servers[name] = wanted;
|
|
129
|
+
changed = true;
|
|
130
|
+
}
|
|
131
|
+
return { changed, conflicts, config: { ...previous, [shape.key]: servers } };
|
|
132
|
+
}
|
|
133
|
+
function codexServerBlock(name, server) {
|
|
134
|
+
const args = server.args.map((argument) => JSON.stringify(argument)).join(", ");
|
|
135
|
+
const lines = [
|
|
136
|
+
`[mcp_servers.${name}]`,
|
|
137
|
+
`command = ${JSON.stringify(server.command)}`,
|
|
138
|
+
`args = [${args}]`
|
|
139
|
+
];
|
|
140
|
+
if (server.env !== void 0) {
|
|
141
|
+
lines.push("", `[mcp_servers.${name}.env]`);
|
|
142
|
+
for (const [key, value] of Object.entries(server.env)) {
|
|
143
|
+
lines.push(`${key} = ${JSON.stringify(value)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return lines.join("\n");
|
|
147
|
+
}
|
|
148
|
+
var CODEX_MCP_SERVERS = Object.freeze(
|
|
149
|
+
Object.entries(MCP_SERVERS).map(
|
|
150
|
+
([name, server]) => Object.freeze({ body: codexServerBlock(name, server), name })
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// ../core/src/version.ts
|
|
155
|
+
var CORE_VERSION = "0.3.16";
|
|
156
|
+
var MCP_HOSTS = Object.freeze([
|
|
157
|
+
Object.freeze({
|
|
158
|
+
id: "claude-code",
|
|
159
|
+
label: "Claude Code",
|
|
160
|
+
file: ".mcp.json",
|
|
161
|
+
format: "mcpServers"
|
|
162
|
+
}),
|
|
163
|
+
Object.freeze({ id: "codex", label: "Codex", file: ".codex/config.toml", format: "codex" }),
|
|
164
|
+
Object.freeze({ id: "cursor", label: "Cursor", file: ".cursor/mcp.json", format: "mcpServers" }),
|
|
165
|
+
Object.freeze({ id: "vscode", label: "VS Code", file: ".vscode/mcp.json", format: "vscode" }),
|
|
166
|
+
Object.freeze({
|
|
167
|
+
id: "gemini-cli",
|
|
168
|
+
label: "Gemini CLI",
|
|
169
|
+
file: ".gemini/settings.json",
|
|
170
|
+
format: "mcpServers"
|
|
171
|
+
}),
|
|
172
|
+
Object.freeze({
|
|
173
|
+
id: "opencode",
|
|
174
|
+
label: "opencode",
|
|
175
|
+
file: "opencode.json",
|
|
176
|
+
format: "opencode",
|
|
177
|
+
// Written only when this installer creates the file, so a second install still reports
|
|
178
|
+
// "unchanged" rather than rewriting a config the user has since edited.
|
|
179
|
+
seed: Object.freeze({ $schema: "https://opencode.ai/config.json" })
|
|
180
|
+
}),
|
|
181
|
+
Object.freeze({ id: "zed", label: "Zed", file: ".zed/settings.json", format: "zed" })
|
|
182
|
+
]);
|
|
183
|
+
function ensureJsonMcpConfig(target, file, format, seed = void 0) {
|
|
184
|
+
const configPath = path8.join(target, file);
|
|
185
|
+
let existing;
|
|
186
|
+
if (existsSync(configPath)) {
|
|
187
|
+
try {
|
|
188
|
+
existing = JSON.parse(readFileSync(configPath, "utf8"));
|
|
189
|
+
} catch {
|
|
190
|
+
return "unreadable";
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
let merged;
|
|
194
|
+
try {
|
|
195
|
+
merged = mergeMcpServers(existing, format);
|
|
196
|
+
} catch {
|
|
197
|
+
return "unreadable";
|
|
198
|
+
}
|
|
199
|
+
const { changed, config, conflicts } = merged;
|
|
200
|
+
if (!changed) return conflicts.length > 0 ? "conflict" : "unchanged";
|
|
201
|
+
const written = existing === void 0 ? { ...seed, ...config } : config;
|
|
202
|
+
mkdirSync(path8.dirname(configPath), { recursive: true });
|
|
203
|
+
writeFileSync(configPath, `${JSON.stringify(written, null, 2)}
|
|
204
|
+
`);
|
|
205
|
+
return conflicts.length > 0 ? "conflict" : existing === void 0 ? "created" : "updated";
|
|
206
|
+
}
|
|
207
|
+
function ensureCodexMcpConfig(target) {
|
|
208
|
+
const directory = path8.join(target, ".codex");
|
|
209
|
+
const configPath = path8.join(directory, "config.toml");
|
|
210
|
+
const existing = existsSync(configPath) ? readFileSync(configPath, "utf8") : "";
|
|
211
|
+
const missing = CODEX_MCP_SERVERS.filter(
|
|
212
|
+
({ name }) => !existing.includes(`[mcp_servers.${name}]`)
|
|
213
|
+
);
|
|
214
|
+
if (missing.length === 0) return "unchanged";
|
|
215
|
+
mkdirSync(directory, { recursive: true });
|
|
216
|
+
const separator = existing.length === 0 || existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
217
|
+
writeFileSync(
|
|
218
|
+
configPath,
|
|
219
|
+
`${existing}${separator}${missing.map(({ body }) => body).join("\n\n")}
|
|
220
|
+
`
|
|
221
|
+
);
|
|
222
|
+
return existing.length === 0 ? "created" : "updated";
|
|
223
|
+
}
|
|
224
|
+
function ensureHostMcpConfigs(target) {
|
|
225
|
+
const outcomes = /* @__PURE__ */ new Map();
|
|
226
|
+
for (const host of MCP_HOSTS) {
|
|
227
|
+
try {
|
|
228
|
+
outcomes.set(
|
|
229
|
+
host.id,
|
|
230
|
+
host.format === "codex" ? ensureCodexMcpConfig(target) : ensureJsonMcpConfig(target, host.file, host.format, host.seed)
|
|
231
|
+
);
|
|
232
|
+
} catch {
|
|
233
|
+
outcomes.set(host.id, "unreadable");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return outcomes;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/mcp-servers.ts
|
|
240
|
+
var CORE_PACKAGE_NAME = "@threenative/core";
|
|
241
|
+
var CORE_PACKAGE_VERSION = CORE_VERSION;
|
|
242
|
+
function serverEntryPath(server) {
|
|
243
|
+
const entry = server.args[0];
|
|
244
|
+
if (entry === void 0) {
|
|
245
|
+
throw new Error("TN_MCP_TABLE: an MCP server entry declares no shim to launch.");
|
|
246
|
+
}
|
|
247
|
+
return entry;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/core-pair.ts
|
|
251
|
+
function parts(value) {
|
|
252
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/u.exec(value.trim());
|
|
253
|
+
if (match === null) return void 0;
|
|
254
|
+
const parsed = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
255
|
+
return parsed.every(Number.isSafeInteger) ? parsed : void 0;
|
|
256
|
+
}
|
|
257
|
+
function pairsWithCore(installed) {
|
|
258
|
+
if (installed === void 0) return false;
|
|
259
|
+
const have = parts(installed);
|
|
260
|
+
const paired = parts(CORE_PACKAGE_VERSION);
|
|
261
|
+
if (have === void 0 || paired === void 0) return false;
|
|
262
|
+
const [haveMajor, haveMinor, havePatch] = have;
|
|
263
|
+
const [pairedMajor, pairedMinor, pairedPatch] = paired;
|
|
264
|
+
if (haveMajor !== pairedMajor) return haveMajor > pairedMajor;
|
|
265
|
+
if (haveMinor !== pairedMinor) return haveMinor > pairedMinor;
|
|
266
|
+
return havePatch >= pairedPatch;
|
|
267
|
+
}
|
|
15
268
|
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([".glb", ".gltf"]);
|
|
16
269
|
var METRE_UPPER_BOUND = 10;
|
|
17
270
|
var CENTIMETRE_LOWER_BOUND = 100;
|
|
@@ -289,240 +542,6 @@ async function inspectCommand(argv, write = (text) => process.stdout.write(text)
|
|
|
289
542
|
` : formatAssetInspection(result));
|
|
290
543
|
return result;
|
|
291
544
|
}
|
|
292
|
-
|
|
293
|
-
// ../core/mcp/servers.mjs
|
|
294
|
-
var MCP_SERVERS = Object.freeze({
|
|
295
|
-
"threenative-assets": Object.freeze({
|
|
296
|
-
command: "node",
|
|
297
|
-
args: Object.freeze(["./node_modules/@threenative/core/mcp/assets.mjs"]),
|
|
298
|
-
// Entries rather than an object literal: these are environment variable names, not identifiers,
|
|
299
|
-
// and written as property names they read as names the naming rule must judge.
|
|
300
|
-
env: Object.freeze(
|
|
301
|
-
Object.fromEntries([
|
|
302
|
-
["ASSET_DOWNLOAD_DIR", "./public/assets"],
|
|
303
|
-
["AUDIO_DOWNLOAD_DIR", "./public/audio"]
|
|
304
|
-
])
|
|
305
|
-
)
|
|
306
|
-
}),
|
|
307
|
-
"threenative-sculpt": Object.freeze({
|
|
308
|
-
command: "node",
|
|
309
|
-
args: Object.freeze(["./node_modules/@threenative/core/mcp/sculpt.mjs"])
|
|
310
|
-
}),
|
|
311
|
-
"threenative-engine": Object.freeze({
|
|
312
|
-
command: "node",
|
|
313
|
-
args: Object.freeze(["./node_modules/@threenative/core/mcp/engine.mjs"])
|
|
314
|
-
}),
|
|
315
|
-
// Cooks a starter terrain kit into a world.glb. The server lives in the optional
|
|
316
|
-
// `@threenative/terrain` package, which the shim resolves from the project at launch.
|
|
317
|
-
"threenative-terrain": Object.freeze({
|
|
318
|
-
command: "node",
|
|
319
|
-
args: Object.freeze(["./node_modules/@threenative/core/mcp/terrain.mjs"])
|
|
320
|
-
}),
|
|
321
|
-
// Inspects, attaches, edits and verifies character animation. Every operation is a build-time
|
|
322
|
-
// edit of one GLB, so a game that animates nothing pays for nothing.
|
|
323
|
-
"threenative-animation": Object.freeze({
|
|
324
|
-
command: "node",
|
|
325
|
-
args: Object.freeze(["./node_modules/@threenative/core/mcp/animation.mjs"])
|
|
326
|
-
}),
|
|
327
|
-
// Google's Chrome DevTools server: performance traces, GPU timing, network, heap and console of
|
|
328
|
-
// the running game. It starts Chrome only on its first tool call, so a project that never
|
|
329
|
-
// inspects a page pays nothing. Its async stack capture inflates CPU time several times, so
|
|
330
|
-
// `trace-a-slow-frame.md` sends absolute CPU questions to `playtest trace` first.
|
|
331
|
-
"threenative-devtools": Object.freeze({
|
|
332
|
-
command: "node",
|
|
333
|
-
args: Object.freeze(["./node_modules/@threenative/core/mcp/devtools.mjs"])
|
|
334
|
-
})
|
|
335
|
-
});
|
|
336
|
-
var SERVER_FORMATS = Object.freeze({
|
|
337
|
-
// Claude Code (`.mcp.json`), Cursor and the Gemini CLI all read this one.
|
|
338
|
-
mcpServers: Object.freeze({
|
|
339
|
-
key: "mcpServers",
|
|
340
|
-
entry: (server) => ({
|
|
341
|
-
command: server.command,
|
|
342
|
-
args: [...server.args],
|
|
343
|
-
...server.env === void 0 ? {} : { env: { ...server.env } }
|
|
344
|
-
})
|
|
345
|
-
}),
|
|
346
|
-
// VS Code names the table `servers` and requires an explicit transport per server.
|
|
347
|
-
vscode: Object.freeze({
|
|
348
|
-
key: "servers",
|
|
349
|
-
entry: (server) => ({
|
|
350
|
-
type: "stdio",
|
|
351
|
-
command: server.command,
|
|
352
|
-
args: [...server.args],
|
|
353
|
-
...server.env === void 0 ? {} : { env: { ...server.env } }
|
|
354
|
-
})
|
|
355
|
-
}),
|
|
356
|
-
// opencode folds the command and its arguments into one array and spells the environment
|
|
357
|
-
// `environment`. A server it does not mark enabled is written down and never started.
|
|
358
|
-
opencode: Object.freeze({
|
|
359
|
-
key: "mcp",
|
|
360
|
-
entry: (server) => ({
|
|
361
|
-
type: "local",
|
|
362
|
-
command: [server.command, ...server.args],
|
|
363
|
-
enabled: true,
|
|
364
|
-
...server.env === void 0 ? {} : { environment: { ...server.env } }
|
|
365
|
-
})
|
|
366
|
-
}),
|
|
367
|
-
// Zed calls them context servers and needs `source: "custom"` to accept a command of our own.
|
|
368
|
-
zed: Object.freeze({
|
|
369
|
-
key: "context_servers",
|
|
370
|
-
entry: (server) => ({
|
|
371
|
-
source: "custom",
|
|
372
|
-
command: server.command,
|
|
373
|
-
args: [...server.args],
|
|
374
|
-
...server.env === void 0 ? {} : { env: { ...server.env } }
|
|
375
|
-
})
|
|
376
|
-
})
|
|
377
|
-
});
|
|
378
|
-
Object.freeze(Object.keys(SERVER_FORMATS));
|
|
379
|
-
function mergeMcpServers(existing, format = "mcpServers") {
|
|
380
|
-
const shape = SERVER_FORMATS[format];
|
|
381
|
-
if (shape === void 0) throw new Error(`Unknown MCP config format '${format}'.`);
|
|
382
|
-
const malformed = existing !== void 0 && (typeof existing !== "object" || existing === null || Array.isArray(existing));
|
|
383
|
-
if (malformed) {
|
|
384
|
-
throw new Error("MCP config root must be an object.");
|
|
385
|
-
}
|
|
386
|
-
const previous = existing ?? {};
|
|
387
|
-
const existingServers = previous[shape.key];
|
|
388
|
-
if (existingServers !== void 0 && (typeof existingServers !== "object" || existingServers === null || Array.isArray(existingServers))) {
|
|
389
|
-
throw new Error(`MCP config '${shape.key}' must be an object.`);
|
|
390
|
-
}
|
|
391
|
-
const servers = { ...existingServers ?? {} };
|
|
392
|
-
for (const [name, server] of Object.entries(servers)) {
|
|
393
|
-
if (typeof server !== "object" || server === null || Array.isArray(server)) {
|
|
394
|
-
throw new Error(`MCP server '${name}' in '${shape.key}' must be an object.`);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
let changed = false;
|
|
398
|
-
const conflicts = [];
|
|
399
|
-
for (const [name, server] of Object.entries(MCP_SERVERS)) {
|
|
400
|
-
const wanted = shape.entry(server);
|
|
401
|
-
if (Object.hasOwn(servers, name)) {
|
|
402
|
-
if (JSON.stringify(servers[name]) !== JSON.stringify(wanted)) conflicts.push(name);
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
servers[name] = wanted;
|
|
406
|
-
changed = true;
|
|
407
|
-
}
|
|
408
|
-
return { changed, conflicts, config: { ...previous, [shape.key]: servers } };
|
|
409
|
-
}
|
|
410
|
-
function codexServerBlock(name, server) {
|
|
411
|
-
const args = server.args.map((argument) => JSON.stringify(argument)).join(", ");
|
|
412
|
-
const lines = [
|
|
413
|
-
`[mcp_servers.${name}]`,
|
|
414
|
-
`command = ${JSON.stringify(server.command)}`,
|
|
415
|
-
`args = [${args}]`
|
|
416
|
-
];
|
|
417
|
-
if (server.env !== void 0) {
|
|
418
|
-
lines.push("", `[mcp_servers.${name}.env]`);
|
|
419
|
-
for (const [key, value] of Object.entries(server.env)) {
|
|
420
|
-
lines.push(`${key} = ${JSON.stringify(value)}`);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
return lines.join("\n");
|
|
424
|
-
}
|
|
425
|
-
var CODEX_MCP_SERVERS = Object.freeze(
|
|
426
|
-
Object.entries(MCP_SERVERS).map(
|
|
427
|
-
([name, server]) => Object.freeze({ body: codexServerBlock(name, server), name })
|
|
428
|
-
)
|
|
429
|
-
);
|
|
430
|
-
|
|
431
|
-
// ../core/src/version.ts
|
|
432
|
-
var CORE_VERSION = "0.3.13";
|
|
433
|
-
var MCP_HOSTS = Object.freeze([
|
|
434
|
-
Object.freeze({
|
|
435
|
-
id: "claude-code",
|
|
436
|
-
label: "Claude Code",
|
|
437
|
-
file: ".mcp.json",
|
|
438
|
-
format: "mcpServers"
|
|
439
|
-
}),
|
|
440
|
-
Object.freeze({ id: "codex", label: "Codex", file: ".codex/config.toml", format: "codex" }),
|
|
441
|
-
Object.freeze({ id: "cursor", label: "Cursor", file: ".cursor/mcp.json", format: "mcpServers" }),
|
|
442
|
-
Object.freeze({ id: "vscode", label: "VS Code", file: ".vscode/mcp.json", format: "vscode" }),
|
|
443
|
-
Object.freeze({
|
|
444
|
-
id: "gemini-cli",
|
|
445
|
-
label: "Gemini CLI",
|
|
446
|
-
file: ".gemini/settings.json",
|
|
447
|
-
format: "mcpServers"
|
|
448
|
-
}),
|
|
449
|
-
Object.freeze({
|
|
450
|
-
id: "opencode",
|
|
451
|
-
label: "opencode",
|
|
452
|
-
file: "opencode.json",
|
|
453
|
-
format: "opencode",
|
|
454
|
-
// Written only when this installer creates the file, so a second install still reports
|
|
455
|
-
// "unchanged" rather than rewriting a config the user has since edited.
|
|
456
|
-
seed: Object.freeze({ $schema: "https://opencode.ai/config.json" })
|
|
457
|
-
}),
|
|
458
|
-
Object.freeze({ id: "zed", label: "Zed", file: ".zed/settings.json", format: "zed" })
|
|
459
|
-
]);
|
|
460
|
-
function ensureJsonMcpConfig(target, file, format, seed = void 0) {
|
|
461
|
-
const configPath = path8.join(target, file);
|
|
462
|
-
let existing;
|
|
463
|
-
if (existsSync(configPath)) {
|
|
464
|
-
try {
|
|
465
|
-
existing = JSON.parse(readFileSync(configPath, "utf8"));
|
|
466
|
-
} catch {
|
|
467
|
-
return "unreadable";
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
let merged;
|
|
471
|
-
try {
|
|
472
|
-
merged = mergeMcpServers(existing, format);
|
|
473
|
-
} catch {
|
|
474
|
-
return "unreadable";
|
|
475
|
-
}
|
|
476
|
-
const { changed, config, conflicts } = merged;
|
|
477
|
-
if (!changed) return conflicts.length > 0 ? "conflict" : "unchanged";
|
|
478
|
-
const written = existing === void 0 ? { ...seed, ...config } : config;
|
|
479
|
-
mkdirSync(path8.dirname(configPath), { recursive: true });
|
|
480
|
-
writeFileSync(configPath, `${JSON.stringify(written, null, 2)}
|
|
481
|
-
`);
|
|
482
|
-
return conflicts.length > 0 ? "conflict" : existing === void 0 ? "created" : "updated";
|
|
483
|
-
}
|
|
484
|
-
function ensureCodexMcpConfig(target) {
|
|
485
|
-
const directory = path8.join(target, ".codex");
|
|
486
|
-
const configPath = path8.join(directory, "config.toml");
|
|
487
|
-
const existing = existsSync(configPath) ? readFileSync(configPath, "utf8") : "";
|
|
488
|
-
const missing = CODEX_MCP_SERVERS.filter(
|
|
489
|
-
({ name }) => !existing.includes(`[mcp_servers.${name}]`)
|
|
490
|
-
);
|
|
491
|
-
if (missing.length === 0) return "unchanged";
|
|
492
|
-
mkdirSync(directory, { recursive: true });
|
|
493
|
-
const separator = existing.length === 0 || existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
494
|
-
writeFileSync(
|
|
495
|
-
configPath,
|
|
496
|
-
`${existing}${separator}${missing.map(({ body }) => body).join("\n\n")}
|
|
497
|
-
`
|
|
498
|
-
);
|
|
499
|
-
return existing.length === 0 ? "created" : "updated";
|
|
500
|
-
}
|
|
501
|
-
function ensureHostMcpConfigs(target) {
|
|
502
|
-
const outcomes = /* @__PURE__ */ new Map();
|
|
503
|
-
for (const host of MCP_HOSTS) {
|
|
504
|
-
try {
|
|
505
|
-
outcomes.set(
|
|
506
|
-
host.id,
|
|
507
|
-
host.format === "codex" ? ensureCodexMcpConfig(target) : ensureJsonMcpConfig(target, host.file, host.format, host.seed)
|
|
508
|
-
);
|
|
509
|
-
} catch {
|
|
510
|
-
outcomes.set(host.id, "unreadable");
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return outcomes;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// src/mcp-servers.ts
|
|
517
|
-
var CORE_PACKAGE_NAME = "@threenative/core";
|
|
518
|
-
var CORE_PACKAGE_VERSION = CORE_VERSION;
|
|
519
|
-
function serverEntryPath(server) {
|
|
520
|
-
const entry = server.args[0];
|
|
521
|
-
if (entry === void 0) {
|
|
522
|
-
throw new Error("TN_MCP_TABLE: an MCP server entry declares no shim to launch.");
|
|
523
|
-
}
|
|
524
|
-
return entry;
|
|
525
|
-
}
|
|
526
545
|
var ORIENTATIONS = ["landscape", "portrait", "sensor"];
|
|
527
546
|
var CONFIG_FILE = "threenative.config.ts";
|
|
528
547
|
var ConfigFailure = class extends Error {
|
|
@@ -1980,6 +1999,7 @@ var ENGINE_ADDON_CLASSES = {
|
|
|
1980
1999
|
};
|
|
1981
2000
|
var ENGINE_ADDON_PREFIX = "\0threenative:web-engine-addon:";
|
|
1982
2001
|
var SKELETON_UTILS_ID = "\0threenative:web-engine-skeleton-utils";
|
|
2002
|
+
var RAPIER_COMPAT_ID = "\0threenative:web-engine-rapier-compat";
|
|
1983
2003
|
var WASM_ENGINE_ENTRY = "build/web/tn-native-engine-web.mjs";
|
|
1984
2004
|
var WASM_THREADS_ENTRY = "build/web/tn-native-engine-web-threads.mjs";
|
|
1985
2005
|
var THREADS_OFF = "TN_WEB_THREADS_OFF";
|
|
@@ -2120,6 +2140,7 @@ function createWebEnginePlugin(options = {}) {
|
|
|
2120
2140
|
const engineClass = ENGINE_ADDON_CLASSES[source];
|
|
2121
2141
|
if (engineClass !== void 0) return ENGINE_ADDON_PREFIX + engineClass;
|
|
2122
2142
|
if (source === "three/addons/utils/SkeletonUtils.js") return SKELETON_UTILS_ID;
|
|
2143
|
+
if (source === "@dimforge/rapier3d-compat") return RAPIER_COMPAT_ID;
|
|
2123
2144
|
if (source === "three-mesh-bvh")
|
|
2124
2145
|
return browserModule("web-engine-mesh-bvh.js", "addons/mesh-bvh.ts");
|
|
2125
2146
|
if (source === "three-mesh-bvh/webgpu")
|
|
@@ -2151,6 +2172,8 @@ function createWebEnginePlugin(options = {}) {
|
|
|
2151
2172
|
if (native && id.startsWith(ENGINE_ADDON_PREFIX))
|
|
2152
2173
|
return `export { ${id.slice(ENGINE_ADDON_PREFIX.length)} } from "three";
|
|
2153
2174
|
`;
|
|
2175
|
+
if (native && id === RAPIER_COMPAT_ID)
|
|
2176
|
+
return 'throw new Error("TN_PHYSICS_COMPAT_EXCLUDED: engine \\"threenative\\" runs physics on the Rapier crate; rapier3d-compat loads only under engine \\"threejs\\".");\n';
|
|
2154
2177
|
if (native && id === SKELETON_UTILS_ID)
|
|
2155
2178
|
return 'import { SkeletonUtils } from "three";\nexport const clone = (source) => SkeletonUtils.clone(source);\n';
|
|
2156
2179
|
if (!native || id !== WEB_ENGINE_ID) return null;
|
|
@@ -2620,7 +2643,15 @@ function createWebBrandPlugin() {
|
|
|
2620
2643
|
const loaded = await loadConfig(path8.resolve(vite.root ?? process.cwd()));
|
|
2621
2644
|
if (loaded.engine === "threenative" && process.env.THREENATIVE_NATIVE_BUNDLE === void 0)
|
|
2622
2645
|
return {
|
|
2623
|
-
optimizeDeps: {
|
|
2646
|
+
optimizeDeps: {
|
|
2647
|
+
exclude: [
|
|
2648
|
+
"three",
|
|
2649
|
+
"three/webgpu",
|
|
2650
|
+
"three/tsl",
|
|
2651
|
+
"three-mesh-bvh",
|
|
2652
|
+
"@threenative/physics"
|
|
2653
|
+
]
|
|
2654
|
+
},
|
|
2624
2655
|
// Vite runs only `worker.plugins` on a worker bundle, so a game booted in a worker
|
|
2625
2656
|
// (PRD-752) needs the same resolver, as ES output for the engine's top-level await.
|
|
2626
2657
|
worker: {
|
|
@@ -3410,10 +3441,10 @@ async function installedCoreVersion(game) {
|
|
|
3410
3441
|
}
|
|
3411
3442
|
async function assertEnginePair(game) {
|
|
3412
3443
|
const installed = await installedCoreVersion(game);
|
|
3413
|
-
if (installed
|
|
3444
|
+
if (pairsWithCore(installed)) return;
|
|
3414
3445
|
const got = installed === void 0 ? "no installed core" : `${CORE_PACKAGE_NAME}@${installed}`;
|
|
3415
3446
|
throw new Error(
|
|
3416
|
-
`TN_AUTHORING_LAYER_PAIR: this create-threenative pairs with ${CORE_PACKAGE_NAME}@${CORE_PACKAGE_VERSION}, and this game installs ${got}. Run '${ENGINE_PAIR_UPGRADE}' first, then 'pnpm exec threenative doctor --fix'.`
|
|
3447
|
+
`TN_AUTHORING_LAYER_PAIR: this create-threenative pairs with ${CORE_PACKAGE_NAME}@${CORE_PACKAGE_VERSION} or newer, and this game installs ${got}. Run '${ENGINE_PAIR_UPGRADE}' first, then 'pnpm exec threenative doctor --fix'.`
|
|
3417
3448
|
);
|
|
3418
3449
|
}
|
|
3419
3450
|
async function authoringLayerStatus(game, root = templateRoot()) {
|
package/dist/quality.d.ts
CHANGED
|
@@ -3,10 +3,14 @@ import { Linter } from 'eslint';
|
|
|
3
3
|
interface IQualityOptions {
|
|
4
4
|
/** The project root: where `tsconfig.json` lives and the typed rules resolve from. */
|
|
5
5
|
readonly root: string;
|
|
6
|
+
/** The reinvention rows (`reinventions.ts`). A scaffolded config turns them on; a game made
|
|
7
|
+
* before they existed passes only `root`, and an upgrade never rewrites that file, so its own
|
|
8
|
+
* code keeps the rules it was made with. */
|
|
9
|
+
readonly reinventions?: boolean;
|
|
6
10
|
}
|
|
7
11
|
/** The default correctness gate for a generated game: TypeScript-aware async rules, React hook
|
|
8
12
|
* rules when React is installed, scoped suppressions, and the ThreeNative game rules (`threenative/*`: frame-callback cost, UI state use).
|
|
9
13
|
* Formatting is Biome's job, not this config's. */
|
|
10
|
-
declare function qualityConfig({ root }: IQualityOptions): Linter.Config[];
|
|
14
|
+
declare function qualityConfig({ root, reinventions }: IQualityOptions): Linter.Config[];
|
|
11
15
|
|
|
12
16
|
export { type IQualityOptions, qualityConfig };
|