create-threenative 0.2.14 → 0.2.17

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.
Files changed (251) hide show
  1. package/agent-docs/kit-mcp.md +10 -0
  2. package/agent-docs/kit-router.md +14 -0
  3. package/agent-docs/kit-stuck.md +7 -0
  4. package/agent-docs/references/capability-reference.md +958 -30
  5. package/agent-docs/references/conventions.md +271 -0
  6. package/agent-docs/references/kit-action-rpg.md +40 -0
  7. package/agent-docs/references/kit-adventure.md +40 -0
  8. package/agent-docs/references/kit-collectathon.md +38 -0
  9. package/agent-docs/references/kit-kart.md +31 -0
  10. package/agent-docs/references/kit-minimal.md +29 -0
  11. package/agent-docs/references/kit-platformer.md +34 -0
  12. package/agent-docs/references/kit-puzzle.md +22 -0
  13. package/agent-docs/references/kit-racing.md +26 -0
  14. package/agent-docs/references/kit-rain.md +31 -0
  15. package/agent-docs/references/kit-rts.md +34 -0
  16. package/agent-docs/references/kit-runner.md +32 -0
  17. package/agent-docs/references/kit-sailing.md +41 -0
  18. package/agent-docs/references/kit-shooter.md +33 -0
  19. package/agent-docs/references/kit-snow.md +33 -0
  20. package/agent-docs/references/kit-starter.md +55 -0
  21. package/agent-docs/references/kit-tower-defense.md +27 -0
  22. package/agent-docs/references/terrain-authoring.md +2 -1
  23. package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
  24. package/agent-files/.agents/skills/prd-creator/SKILL.md +3 -2
  25. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +81 -59
  26. package/agent-files/.claude/hooks/discovery-gate.mjs +125 -0
  27. package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
  28. package/agent-files/.claude/settings.json +25 -0
  29. package/agent-files/.codex/hooks.json +18 -1
  30. package/dist/index.js +256 -120
  31. package/dist/terrain-kit.d.ts +7 -0
  32. package/dist/terrain-kit.js +82 -0
  33. package/dist/threenative.js +23 -4
  34. package/dist/web-engine-gltf-loader.js +20 -7
  35. package/dist/web-engine-post-effects.js +34 -4
  36. package/dist/web-engine-runtime.js +6119 -3311
  37. package/package.json +13 -8
  38. package/template-assets/patches/three@0.187.0.patch +2004 -407
  39. package/templates/action-rpg/AGENTS.md +99 -84
  40. package/templates/action-rpg/CLAUDE.md +99 -84
  41. package/templates/action-rpg/kit.json +1 -0
  42. package/templates/action-rpg/package.json +7 -7
  43. package/templates/action-rpg/playtests/spells.playtest.json +20 -0
  44. package/templates/action-rpg/src/game.ts +1 -0
  45. package/templates/action-rpg/src/render/atmosphere.ts +5 -16
  46. package/templates/action-rpg/src/render/gpuSky.ts +4 -7
  47. package/templates/action-rpg/src/render/quality.ts +3 -1
  48. package/templates/action-rpg/src/scenes/Play.ts +26 -0
  49. package/templates/action-rpg/src/ui/AbilityBar.tsx +1 -1
  50. package/templates/action-rpg/threenative.config.ts +0 -3
  51. package/templates/adventure/AGENTS.md +87 -44
  52. package/templates/adventure/CLAUDE.md +87 -44
  53. package/templates/adventure/package.json +7 -7
  54. package/templates/collectathon/AGENTS.md +88 -42
  55. package/templates/collectathon/CLAUDE.md +88 -42
  56. package/templates/collectathon/package.json +7 -7
  57. package/templates/kart/AGENTS.md +82 -42
  58. package/templates/kart/CLAUDE.md +82 -42
  59. package/templates/kart/package.json +6 -6
  60. package/templates/minimal/AGENTS.md +100 -84
  61. package/templates/minimal/CLAUDE.md +100 -84
  62. package/templates/minimal/package.json +6 -6
  63. package/templates/minimal/src/render/atmosphere.ts +5 -16
  64. package/templates/minimal/src/render/gpuSky.ts +4 -7
  65. package/templates/platformer/AGENTS.md +90 -46
  66. package/templates/platformer/CLAUDE.md +90 -46
  67. package/templates/platformer/package.json +7 -7
  68. package/templates/puzzle/AGENTS.md +92 -80
  69. package/templates/puzzle/CLAUDE.md +92 -80
  70. package/templates/puzzle/package.json +7 -7
  71. package/templates/racing/AGENTS.md +95 -82
  72. package/templates/racing/CLAUDE.md +95 -82
  73. package/templates/racing/package.json +7 -7
  74. package/templates/racing/src/render/atmosphere.ts +5 -16
  75. package/templates/racing/src/render/gpuSky.ts +4 -7
  76. package/templates/rain/AGENTS.md +92 -84
  77. package/templates/rain/CLAUDE.md +92 -84
  78. package/templates/rain/native-playtests/lightning.playtest.json +85 -10
  79. package/templates/rain/package.json +6 -6
  80. package/templates/rain/playtests/reduced-motion.playtest.json +6 -0
  81. package/templates/rain/src/scenes/Boot.ts +1 -0
  82. package/templates/rain/src/state.ts +7 -0
  83. package/templates/rain/src/ui/GameUi.tsx +7 -1
  84. package/templates/rts/AGENTS.md +96 -85
  85. package/templates/rts/CLAUDE.md +96 -85
  86. package/templates/rts/package.json +6 -6
  87. package/templates/runner/AGENTS.md +92 -80
  88. package/templates/runner/CLAUDE.md +92 -80
  89. package/templates/runner/package.json +7 -7
  90. package/templates/runner/playtests/performance.playtest.json +1 -1
  91. package/templates/runner/src/render/atmosphere.ts +5 -16
  92. package/templates/runner/src/render/gpuSky.ts +4 -7
  93. package/templates/runner/src/render/lighting.ts +53 -11
  94. package/templates/runner/src/scenes/Run.ts +4 -3
  95. package/templates/runner/threenative.config.ts +0 -3
  96. package/templates/sailing/AGENTS.md +91 -79
  97. package/templates/sailing/CLAUDE.md +91 -79
  98. package/templates/sailing/package.json +7 -7
  99. package/templates/sailing/playtests/sails.playtest.json +1 -0
  100. package/templates/sailing/src/render/sky.ts +4 -0
  101. package/templates/sailing/threenative.config.ts +0 -3
  102. package/templates/shooter/AGENTS.md +93 -68
  103. package/templates/shooter/CLAUDE.md +93 -68
  104. package/templates/shooter/package.json +7 -7
  105. package/templates/shooter/src/render/atmosphere.ts +5 -16
  106. package/templates/shooter/src/render/gpuSky.ts +4 -7
  107. package/templates/shooter/src/render/quality.ts +3 -1
  108. package/templates/snow/AGENTS.md +90 -76
  109. package/templates/snow/CLAUDE.md +90 -76
  110. package/templates/snow/package.json +7 -7
  111. package/templates/snow/threenative.config.ts +0 -3
  112. package/templates/starter/AGENTS.md +104 -88
  113. package/templates/starter/CLAUDE.md +104 -88
  114. package/templates/starter/native-playtests/render-chain.playtest.json +24 -24
  115. package/templates/starter/native-playtests/smooth-motion.playtest.json +3 -3
  116. package/templates/starter/package.json +7 -7
  117. package/templates/starter/src/entities/Player.ts +10 -22
  118. package/templates/starter/src/render/atmosphere.ts +5 -16
  119. package/templates/starter/src/render/gpuSky.ts +4 -7
  120. package/templates/starter/src/render/lighting.ts +54 -4
  121. package/templates/starter/src/render/temporalAA.ts +8 -7
  122. package/templates/starter/src/render/temporalAAFrame.ts +30 -9
  123. package/templates/starter/src/render/temporalAAResolve.ts +15 -1
  124. package/templates/starter/src/render/temporalClampRelease.ts +183 -0
  125. package/templates/starter/src/render/temporalHistoryResolve.ts +90 -0
  126. package/templates/starter/src/render/temporalMoire.ts +190 -0
  127. package/templates/starter/src/render/temporalResolve.ts +75 -16
  128. package/templates/starter/src/render/temporalResolveDepth.ts +2 -0
  129. package/templates/starter/src/scenes/Play.ts +41 -29
  130. package/templates/tower-defense/AGENTS.md +92 -81
  131. package/templates/tower-defense/CLAUDE.md +92 -81
  132. package/templates/tower-defense/package.json +7 -7
  133. package/capabilities.json +0 -9197
  134. package/templates/AGENTS.md +0 -21
  135. package/templates/CLAUDE.md +0 -23
  136. package/templates/action-rpg/.codex/config.toml +0 -23
  137. package/templates/action-rpg/.cursor/mcp.json +0 -38
  138. package/templates/action-rpg/.gemini/settings.json +0 -38
  139. package/templates/action-rpg/.mcp.json +0 -38
  140. package/templates/action-rpg/.vscode/mcp.json +0 -43
  141. package/templates/action-rpg/.zed/settings.json +0 -43
  142. package/templates/action-rpg/opencode.json +0 -49
  143. package/templates/adventure/.codex/config.toml +0 -23
  144. package/templates/adventure/.cursor/mcp.json +0 -38
  145. package/templates/adventure/.gemini/settings.json +0 -38
  146. package/templates/adventure/.mcp.json +0 -38
  147. package/templates/adventure/.vscode/mcp.json +0 -43
  148. package/templates/adventure/.zed/settings.json +0 -43
  149. package/templates/adventure/opencode.json +0 -49
  150. package/templates/collectathon/.codex/config.toml +0 -23
  151. package/templates/collectathon/.cursor/mcp.json +0 -38
  152. package/templates/collectathon/.gemini/settings.json +0 -38
  153. package/templates/collectathon/.mcp.json +0 -38
  154. package/templates/collectathon/.vscode/mcp.json +0 -43
  155. package/templates/collectathon/.zed/settings.json +0 -43
  156. package/templates/collectathon/opencode.json +0 -49
  157. package/templates/kart/.codex/config.toml +0 -23
  158. package/templates/kart/.cursor/mcp.json +0 -38
  159. package/templates/kart/.gemini/settings.json +0 -38
  160. package/templates/kart/.mcp.json +0 -38
  161. package/templates/kart/.vscode/mcp.json +0 -43
  162. package/templates/kart/.zed/settings.json +0 -43
  163. package/templates/kart/opencode.json +0 -49
  164. package/templates/minimal/.codex/config.toml +0 -23
  165. package/templates/minimal/.cursor/mcp.json +0 -38
  166. package/templates/minimal/.gemini/settings.json +0 -38
  167. package/templates/minimal/.mcp.json +0 -38
  168. package/templates/minimal/.vscode/mcp.json +0 -43
  169. package/templates/minimal/.zed/settings.json +0 -43
  170. package/templates/minimal/opencode.json +0 -49
  171. package/templates/platformer/.codex/config.toml +0 -23
  172. package/templates/platformer/.cursor/mcp.json +0 -38
  173. package/templates/platformer/.gemini/settings.json +0 -38
  174. package/templates/platformer/.mcp.json +0 -38
  175. package/templates/platformer/.vscode/mcp.json +0 -43
  176. package/templates/platformer/.zed/settings.json +0 -43
  177. package/templates/platformer/opencode.json +0 -49
  178. package/templates/puzzle/.codex/config.toml +0 -23
  179. package/templates/puzzle/.cursor/mcp.json +0 -38
  180. package/templates/puzzle/.gemini/settings.json +0 -38
  181. package/templates/puzzle/.mcp.json +0 -38
  182. package/templates/puzzle/.vscode/mcp.json +0 -43
  183. package/templates/puzzle/.zed/settings.json +0 -43
  184. package/templates/puzzle/opencode.json +0 -49
  185. package/templates/racing/.codex/config.toml +0 -23
  186. package/templates/racing/.cursor/mcp.json +0 -38
  187. package/templates/racing/.gemini/settings.json +0 -38
  188. package/templates/racing/.mcp.json +0 -38
  189. package/templates/racing/.vscode/mcp.json +0 -43
  190. package/templates/racing/.zed/settings.json +0 -43
  191. package/templates/racing/opencode.json +0 -49
  192. package/templates/rain/.codex/config.toml +0 -23
  193. package/templates/rain/.cursor/mcp.json +0 -38
  194. package/templates/rain/.gemini/settings.json +0 -38
  195. package/templates/rain/.mcp.json +0 -38
  196. package/templates/rain/.vscode/mcp.json +0 -43
  197. package/templates/rain/.zed/settings.json +0 -43
  198. package/templates/rain/opencode.json +0 -49
  199. package/templates/rts/.codex/config.toml +0 -23
  200. package/templates/rts/.cursor/mcp.json +0 -38
  201. package/templates/rts/.gemini/settings.json +0 -38
  202. package/templates/rts/.mcp.json +0 -38
  203. package/templates/rts/.vscode/mcp.json +0 -43
  204. package/templates/rts/.zed/settings.json +0 -43
  205. package/templates/rts/opencode.json +0 -49
  206. package/templates/runner/.codex/config.toml +0 -23
  207. package/templates/runner/.cursor/mcp.json +0 -38
  208. package/templates/runner/.gemini/settings.json +0 -38
  209. package/templates/runner/.mcp.json +0 -38
  210. package/templates/runner/.vscode/mcp.json +0 -43
  211. package/templates/runner/.zed/settings.json +0 -43
  212. package/templates/runner/README.md +0 -43
  213. package/templates/runner/opencode.json +0 -49
  214. package/templates/sailing/.codex/config.toml +0 -23
  215. package/templates/sailing/.cursor/mcp.json +0 -38
  216. package/templates/sailing/.gemini/settings.json +0 -38
  217. package/templates/sailing/.mcp.json +0 -38
  218. package/templates/sailing/.vscode/mcp.json +0 -43
  219. package/templates/sailing/.zed/settings.json +0 -43
  220. package/templates/sailing/README.md +0 -28
  221. package/templates/sailing/opencode.json +0 -49
  222. package/templates/shooter/.codex/config.toml +0 -23
  223. package/templates/shooter/.cursor/mcp.json +0 -38
  224. package/templates/shooter/.gemini/settings.json +0 -38
  225. package/templates/shooter/.mcp.json +0 -38
  226. package/templates/shooter/.vscode/mcp.json +0 -43
  227. package/templates/shooter/.zed/settings.json +0 -43
  228. package/templates/shooter/opencode.json +0 -49
  229. package/templates/snow/.codex/config.toml +0 -23
  230. package/templates/snow/.cursor/mcp.json +0 -38
  231. package/templates/snow/.gemini/settings.json +0 -38
  232. package/templates/snow/.mcp.json +0 -38
  233. package/templates/snow/.vscode/mcp.json +0 -43
  234. package/templates/snow/.zed/settings.json +0 -43
  235. package/templates/snow/README.md +0 -26
  236. package/templates/snow/opencode.json +0 -49
  237. package/templates/starter/.codex/config.toml +0 -23
  238. package/templates/starter/.cursor/mcp.json +0 -38
  239. package/templates/starter/.gemini/settings.json +0 -38
  240. package/templates/starter/.mcp.json +0 -38
  241. package/templates/starter/.vscode/mcp.json +0 -43
  242. package/templates/starter/.zed/settings.json +0 -43
  243. package/templates/starter/opencode.json +0 -49
  244. package/templates/tower-defense/.codex/config.toml +0 -23
  245. package/templates/tower-defense/.cursor/mcp.json +0 -38
  246. package/templates/tower-defense/.gemini/settings.json +0 -38
  247. package/templates/tower-defense/.mcp.json +0 -38
  248. package/templates/tower-defense/.vscode/mcp.json +0 -43
  249. package/templates/tower-defense/.zed/settings.json +0 -43
  250. package/templates/tower-defense/README.md +0 -16
  251. package/templates/tower-defense/opencode.json +0 -49
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { execFileSync, spawn } from 'child_process';
4
- import { existsSync, realpathSync, readdirSync, readFileSync, rmSync, mkdirSync, writeFileSync } from 'fs';
5
- import { mkdir, cp, rename, readFile, readdir, writeFile, rm, symlink, access, unlink, stat } from 'fs/promises';
6
- import path6 from 'path';
4
+ import { existsSync, realpathSync, readdirSync, readFileSync, mkdirSync, writeFileSync, rmSync } from 'fs';
5
+ import { mkdir, cp, rm, rename, readFile, readdir, writeFile, symlink, access, unlink, stat } from 'fs/promises';
6
+ import path7 from 'path';
7
7
  import { fileURLToPath, pathToFileURL } from 'url';
8
8
  import { LoadingManager, Box3, Vector3 } from 'three';
9
9
  import { createHash } from 'crypto';
@@ -86,10 +86,10 @@ function localResourcePath(baseDirectory, uri) {
86
86
  } catch (error) {
87
87
  throw new Error(`Invalid glTF resource URI "${uri}": ${String(error)}`);
88
88
  }
89
- return path6.resolve(baseDirectory, decoded);
89
+ return path7.resolve(baseDirectory, decoded);
90
90
  }
91
91
  function resourceMimeType(resourcePath, declared) {
92
- return declared ?? RESOURCE_MIME_TYPES[path6.extname(resourcePath).toLowerCase()] ?? "application/octet-stream";
92
+ return declared ?? RESOURCE_MIME_TYPES[path7.extname(resourcePath).toLowerCase()] ?? "application/octet-stream";
93
93
  }
94
94
  function gltfResourceReferences(document) {
95
95
  const references = [];
@@ -118,10 +118,10 @@ async function readLocalResources(baseDirectory, references) {
118
118
  return resources;
119
119
  }
120
120
  async function localResourceResolver(file, data) {
121
- if (path6.extname(file).toLowerCase() !== ".gltf") return (url) => url;
121
+ if (path7.extname(file).toLowerCase() !== ".gltf") return (url) => url;
122
122
  const document = JSON.parse(data.toString("utf8"));
123
123
  const references = gltfResourceReferences(document);
124
- const baseDirectory = path6.dirname(path6.resolve(file));
124
+ const baseDirectory = path7.dirname(path7.resolve(file));
125
125
  const resources = await readLocalResources(baseDirectory, references);
126
126
  return (url) => {
127
127
  const resourcePath = localResourcePath(baseDirectory, url);
@@ -135,11 +135,11 @@ async function parseGltfAsset(file, data) {
135
135
  const manager = new LoadingManager();
136
136
  manager.setURLModifier(await localResourceResolver(file, data));
137
137
  const loader = new GLTFLoader(manager);
138
- const extension = path6.extname(file).toLowerCase();
138
+ const extension = path7.extname(file).toLowerCase();
139
139
  const payload = extension === ".gltf" ? data.toString("utf8") : data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
140
140
  const parsed = await loader.parseAsync(
141
141
  payload,
142
- `${path6.dirname(path6.resolve(file))}${path6.sep}`
142
+ `${path7.dirname(path7.resolve(file))}${path7.sep}`
143
143
  );
144
144
  const json = parsed.parser.json;
145
145
  return {
@@ -199,11 +199,11 @@ function inspectScene(file, scene, animations, resourceCounts) {
199
199
  bounds,
200
200
  bones: resources.bones,
201
201
  clips: animations.map((clip) => clip.name || "(unnamed)"),
202
- file: path6.basename(file),
202
+ file: path7.basename(file),
203
203
  forwardAxis: largest === void 0 ? { axis: "unknown", basis: "none", direction: "unknown" } : { axis: largest.axis, basis: "longest geometry axis", direction: "unknown" },
204
204
  materials: resourceCounts.materials ?? resources.materials,
205
205
  meshes: resourceCounts.meshes ?? resources.meshes,
206
- path: path6.resolve(file),
206
+ path: path7.resolve(file),
207
207
  textures: resourceCounts.textures ?? resources.textures,
208
208
  units: {
209
209
  label: unitsLabel(largest?.value ?? 0),
@@ -232,7 +232,7 @@ function parseInspectArgs(argv) {
232
232
  return { file, json: argv.includes("--json") };
233
233
  }
234
234
  async function inspectAsset(file) {
235
- const extension = path6.extname(file).toLowerCase();
235
+ const extension = path7.extname(file).toLowerCase();
236
236
  if (!SUPPORTED_EXTENSIONS.has(extension)) {
237
237
  throw new Error(`TN_ASSET_INSPECT_UNSUPPORTED: ${file}: expected a .glb or .gltf file.`);
238
238
  }
@@ -311,6 +311,12 @@ var MCP_SERVERS = Object.freeze({
311
311
  command: "node",
312
312
  args: Object.freeze(["./node_modules/@threenative/core/mcp/engine.mjs"])
313
313
  }),
314
+ // Cooks a starter terrain kit into a world.glb. The server lives in the optional
315
+ // `@threenative/terrain` package, which the shim resolves from the project at launch.
316
+ "threenative-terrain": Object.freeze({
317
+ command: "node",
318
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/terrain.mjs"])
319
+ }),
314
320
  // Inspects, attaches, edits and verifies character animation. Every operation is a build-time
315
321
  // edit of one GLB, so a game that animates nothing pays for nothing.
316
322
  "threenative-animation": Object.freeze({
@@ -369,6 +375,37 @@ var SERVER_FORMATS = Object.freeze({
369
375
  })
370
376
  });
371
377
  Object.freeze(Object.keys(SERVER_FORMATS));
378
+ function mergeMcpServers(existing, format = "mcpServers") {
379
+ const shape = SERVER_FORMATS[format];
380
+ if (shape === void 0) throw new Error(`Unknown MCP config format '${format}'.`);
381
+ const malformed = existing !== void 0 && (typeof existing !== "object" || existing === null || Array.isArray(existing));
382
+ if (malformed) {
383
+ throw new Error("MCP config root must be an object.");
384
+ }
385
+ const previous = existing ?? {};
386
+ const existingServers = previous[shape.key];
387
+ if (existingServers !== void 0 && (typeof existingServers !== "object" || existingServers === null || Array.isArray(existingServers))) {
388
+ throw new Error(`MCP config '${shape.key}' must be an object.`);
389
+ }
390
+ const servers = { ...existingServers ?? {} };
391
+ for (const [name, server] of Object.entries(servers)) {
392
+ if (typeof server !== "object" || server === null || Array.isArray(server)) {
393
+ throw new Error(`MCP server '${name}' in '${shape.key}' must be an object.`);
394
+ }
395
+ }
396
+ let changed = false;
397
+ const conflicts = [];
398
+ for (const [name, server] of Object.entries(MCP_SERVERS)) {
399
+ const wanted = shape.entry(server);
400
+ if (Object.hasOwn(servers, name)) {
401
+ if (JSON.stringify(servers[name]) !== JSON.stringify(wanted)) conflicts.push(name);
402
+ continue;
403
+ }
404
+ servers[name] = wanted;
405
+ changed = true;
406
+ }
407
+ return { changed, conflicts, config: { ...previous, [shape.key]: servers } };
408
+ }
372
409
  function codexServerBlock(name, server) {
373
410
  const args = server.args.map((argument) => JSON.stringify(argument)).join(", ");
374
411
  const lines = [
@@ -384,11 +421,93 @@ function codexServerBlock(name, server) {
384
421
  }
385
422
  return lines.join("\n");
386
423
  }
387
- Object.freeze(
424
+ var CODEX_MCP_SERVERS = Object.freeze(
388
425
  Object.entries(MCP_SERVERS).map(
389
426
  ([name, server]) => Object.freeze({ body: codexServerBlock(name, server), name })
390
427
  )
391
428
  );
429
+ var MCP_HOSTS = Object.freeze([
430
+ Object.freeze({
431
+ id: "claude-code",
432
+ label: "Claude Code",
433
+ file: ".mcp.json",
434
+ format: "mcpServers"
435
+ }),
436
+ Object.freeze({ id: "codex", label: "Codex", file: ".codex/config.toml", format: "codex" }),
437
+ Object.freeze({ id: "cursor", label: "Cursor", file: ".cursor/mcp.json", format: "mcpServers" }),
438
+ Object.freeze({ id: "vscode", label: "VS Code", file: ".vscode/mcp.json", format: "vscode" }),
439
+ Object.freeze({
440
+ id: "gemini-cli",
441
+ label: "Gemini CLI",
442
+ file: ".gemini/settings.json",
443
+ format: "mcpServers"
444
+ }),
445
+ Object.freeze({
446
+ id: "opencode",
447
+ label: "opencode",
448
+ file: "opencode.json",
449
+ format: "opencode",
450
+ // Written only when this installer creates the file, so a second install still reports
451
+ // "unchanged" rather than rewriting a config the user has since edited.
452
+ seed: Object.freeze({ $schema: "https://opencode.ai/config.json" })
453
+ }),
454
+ Object.freeze({ id: "zed", label: "Zed", file: ".zed/settings.json", format: "zed" })
455
+ ]);
456
+ function ensureJsonMcpConfig(target, file, format, seed = void 0) {
457
+ const configPath = path7.join(target, file);
458
+ let existing;
459
+ if (existsSync(configPath)) {
460
+ try {
461
+ existing = JSON.parse(readFileSync(configPath, "utf8"));
462
+ } catch {
463
+ return "unreadable";
464
+ }
465
+ }
466
+ let merged;
467
+ try {
468
+ merged = mergeMcpServers(existing, format);
469
+ } catch {
470
+ return "unreadable";
471
+ }
472
+ const { changed, config, conflicts } = merged;
473
+ if (!changed) return conflicts.length > 0 ? "conflict" : "unchanged";
474
+ const written = existing === void 0 ? { ...seed, ...config } : config;
475
+ mkdirSync(path7.dirname(configPath), { recursive: true });
476
+ writeFileSync(configPath, `${JSON.stringify(written, null, 2)}
477
+ `);
478
+ return conflicts.length > 0 ? "conflict" : existing === void 0 ? "created" : "updated";
479
+ }
480
+ function ensureCodexMcpConfig(target) {
481
+ const directory = path7.join(target, ".codex");
482
+ const configPath = path7.join(directory, "config.toml");
483
+ const existing = existsSync(configPath) ? readFileSync(configPath, "utf8") : "";
484
+ const missing = CODEX_MCP_SERVERS.filter(
485
+ ({ name }) => !existing.includes(`[mcp_servers.${name}]`)
486
+ );
487
+ if (missing.length === 0) return "unchanged";
488
+ mkdirSync(directory, { recursive: true });
489
+ const separator = existing.length === 0 || existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
490
+ writeFileSync(
491
+ configPath,
492
+ `${existing}${separator}${missing.map(({ body }) => body).join("\n\n")}
493
+ `
494
+ );
495
+ return existing.length === 0 ? "created" : "updated";
496
+ }
497
+ function ensureHostMcpConfigs(target) {
498
+ const outcomes = /* @__PURE__ */ new Map();
499
+ for (const host of MCP_HOSTS) {
500
+ try {
501
+ outcomes.set(
502
+ host.id,
503
+ host.format === "codex" ? ensureCodexMcpConfig(target) : ensureJsonMcpConfig(target, host.file, host.format, host.seed)
504
+ );
505
+ } catch {
506
+ outcomes.set(host.id, "unreadable");
507
+ }
508
+ }
509
+ return outcomes;
510
+ }
392
511
 
393
512
  // src/mcp-servers.ts
394
513
  function serverEntryPath(server) {
@@ -403,23 +522,23 @@ var DECODER_LIB_ASSET_URL = /new URL\(\s*(['"])\.\.\/libs\/([^'"]+)\1\s*,\s*impo
403
522
  function rewriteDecoderAssetUrls(code) {
404
523
  return code.replace(DECODER_LIB_ASSET_URL, '"../libs/$2"');
405
524
  }
406
- var MARKER_RELATIVE = path6.join("node_modules", ".vite", "threenative-engine-build.json");
525
+ var MARKER_RELATIVE = path7.join("node_modules", ".vite", "threenative-engine-build.json");
407
526
  function hashTree(hash, directory) {
408
527
  const entries = readdirSync(directory, { withFileTypes: true }).sort(
409
528
  (left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0
410
529
  );
411
530
  for (const entry of entries) {
412
- const full = path6.join(directory, entry.name);
531
+ const full = path7.join(directory, entry.name);
413
532
  if (entry.isDirectory()) {
414
533
  hashTree(hash, full);
415
534
  } else if (entry.isFile()) {
416
- hash.update(path6.relative(directory, full));
535
+ hash.update(path7.relative(directory, full));
417
536
  hash.update(readFileSync(full));
418
537
  }
419
538
  }
420
539
  }
421
540
  function hashEngineDist(projectRoot) {
422
- const scopeDir = path6.join(projectRoot, "node_modules", "@threenative");
541
+ const scopeDir = path7.join(projectRoot, "node_modules", "@threenative");
423
542
  let packages;
424
543
  try {
425
544
  packages = readdirSync(scopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => entry.name).sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
@@ -428,13 +547,13 @@ function hashEngineDist(projectRoot) {
428
547
  }
429
548
  const dists = [];
430
549
  for (const name of packages) {
431
- let packageDir = path6.join(scopeDir, name);
550
+ let packageDir = path7.join(scopeDir, name);
432
551
  try {
433
552
  packageDir = realpathSync(packageDir);
434
553
  } catch {
435
554
  continue;
436
555
  }
437
- const dist = path6.join(packageDir, "dist");
556
+ const dist = path7.join(packageDir, "dist");
438
557
  if (existsSync(dist)) dists.push([name, dist]);
439
558
  }
440
559
  if (dists.length === 0) return void 0;
@@ -446,7 +565,7 @@ function hashEngineDist(projectRoot) {
446
565
  return hash.digest("hex");
447
566
  }
448
567
  function markerPath(projectRoot) {
449
- return path6.join(projectRoot, MARKER_RELATIVE);
568
+ return path7.join(projectRoot, MARKER_RELATIVE);
450
569
  }
451
570
  function readMarker(file) {
452
571
  try {
@@ -466,7 +585,7 @@ function processIsAlive(pid) {
466
585
  }
467
586
  function createEngineFreshnessPlugin() {
468
587
  let recordedHash;
469
- const rootOf = (config) => path6.resolve(config.root ?? process.cwd());
588
+ const rootOf = (config) => path7.resolve(config.root ?? process.cwd());
470
589
  return {
471
590
  name: "threenative-engine-freshness",
472
591
  config(config, env) {
@@ -498,7 +617,7 @@ function createEngineFreshnessPlugin() {
498
617
  const writeBootMarker = (port) => {
499
618
  const hash = recordedHash ?? hashEngineDist(root);
500
619
  if (hash === void 0) return;
501
- mkdirSync(path6.dirname(file), { recursive: true });
620
+ mkdirSync(path7.dirname(file), { recursive: true });
502
621
  writeFileSync(
503
622
  file,
504
623
  JSON.stringify(
@@ -598,13 +717,13 @@ function defaultAppId(name) {
598
717
  return `com.threenative.${segment}`;
599
718
  }
600
719
  function projectRequire(cwd) {
601
- return createRequire$1(path6.join(cwd, "package.json"));
720
+ return createRequire$1(path7.join(cwd, "package.json"));
602
721
  }
603
722
  function configLoaderSearch(cwd) {
604
723
  return [
605
- path6.join(cwd, "node_modules", "vite"),
606
- path6.join(cwd, "node_modules", "esbuild"),
607
- path6.resolve(path6.dirname(fileURLToPath(import.meta.url)), "..", "node_modules", "esbuild")
724
+ path7.join(cwd, "node_modules", "vite"),
725
+ path7.join(cwd, "node_modules", "esbuild"),
726
+ path7.resolve(path7.dirname(fileURLToPath(import.meta.url)), "..", "node_modules", "esbuild")
608
727
  ];
609
728
  }
610
729
  var CONFIG_BUILD_COMMAND = "pnpm exec threenative build --target web";
@@ -612,7 +731,7 @@ function configContext(cwd, layer, sources, searched, fix) {
612
731
  return { cwd, fix, layer, searched, sources };
613
732
  }
614
733
  function packageContext(cwd) {
615
- const packagePath = path6.join(cwd, "package.json");
734
+ const packagePath = path7.join(cwd, "package.json");
616
735
  return configContext(
617
736
  cwd,
618
737
  "package manifest",
@@ -635,8 +754,8 @@ function validationContext(cwd, sources) {
635
754
  cwd,
636
755
  "config validation",
637
756
  sources,
638
- [path6.join(cwd, "package.json"), path6.join(cwd, CONFIG_FILE)],
639
- `fix '${path6.join(cwd, CONFIG_FILE)}' and rerun ${CONFIG_BUILD_COMMAND}`
757
+ [path7.join(cwd, "package.json"), path7.join(cwd, CONFIG_FILE)],
758
+ `fix '${path7.join(cwd, CONFIG_FILE)}' and rerun ${CONFIG_BUILD_COMMAND}`
640
759
  );
641
760
  }
642
761
  function configFailure(code, context, detail) {
@@ -676,7 +795,7 @@ function resolveEsbuild(cwd) {
676
795
  }
677
796
  }
678
797
  async function importConfig(cwd) {
679
- const sourcePath = path6.join(cwd, CONFIG_FILE);
798
+ const sourcePath = path7.join(cwd, CONFIG_FILE);
680
799
  try {
681
800
  await access(sourcePath);
682
801
  } catch {
@@ -737,7 +856,7 @@ async function importConfig(cwd) {
737
856
  error instanceof Error ? error.message : String(error)
738
857
  );
739
858
  }
740
- const compiledPath = path6.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
859
+ const compiledPath = path7.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
741
860
  try {
742
861
  await writeFile(compiledPath, code, "utf8");
743
862
  } catch (error) {
@@ -773,7 +892,7 @@ async function importConfig(cwd) {
773
892
  async function readManifest(cwd) {
774
893
  let parsed;
775
894
  try {
776
- parsed = JSON.parse(await readFile(path6.join(cwd, "package.json"), "utf8"));
895
+ parsed = JSON.parse(await readFile(path7.join(cwd, "package.json"), "utf8"));
777
896
  } catch (error) {
778
897
  fail("TN_CONFIG_PACKAGE_INVALID", error instanceof Error ? error.message : String(error));
779
898
  }
@@ -792,12 +911,12 @@ function packageNativeEntry(manifest) {
792
911
  }
793
912
  function validateNativeEntry(value, cwd) {
794
913
  const entry = nonEmptyString(value, "TN_NATIVE_ENTRY_MISSING", "nativeEntry");
795
- if (path6.isAbsolute(entry)) {
914
+ if (path7.isAbsolute(entry)) {
796
915
  fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must be project-relative.");
797
916
  }
798
- const resolved = path6.resolve(cwd, entry);
799
- const relative = path6.relative(cwd, resolved);
800
- if (relative === ".." || relative.startsWith(`..${path6.sep}`) || path6.isAbsolute(relative)) {
917
+ const resolved = path7.resolve(cwd, entry);
918
+ const relative = path7.relative(cwd, resolved);
919
+ if (relative === ".." || relative.startsWith(`..${path7.sep}`) || path7.isAbsolute(relative)) {
801
920
  fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must stay inside the project.");
802
921
  }
803
922
  return entry;
@@ -841,18 +960,18 @@ async function validateApp(raw, name, cwd) {
841
960
  }
842
961
  async function validateProjectAsset(raw, cwd, label, options) {
843
962
  const relative = nonEmptyString(raw, `${options.codePrefix}_INVALID`, label);
844
- if (path6.isAbsolute(relative)) {
963
+ if (path7.isAbsolute(relative)) {
845
964
  fail(`${options.codePrefix}_PATH_INVALID`, `${label} must be project-relative: ${relative}`);
846
965
  }
847
- const resolved = path6.resolve(cwd, relative);
848
- const withinProject = path6.relative(cwd, resolved);
849
- if (withinProject === ".." || withinProject.startsWith(`..${path6.sep}`) || path6.isAbsolute(withinProject)) {
966
+ const resolved = path7.resolve(cwd, relative);
967
+ const withinProject = path7.relative(cwd, resolved);
968
+ if (withinProject === ".." || withinProject.startsWith(`..${path7.sep}`) || path7.isAbsolute(withinProject)) {
850
969
  fail(
851
970
  `${options.codePrefix}_PATH_INVALID`,
852
971
  `${label} must stay inside the project: ${relative}`
853
972
  );
854
973
  }
855
- const extension = path6.extname(relative).slice(1).toLowerCase();
974
+ const extension = path7.extname(relative).slice(1).toLowerCase();
856
975
  if (!options.formats.includes(extension)) {
857
976
  fail(
858
977
  options.codePrefix === "TN_CONFIG_ICON" ? `${options.codePrefix}_INVALID` : `${options.codePrefix}_FORMAT_INVALID`,
@@ -1854,8 +1973,8 @@ function assertProfileCapReachable(assets, overlay, name) {
1854
1973
  }
1855
1974
  }
1856
1975
  async function loadConfigInternal(root, selection) {
1857
- const packagePath = path6.join(root, "package.json");
1858
- const sourcePath = path6.join(root, CONFIG_FILE);
1976
+ const packagePath = path7.join(root, "package.json");
1977
+ const sourcePath = path7.join(root, CONFIG_FILE);
1859
1978
  const manifest = await withConfigContext(
1860
1979
  packageContext(root),
1861
1980
  "TN_CONFIG_PACKAGE_INVALID",
@@ -1930,9 +2049,9 @@ async function loadConfigInternal(root, selection) {
1930
2049
  );
1931
2050
  }
1932
2051
  async function loadConfig(cwd, selection) {
1933
- const root = path6.resolve(cwd);
2052
+ const root = path7.resolve(cwd);
1934
2053
  return withConfigContext(
1935
- validationContext(root, [path6.join(root, CONFIG_FILE), path6.join(root, "package.json")]),
2054
+ validationContext(root, [path7.join(root, CONFIG_FILE), path7.join(root, "package.json")]),
1936
2055
  "TN_CONFIG_VALIDATION_FAILED",
1937
2056
  () => loadConfigInternal(root, selection)
1938
2057
  );
@@ -1998,9 +2117,9 @@ function wasmModule(root, explicit) {
1998
2117
  }
1999
2118
  let entry;
2000
2119
  try {
2001
- const require2 = createRequire$1(path6.join(root, "package.json"));
2002
- entry = path6.join(
2003
- path6.dirname(require2.resolve("@threenative/runtime-native/package.json")),
2120
+ const require2 = createRequire$1(path7.join(root, "package.json"));
2121
+ entry = path7.join(
2122
+ path7.dirname(require2.resolve("@threenative/runtime-native/package.json")),
2004
2123
  WASM_ENGINE_ENTRY
2005
2124
  );
2006
2125
  } catch {
@@ -2015,7 +2134,7 @@ function wasmModule(root, explicit) {
2015
2134
  return entry;
2016
2135
  }
2017
2136
  async function upstreamNames(root) {
2018
- const require2 = createRequire$1(path6.join(root, "package.json"));
2137
+ const require2 = createRequire$1(path7.join(root, "package.json"));
2019
2138
  const modules = await Promise.all(
2020
2139
  UPSTREAM.map((id) => import(pathToFileURL(require2.resolve(id)).href))
2021
2140
  );
@@ -2082,7 +2201,7 @@ function createWebEnginePlugin(options = {}) {
2082
2201
  "__tnLoadGltf"
2083
2202
  ];
2084
2203
  const single = wasmModule(projectRoot(), options.wasm);
2085
- const threads = path6.join(path6.dirname(single), path6.basename(WASM_THREADS_ENTRY));
2204
+ const threads = path7.join(path7.dirname(single), path7.basename(WASM_THREADS_ENTRY));
2086
2205
  if (!existsSync(threads))
2087
2206
  throw new Error(
2088
2207
  `TN_WASM_THREADS_MISSING: engine "threenative" needs the threaded Wasm engine at ${threads}; reinstall @threenative/runtime-native, or in a ThreeNative checkout run \`pnpm wasm:build\` (presets wasm and wasm-threads). ${OPT_OUT}`
@@ -2122,8 +2241,8 @@ function htmlAttribute(value) {
2122
2241
  }
2123
2242
  function publicUrl(root, value) {
2124
2243
  if (value === void 0) return void 0;
2125
- const relative = path6.isAbsolute(value) ? path6.relative(root, value) : value;
2126
- const normalized = relative.replaceAll(path6.sep, "/").replace(/^public\//u, "");
2244
+ const relative = path7.isAbsolute(value) ? path7.relative(root, value) : value;
2245
+ const normalized = relative.replaceAll(path7.sep, "/").replace(/^public\//u, "");
2127
2246
  return `/${normalized.replace(/^\//u, "")}`;
2128
2247
  }
2129
2248
  function manifestIcon(root, source, purpose) {
@@ -2200,7 +2319,7 @@ function createWebBrandPlugin() {
2200
2319
  name: "threenative-web-brand",
2201
2320
  enforce: "pre",
2202
2321
  async config(vite) {
2203
- const loaded = await loadConfig(path6.resolve(vite.root ?? process.cwd()));
2322
+ const loaded = await loadConfig(path7.resolve(vite.root ?? process.cwd()));
2204
2323
  if (loaded.engine === "threenative" && process.env.THREENATIVE_NATIVE_BUNDLE === void 0)
2205
2324
  return {
2206
2325
  optimizeDeps: { exclude: ["three", "three/webgpu", "three/tsl", "three-mesh-bvh"] },
@@ -2283,23 +2402,24 @@ var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".css", ".html", ".json", ".
2283
2402
  var TEMPLATE_NAME = /^[a-z][a-z0-9-]*$/u;
2284
2403
  var SHARED_AGENT_MARKER_LINE = /^<!--\s*(?:shared:\s*[^>]+|\/shared)\s*-->\r?\n?/gmu;
2285
2404
  var DEFAULT_TEMPLATE = "starter";
2405
+ var SUPPORTED_PACKAGE_MANAGER = "pnpm@10.25.0";
2286
2406
  function templateRoot() {
2287
- return path6.resolve(path6.dirname(fileURLToPath(import.meta.url)), "../templates");
2407
+ return path7.resolve(path7.dirname(fileURLToPath(import.meta.url)), "../templates");
2288
2408
  }
2289
- var LOADING_SOURCE_RELATIVE_PATH = path6.join("src", "render", "loading.ts");
2409
+ var LOADING_SOURCE_RELATIVE_PATH = path7.join("src", "render", "loading.ts");
2290
2410
  var LOADING_APPEARANCE_MARKER = "BEGIN THREENATIVE LOADING APPEARANCE";
2291
2411
  var TEMPLATE_ICON_NAME = "icon.png";
2292
2412
  var LOADING_APPEARANCE_BLOCK_PATTERN = /\/\* BEGIN THREENATIVE LOADING APPEARANCE \*\/[\s\S]*?\/\* END THREENATIVE LOADING APPEARANCE \*\//gu;
2293
2413
  function discoverStampedTemplates(root = templateRoot()) {
2294
2414
  return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right)).filter((template) => {
2295
- const file = path6.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
2415
+ const file = path7.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
2296
2416
  return existsSync(file) && readFileSync(file, "utf8").includes(LOADING_APPEARANCE_MARKER);
2297
2417
  });
2298
2418
  }
2299
2419
  function canonicalLoadingPath(root = templateRoot()) {
2300
- const local = path6.resolve(root, "..", "template-assets", "loading.ts");
2420
+ const local = path7.resolve(root, "..", "template-assets", "loading.ts");
2301
2421
  if (existsSync(local)) return local;
2302
- return path6.resolve(templateRoot(), "..", "template-assets", "loading.ts");
2422
+ return path7.resolve(templateRoot(), "..", "template-assets", "loading.ts");
2303
2423
  }
2304
2424
  function loadingAppearanceBlock(source, file) {
2305
2425
  const matches = source.match(LOADING_APPEARANCE_BLOCK_PATTERN) ?? [];
@@ -2320,21 +2440,21 @@ var SHARED_RENDER_SOURCES = [
2320
2440
  "src/render/temporalDetailStage.ts"
2321
2441
  ];
2322
2442
  function canonicalRenderSourcePath(relativePath, root = templateRoot()) {
2323
- const name = path6.basename(relativePath);
2324
- const local = path6.resolve(root, "..", "template-assets", name);
2443
+ const name = path7.basename(relativePath);
2444
+ const local = path7.resolve(root, "..", "template-assets", name);
2325
2445
  if (existsSync(local)) return local;
2326
- const starter = path6.resolve(root, "starter", relativePath);
2446
+ const starter = path7.resolve(root, "starter", relativePath);
2327
2447
  if (existsSync(starter)) return starter;
2328
- const shared = path6.resolve(templateRoot(), "..", "template-assets", name);
2448
+ const shared = path7.resolve(templateRoot(), "..", "template-assets", name);
2329
2449
  if (existsSync(shared)) return shared;
2330
- return path6.resolve(templateRoot(), "starter", relativePath);
2450
+ return path7.resolve(templateRoot(), "starter", relativePath);
2331
2451
  }
2332
2452
  async function restampSharedRenderCopies(root = templateRoot()) {
2333
2453
  const stamped = [];
2334
2454
  for (const relativePath of SHARED_RENDER_SOURCES) {
2335
2455
  const canonical = await readFile(canonicalRenderSourcePath(relativePath, root), "utf8");
2336
2456
  for (const template of readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right))) {
2337
- const file = path6.join(root, template, relativePath);
2457
+ const file = path7.join(root, template, relativePath);
2338
2458
  if (!existsSync(file)) continue;
2339
2459
  await writeFile(file, canonical);
2340
2460
  stamped.push(file);
@@ -2346,7 +2466,7 @@ async function restampTemplateLoadingCopies(root = templateRoot()) {
2346
2466
  const canonical = await readFile(canonicalLoadingPath(root), "utf8");
2347
2467
  const stamped = [];
2348
2468
  for (const template of discoverStampedTemplates(root)) {
2349
- const file = path6.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
2469
+ const file = path7.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
2350
2470
  const source = await readFile(file, "utf8");
2351
2471
  await writeFile(file, stampLoadingSource(canonical, source));
2352
2472
  stamped.push(file);
@@ -2354,19 +2474,19 @@ async function restampTemplateLoadingCopies(root = templateRoot()) {
2354
2474
  return stamped;
2355
2475
  }
2356
2476
  async function stampTemplateLoading(target, template, root) {
2357
- const sourcePath = path6.join(template, LOADING_SOURCE_RELATIVE_PATH);
2477
+ const sourcePath = path7.join(template, LOADING_SOURCE_RELATIVE_PATH);
2358
2478
  if (!existsSync(sourcePath)) return;
2359
2479
  const source = await readFile(sourcePath, "utf8");
2360
2480
  if (!source.includes("BEGIN THREENATIVE LOADING APPEARANCE")) return;
2361
2481
  const canonical = await readFile(canonicalLoadingPath(root), "utf8");
2362
2482
  await writeFile(
2363
- path6.join(target, LOADING_SOURCE_RELATIVE_PATH),
2483
+ path7.join(target, LOADING_SOURCE_RELATIVE_PATH),
2364
2484
  stampLoadingSource(canonical, source)
2365
2485
  );
2366
2486
  }
2367
2487
  async function copyTemplateIcon(target, templateRootDirectory) {
2368
- const source = path6.join(
2369
- path6.dirname(templateRootDirectory),
2488
+ const source = path7.join(
2489
+ path7.dirname(templateRootDirectory),
2370
2490
  "template-assets",
2371
2491
  TEMPLATE_ICON_NAME
2372
2492
  );
@@ -2375,18 +2495,18 @@ async function copyTemplateIcon(target, templateRootDirectory) {
2375
2495
  `TN_TEMPLATE_ICON_MISSING: '${source}' is not in the package; every generated project needs the native icon asset.`
2376
2496
  );
2377
2497
  }
2378
- const destination = path6.join(target, "public", TEMPLATE_ICON_NAME);
2379
- await mkdir(path6.dirname(destination), { recursive: true });
2498
+ const destination = path7.join(target, "public", TEMPLATE_ICON_NAME);
2499
+ await mkdir(path7.dirname(destination), { recursive: true });
2380
2500
  await cp(source, destination, { errorOnExist: true, force: false });
2381
2501
  }
2382
2502
  async function copySharedAssets(target, templateRootDirectory) {
2383
- const shared = path6.join(path6.dirname(templateRootDirectory), "template-assets", "assets");
2503
+ const shared = path7.join(path7.dirname(templateRootDirectory), "template-assets", "assets");
2384
2504
  if (!existsSync(shared)) return;
2385
- const source = path6.join(target, "src");
2505
+ const source = path7.join(target, "src");
2386
2506
  const texts = [];
2387
2507
  const walk = async (directory) => {
2388
2508
  for (const entry of await readdir(directory, { withFileTypes: true })) {
2389
- const file = path6.join(directory, entry.name);
2509
+ const file = path7.join(directory, entry.name);
2390
2510
  if (entry.isDirectory()) await walk(file);
2391
2511
  else if (/\.(?:ts|tsx)$/u.test(entry.name)) texts.push(await readFile(file, "utf8"));
2392
2512
  }
@@ -2404,13 +2524,13 @@ async function copySharedAssets(target, templateRootDirectory) {
2404
2524
  };
2405
2525
  for (const name of names) {
2406
2526
  if (!copied(name)) continue;
2407
- const destination = path6.join(target, "assets", name);
2408
- await mkdir(path6.dirname(destination), { recursive: true });
2409
- await cp(path6.join(shared, name), destination, { errorOnExist: true, force: false });
2527
+ const destination = path7.join(target, "assets", name);
2528
+ await mkdir(path7.dirname(destination), { recursive: true });
2529
+ await cp(path7.join(shared, name), destination, { errorOnExist: true, force: false });
2410
2530
  }
2411
2531
  }
2412
2532
  async function copyQualityConfig(target, templateRootDirectory) {
2413
- const shared = path6.join(path6.dirname(templateRootDirectory), "template-assets", "quality");
2533
+ const shared = path7.join(path7.dirname(templateRootDirectory), "template-assets", "quality");
2414
2534
  if (!existsSync(shared)) throw new Error(`TN_QUALITY_CONFIG_MISSING: ${shared}`);
2415
2535
  await cp(shared, target, { errorOnExist: true, recursive: true });
2416
2536
  }
@@ -2423,7 +2543,7 @@ function nonEmptyString2(value, field, file) {
2423
2543
  return value;
2424
2544
  }
2425
2545
  function loadManifest(directory) {
2426
- const file = path6.join(directory, "kit.json");
2546
+ const file = path7.join(directory, "kit.json");
2427
2547
  let raw;
2428
2548
  try {
2429
2549
  raw = readFileSync(file, "utf8");
@@ -2441,7 +2561,7 @@ function loadManifest(directory) {
2441
2561
  if (typeof value !== "object" || value === null || Array.isArray(value))
2442
2562
  return invalidManifest(file, "the root must be an object");
2443
2563
  const record = value;
2444
- const directoryName = path6.basename(directory);
2564
+ const directoryName = path7.basename(directory);
2445
2565
  const name = nonEmptyString2(record.name, "name", file);
2446
2566
  if (!TEMPLATE_NAME.test(name))
2447
2567
  return invalidManifest(file, "name must match /^[a-z][a-z0-9-]*$/");
@@ -2461,7 +2581,7 @@ function loadManifest(directory) {
2461
2581
  };
2462
2582
  }
2463
2583
  function discoverKitManifests(root = templateRoot()) {
2464
- return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => loadManifest(path6.join(root, entry.name))).sort((left, right) => left.name.localeCompare(right.name));
2584
+ return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => loadManifest(path7.join(root, entry.name))).sort((left, right) => left.name.localeCompare(right.name));
2465
2585
  }
2466
2586
  function discoverTemplateNames(root = templateRoot()) {
2467
2587
  return discoverKitManifests(root).map(({ name }) => name);
@@ -2507,7 +2627,7 @@ function scaffoldNextSteps(target, installed, servers = []) {
2507
2627
  function projectMcpServers(target) {
2508
2628
  try {
2509
2629
  return Object.keys(
2510
- JSON.parse(readFileSync(path6.join(target, ".mcp.json"), "utf8")).mcpServers ?? {}
2630
+ JSON.parse(readFileSync(path7.join(target, ".mcp.json"), "utf8")).mcpServers ?? {}
2511
2631
  );
2512
2632
  } catch {
2513
2633
  return [];
@@ -2586,7 +2706,7 @@ function cliHelp() {
2586
2706
  `;
2587
2707
  }
2588
2708
  function packageName(target) {
2589
- const name = path6.basename(target).toLowerCase().replace(/[^a-z0-9-_]+/g, "-");
2709
+ const name = path7.basename(target).toLowerCase().replace(/[^a-z0-9-_]+/g, "-");
2590
2710
  if (name.length === 0 || name === "-" || name === "_") {
2591
2711
  throw new Error(`Cannot derive a package name from '${target}'.`);
2592
2712
  }
@@ -2609,12 +2729,12 @@ function substituteTemplateVariables(content, replacements) {
2609
2729
  async function renderTemplate(directory, replacements) {
2610
2730
  const files = await readdir(directory, { withFileTypes: true });
2611
2731
  for (const entry of files) {
2612
- const source = path6.join(directory, entry.name);
2732
+ const source = path7.join(directory, entry.name);
2613
2733
  if (entry.isDirectory()) {
2614
2734
  await renderTemplate(source, replacements);
2615
2735
  continue;
2616
2736
  }
2617
- if (!TEXT_FILE_EXTENSIONS.has(path6.extname(entry.name))) continue;
2737
+ if (!TEXT_FILE_EXTENSIONS.has(path7.extname(entry.name))) continue;
2618
2738
  const content = await readFile(source, "utf8");
2619
2739
  let rendered = substituteTemplateVariables(content, replacements);
2620
2740
  if (entry.name === "AGENTS.md" || entry.name === "CLAUDE.md") {
@@ -2629,6 +2749,8 @@ var AGENT_FILES_DIRECTORY = "agent-files";
2629
2749
  var AUTHORING_GITIGNORE_RULES = [
2630
2750
  "# ThreeNative local authoring state and dependency secrets",
2631
2751
  ".dream-loop/",
2752
+ // The discovery gate's per-session prompt time (PRD-827).
2753
+ ".threenative/discovery-gate.json",
2632
2754
  "node_modules/",
2633
2755
  ".env",
2634
2756
  ".env.*",
@@ -2644,27 +2766,27 @@ var REFERENCE_TOKEN_PATTERN = new RegExp(
2644
2766
  "gu"
2645
2767
  );
2646
2768
  async function linkClaudeSkills(target) {
2647
- const stored = path6.join(target, ".agents", "skills");
2769
+ const stored = path7.join(target, ".agents", "skills");
2648
2770
  if (!existsSync(stored)) return;
2649
- const hostSkills = path6.join(target, ".claude", "skills");
2650
- const subagents = path6.join(target, ".claude", "agents");
2771
+ const hostSkills = path7.join(target, ".claude", "skills");
2772
+ const subagents = path7.join(target, ".claude", "agents");
2651
2773
  await mkdir(hostSkills, { recursive: true });
2652
2774
  for (const entry of await readdir(stored, { withFileTypes: true })) {
2653
2775
  if (!entry.isDirectory()) continue;
2654
- if (existsSync(path6.join(subagents, `${entry.name}.md`))) continue;
2655
- const link = path6.join(hostSkills, entry.name);
2656
- const relative = path6.relative(hostSkills, path6.join(stored, entry.name));
2776
+ if (existsSync(path7.join(subagents, `${entry.name}.md`))) continue;
2777
+ const link = path7.join(hostSkills, entry.name);
2778
+ const relative = path7.relative(hostSkills, path7.join(stored, entry.name));
2657
2779
  try {
2658
2780
  await symlink(relative, link, "dir");
2659
2781
  } catch (error) {
2660
2782
  const code = error.code;
2661
2783
  if (code !== "EPERM" && code !== "EACCES") throw error;
2662
- await cp(path6.join(stored, entry.name), link, { recursive: true });
2784
+ await cp(path7.join(stored, entry.name), link, { recursive: true });
2663
2785
  }
2664
2786
  }
2665
2787
  }
2666
2788
  async function copyAgentFiles(target, templateRootDirectory) {
2667
- const source = path6.join(path6.dirname(templateRootDirectory), AGENT_FILES_DIRECTORY);
2789
+ const source = path7.join(path7.dirname(templateRootDirectory), AGENT_FILES_DIRECTORY);
2668
2790
  if (!existsSync(source)) {
2669
2791
  throw new Error(
2670
2792
  `TN_AGENT_FILES_MISSING: '${source}' is not in the package; every generated project needs the canonical agent roles.`
@@ -2674,7 +2796,7 @@ async function copyAgentFiles(target, templateRootDirectory) {
2674
2796
  await linkClaudeSkills(target);
2675
2797
  }
2676
2798
  async function installAuthoringGitignore(target) {
2677
- const file = path6.join(target, ".gitignore");
2799
+ const file = path7.join(target, ".gitignore");
2678
2800
  const existing = existsSync(file) ? await readFile(file, "utf8") : "";
2679
2801
  const present = new Set(existing.split(/\r?\n/u));
2680
2802
  const missing = AUTHORING_GITIGNORE_RULES.filter((entry) => !present.has(entry));
@@ -2688,8 +2810,8 @@ async function installAuthoringGitignore(target) {
2688
2810
  );
2689
2811
  }
2690
2812
  async function assertReferenceBundle(target, templateRootDirectory) {
2691
- const bundleDirectory = path6.join(
2692
- path6.dirname(templateRootDirectory),
2813
+ const bundleDirectory = path7.join(
2814
+ path7.dirname(templateRootDirectory),
2693
2815
  "agent-docs",
2694
2816
  "references"
2695
2817
  );
@@ -2701,7 +2823,7 @@ async function assertReferenceBundle(target, templateRootDirectory) {
2701
2823
  ".agents/skills/threenative-assets/SKILL.md",
2702
2824
  ".claude/skills/threenative-assets/SKILL.md"
2703
2825
  ]) {
2704
- const filePath = path6.join(target, file);
2826
+ const filePath = path7.join(target, file);
2705
2827
  if (existsSync(filePath)) await assertReferenceTargets(file, filePath, bundleDirectory);
2706
2828
  }
2707
2829
  }
@@ -2715,7 +2837,7 @@ async function assertReferenceTargets(from, filePath, bundleDirectory) {
2715
2837
  `RED observed: referenced recipe missing: '${from}' names '${referenced}', which is not a shipped reference page.`
2716
2838
  );
2717
2839
  }
2718
- if (!existsSync(path6.join(bundleDirectory, referenced))) {
2840
+ if (!existsSync(path7.join(bundleDirectory, referenced))) {
2719
2841
  throw new Error(
2720
2842
  `RED observed: referenced recipe missing: '${from}' links '${REFERENCE_BUNDLE_PREFIX}${referenced}', which the package does not ship.`
2721
2843
  );
@@ -2723,12 +2845,17 @@ async function assertReferenceTargets(from, filePath, bundleDirectory) {
2723
2845
  }
2724
2846
  }
2725
2847
  async function applyPackageSources(target, packageSources) {
2726
- if (packageSources === void 0) return;
2727
- const packagePath = path6.join(target, "package.json");
2848
+ const packagePath = path7.join(target, "package.json");
2728
2849
  const packageJson = JSON.parse(await readFile(packagePath, "utf8"));
2850
+ packageJson.packageManager = SUPPORTED_PACKAGE_MANAGER;
2851
+ if (packageSources === void 0) {
2852
+ await writeFile(packagePath, `${JSON.stringify(packageJson, null, 2)}
2853
+ `);
2854
+ return;
2855
+ }
2729
2856
  const localSource = (source) => {
2730
2857
  const filePath = source.startsWith("file:") ? source.slice("file:".length) : source;
2731
- return `file:${path6.resolve(filePath)}`;
2858
+ return `file:${path7.resolve(filePath)}`;
2732
2859
  };
2733
2860
  for (const [name, source] of Object.entries(packageSources)) {
2734
2861
  if (source === void 0) continue;
@@ -2757,19 +2884,19 @@ var FRAMEWORK_PATCH_SOURCES = {
2757
2884
  "@tailwindcss__node@4.3.3.patch": "../../patches/@tailwindcss__node@4.3.3.patch"
2758
2885
  };
2759
2886
  async function copyFrameworkPatches(target, templateRootDirectory) {
2760
- const manifest = JSON.parse(await readFile(path6.join(target, "package.json"), "utf8"));
2761
- const packageRoot = path6.dirname(templateRoot());
2887
+ const manifest = JSON.parse(await readFile(path7.join(target, "package.json"), "utf8"));
2888
+ const packageRoot = path7.dirname(templateRoot());
2762
2889
  for (const relative of Object.values(manifest.pnpm?.patchedDependencies ?? {})) {
2763
- const name = path6.basename(relative);
2890
+ const name = path7.basename(relative);
2764
2891
  const fallback = FRAMEWORK_PATCH_SOURCES[name];
2765
2892
  if (fallback === void 0 || relative !== `${FRAMEWORK_PATCH_DIRECTORY}/${name}`) {
2766
2893
  throw new Error(`TN_FRAMEWORK_PATCH_MISSING: unsupported template patch '${relative}'.`);
2767
2894
  }
2768
- const candidates = [.../* @__PURE__ */ new Set([path6.dirname(templateRootDirectory), packageRoot])].map(
2769
- (root) => path6.join(root, "template-assets", FRAMEWORK_PATCH_DIRECTORY, name)
2895
+ const candidates = [.../* @__PURE__ */ new Set([path7.dirname(templateRootDirectory), packageRoot])].map(
2896
+ (root) => path7.join(root, "template-assets", FRAMEWORK_PATCH_DIRECTORY, name)
2770
2897
  );
2771
- const canonical = path6.resolve(packageRoot, fallback);
2772
- if (existsSync(path6.join(packageRoot, "src", "index.ts"))) candidates.unshift(canonical);
2898
+ const canonical = path7.resolve(packageRoot, fallback);
2899
+ if (existsSync(path7.join(packageRoot, "src", "index.ts"))) candidates.unshift(canonical);
2773
2900
  else candidates.push(canonical);
2774
2901
  const source = candidates.find((candidate) => existsSync(candidate));
2775
2902
  if (source === void 0) {
@@ -2777,8 +2904,8 @@ async function copyFrameworkPatches(target, templateRootDirectory) {
2777
2904
  `TN_FRAMEWORK_PATCH_MISSING: dependency patch '${name}' is absent from the CLI package.`
2778
2905
  );
2779
2906
  }
2780
- const destination = path6.join(target, relative);
2781
- await mkdir(path6.dirname(destination), { recursive: true });
2907
+ const destination = path7.join(target, relative);
2908
+ await mkdir(path7.dirname(destination), { recursive: true });
2782
2909
  await cp(source, destination);
2783
2910
  }
2784
2911
  }
@@ -2790,8 +2917,15 @@ function mcpPackageName(entry) {
2790
2917
  const segments = entry.slice(NODE_MODULES_PREFIX.length).split("/");
2791
2918
  return entry.startsWith(`${NODE_MODULES_PREFIX}@`) ? segments.slice(0, 2).join("/") : segments[0] ?? "";
2792
2919
  }
2920
+ function writeHostMcpConfigs(target) {
2921
+ for (const [host, outcome] of ensureHostMcpConfigs(target)) {
2922
+ if (outcome === "unreadable" || outcome === "unwritable") {
2923
+ throw new Error(`TN_MCP_HOST_CONFIG: the ${host} MCP config is '${outcome}'.`);
2924
+ }
2925
+ }
2926
+ }
2793
2927
  async function assertMcpConfig(target) {
2794
- const configPath = path6.join(target, ".mcp.json");
2928
+ const configPath = path7.join(target, ".mcp.json");
2795
2929
  const raw = await readFile(configPath, "utf8").catch(() => {
2796
2930
  throw new Error(`Scaffold produced no .mcp.json at '${configPath}'.`);
2797
2931
  });
@@ -2804,7 +2938,7 @@ async function assertMcpConfig(target) {
2804
2938
  throw new Error(`'${configPath}' is missing required MCP server '${name}'.`);
2805
2939
  }
2806
2940
  }
2807
- const manifest = JSON.parse(await readFile(path6.join(target, "package.json"), "utf8"));
2941
+ const manifest = JSON.parse(await readFile(path7.join(target, "package.json"), "utf8"));
2808
2942
  const declared = /* @__PURE__ */ new Set([
2809
2943
  ...Object.keys(manifest.dependencies ?? {}),
2810
2944
  ...Object.keys(manifest.devDependencies ?? {})
@@ -2838,7 +2972,7 @@ async function assertMcpConfig(target) {
2838
2972
  );
2839
2973
  }
2840
2974
  }
2841
- const codexPath = path6.join(target, ".codex", "config.toml");
2975
+ const codexPath = path7.join(target, ".codex", "config.toml");
2842
2976
  const codex = await readFile(codexPath, "utf8").catch(() => {
2843
2977
  throw new Error(`Scaffold produced no Codex MCP config at '${codexPath}'.`);
2844
2978
  });
@@ -2864,14 +2998,14 @@ async function discardScaffold(target, existedBefore) {
2864
2998
  return;
2865
2999
  }
2866
3000
  for (const entry of await readdir(target)) {
2867
- await rm(path6.join(target, entry), { force: true, recursive: true });
3001
+ await rm(path7.join(target, entry), { force: true, recursive: true });
2868
3002
  }
2869
3003
  }
2870
3004
  async function createProject(options, cwd = process.cwd(), root = templateRoot()) {
2871
3005
  const manifests = discoverKitManifests(root);
2872
3006
  const template = options.template ?? DEFAULT_TEMPLATE;
2873
3007
  if (!manifests.some(({ name }) => name === template)) kitManifest(template, root);
2874
- const target = path6.resolve(cwd, options.target);
3008
+ const target = path7.resolve(cwd, options.target);
2875
3009
  const targetExists = await isEmpty(target).catch(() => false);
2876
3010
  if (!targetExists) {
2877
3011
  throw new Error(`Target '${target}' already exists and is not empty.`);
@@ -2880,16 +3014,17 @@ async function createProject(options, cwd = process.cwd(), root = templateRoot()
2880
3014
  await mkdir(target, { recursive: true });
2881
3015
  const installed = options.install ?? true;
2882
3016
  try {
2883
- const source = path6.join(root, template);
3017
+ const source = path7.join(root, template);
2884
3018
  await cp(source, target, { recursive: true, errorOnExist: true });
3019
+ await rm(path7.join(target, "kit.json"), { force: true });
2885
3020
  if (["starter", "collectathon", "adventure", "kart"].includes(template))
2886
3021
  for (const relative of SHARED_RENDER_SOURCES)
2887
- await cp(canonicalRenderSourcePath(relative, root), path6.join(target, relative));
3022
+ await cp(canonicalRenderSourcePath(relative, root), path7.join(target, relative));
2888
3023
  await copyTemplateIcon(target, root);
2889
3024
  await copySharedAssets(target, root);
2890
3025
  await copyQualityConfig(target, root);
2891
- if (existsSync(path6.join(target, "gitignore"))) {
2892
- await rename(path6.join(target, "gitignore"), path6.join(target, ".gitignore"));
3026
+ if (existsSync(path7.join(target, "gitignore"))) {
3027
+ await rename(path7.join(target, "gitignore"), path7.join(target, ".gitignore"));
2893
3028
  }
2894
3029
  await installAuthoringGitignore(target);
2895
3030
  const projectName = packageName(target);
@@ -2904,6 +3039,7 @@ async function createProject(options, cwd = process.cwd(), root = templateRoot()
2904
3039
  await renderTemplate(target, replacements);
2905
3040
  await copyFrameworkPatches(target, root);
2906
3041
  await applyPackageSources(target, options.packageSources);
3042
+ writeHostMcpConfigs(target);
2907
3043
  await assertMcpConfig(target);
2908
3044
  await assertReferenceBundle(target, root);
2909
3045
  if (installed) await runInstall(target);
@@ -3024,7 +3160,7 @@ async function main() {
3024
3160
  );
3025
3161
  }
3026
3162
  var entryPath = process.argv[1];
3027
- if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path6.resolve(entryPath)) === realpathSync(fileURLToPath(import.meta.url))) {
3163
+ if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path7.resolve(entryPath)) === realpathSync(fileURLToPath(import.meta.url))) {
3028
3164
  main().catch((error) => {
3029
3165
  process.stderr.write(`${error instanceof Error ? error.message : String(error)}
3030
3166
  `);