@waica/cli 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +1 -1
  2. package/dist/editor/assets/{cssMode-D3SZSKEA.js → cssMode-eS4pAOyh.js} +1 -1
  3. package/dist/editor/assets/{freemarker2-BH1pa3TU.js → freemarker2-FMQjZKQk.js} +1 -1
  4. package/dist/editor/assets/{handlebars-Cf7meNHo.js → handlebars-dDYOnqat.js} +1 -1
  5. package/dist/editor/assets/{html-6hqYzl5P.js → html-Ba6xZh4T.js} +1 -1
  6. package/dist/editor/assets/{htmlMode-D_IiyUdi.js → htmlMode-DC9qJr2p.js} +1 -1
  7. package/dist/editor/assets/{index-CJyB1cBF.js → index-CoyeInOT.js} +2029 -268
  8. package/dist/editor/assets/{javascript-CTeTqLj8.js → javascript-DOwFvmvM.js} +1 -1
  9. package/dist/editor/assets/{jsonMode-t8AC-38H.js → jsonMode-CcG7zlSf.js} +1 -1
  10. package/dist/editor/assets/{liquid-Dc6NoKas.js → liquid-Dfp71r7J.js} +1 -1
  11. package/dist/editor/assets/{mdx-DCPtX-bs.js → mdx-Ci7vVeht.js} +1 -1
  12. package/dist/editor/assets/{python-DXAju_oJ.js → python-Bluv3Y9Q.js} +1 -1
  13. package/dist/editor/assets/{razor-DqQldpv6.js → razor-BtwTXMaK.js} +1 -1
  14. package/dist/editor/assets/{tsMode-B60EhHlZ.js → tsMode-D3_D-H85.js} +1 -1
  15. package/dist/editor/assets/{typescript-C4LyYAns.js → typescript-Ch_PS5f7.js} +1 -1
  16. package/dist/editor/assets/{xml-B0QcT5_Z.js → xml-CI_bH_MX.js} +1 -1
  17. package/dist/editor/assets/{yaml-CEpyO2Qc.js → yaml-LD9GTZyy.js} +1 -1
  18. package/dist/editor/index.html +1 -1
  19. package/dist/mcp/archetypes.js +6 -2
  20. package/dist/mcp/create-project.js +12 -6
  21. package/dist/mcp/known-archetypes.js +19 -0
  22. package/dist/mcp/node_modules/@waica/archetype-platformer/package.json +3 -3
  23. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/ATTRIBUTION.md +28 -0
  24. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-blob.png +0 -0
  25. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-fence.png +0 -0
  26. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-grass.png +0 -0
  27. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-hero.png +0 -0
  28. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-npc.png +0 -0
  29. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-path.png +0 -0
  30. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-potion.png +0 -0
  31. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-tree.png +0 -0
  32. package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-water.png +0 -0
  33. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/animation.d.ts +7 -0
  34. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/animation.js +10 -0
  35. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/art.d.ts +10 -0
  36. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/art.js +19 -0
  37. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/bundle.d.ts +3 -0
  38. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/bundle.js +10 -0
  39. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/controls.d.ts +5 -0
  40. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/controls.js +16 -0
  41. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/index.d.ts +25 -0
  42. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/index.js +16 -0
  43. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/manifest.d.ts +16 -0
  44. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/manifest.js +29 -0
  45. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/prefabs.d.ts +11 -0
  46. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/prefabs.js +178 -0
  47. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry-data.d.ts +9 -0
  48. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry-data.js +54 -0
  49. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry.d.ts +6 -0
  50. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry.js +21 -0
  51. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/scene-default.d.ts +57 -0
  52. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/scene-default.js +110 -0
  53. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/ui.d.ts +10 -0
  54. package/dist/mcp/node_modules/@waica/archetype-topdown/dist/ui.js +43 -0
  55. package/dist/mcp/node_modules/@waica/archetype-topdown/package.json +30 -0
  56. package/dist/mcp/node_modules/@waica/behaviors/dist/index.d.ts +3 -0
  57. package/dist/mcp/node_modules/@waica/behaviors/dist/index.js +3 -0
  58. package/dist/mcp/node_modules/@waica/behaviors/dist/interactable.d.ts +31 -0
  59. package/dist/mcp/node_modules/@waica/behaviors/dist/interactable.js +49 -0
  60. package/dist/mcp/node_modules/@waica/behaviors/dist/platformer-motor.d.ts +4 -2
  61. package/dist/mcp/node_modules/@waica/behaviors/dist/platformer-motor.js +5 -1
  62. package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-motor.d.ts +72 -0
  63. package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-motor.js +102 -0
  64. package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-player-states.d.ts +18 -0
  65. package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-player-states.js +86 -0
  66. package/dist/mcp/node_modules/@waica/behaviors/package.json +2 -2
  67. package/dist/mcp/node_modules/@waica/engine/dist/animation/directional.d.ts +48 -0
  68. package/dist/mcp/node_modules/@waica/engine/dist/animation/directional.js +68 -0
  69. package/dist/mcp/node_modules/@waica/engine/dist/archetype.d.ts +3 -0
  70. package/dist/mcp/node_modules/@waica/engine/dist/camera.d.ts +19 -0
  71. package/dist/mcp/node_modules/@waica/engine/dist/camera.js +10 -0
  72. package/dist/mcp/node_modules/@waica/engine/dist/components/animated-sprite.d.ts +8 -1
  73. package/dist/mcp/node_modules/@waica/engine/dist/components/animated-sprite.js +19 -2
  74. package/dist/mcp/node_modules/@waica/engine/dist/components/sprite.d.ts +4 -1
  75. package/dist/mcp/node_modules/@waica/engine/dist/components/sprite.js +5 -0
  76. package/dist/mcp/node_modules/@waica/engine/dist/game.d.ts +9 -1
  77. package/dist/mcp/node_modules/@waica/engine/dist/game.js +32 -3
  78. package/dist/mcp/node_modules/@waica/engine/dist/index.d.ts +7 -3
  79. package/dist/mcp/node_modules/@waica/engine/dist/index.js +3 -1
  80. package/dist/mcp/node_modules/@waica/engine/dist/render-sort.d.ts +31 -0
  81. package/dist/mcp/node_modules/@waica/engine/dist/render-sort.js +39 -0
  82. package/dist/mcp/node_modules/@waica/engine/dist/scene.d.ts +10 -0
  83. package/dist/mcp/node_modules/@waica/engine/dist/scene.js +1 -0
  84. package/dist/mcp/node_modules/@waica/engine/dist/state/hooks.d.ts +1 -1
  85. package/dist/mcp/node_modules/@waica/engine/dist/state/hooks.js +3 -1
  86. package/dist/mcp/node_modules/@waica/engine/dist/state/state-machine.d.ts +18 -0
  87. package/dist/mcp/node_modules/@waica/engine/dist/state/state-machine.js +57 -1
  88. package/dist/mcp/node_modules/@waica/engine/package.json +1 -1
  89. package/dist/mcp/package-resolver.js +10 -4
  90. package/dist/mcp/project-component-loader.js +2 -1
  91. package/dist/mcp/project-component-runner.js +4 -0
  92. package/dist/mcp/server.js +18 -1
  93. package/dist/mcp/template/package.json.tpl +1 -1
  94. package/dist/mcp/template/src/main.ts +8 -4
  95. package/dist/mcp/workspace-runtime.js +41 -10
  96. package/package.json +1 -1
@@ -7,6 +7,7 @@ import { tmpdir } from 'node:os';
7
7
  import path from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { promisify } from 'node:util';
10
+ import { KNOWN_ARCHETYPES } from './known-archetypes.js';
10
11
  import { directFiles } from './project-path.js';
11
12
  export const PROJECT_COMPONENT_PROTOCOL_VERSION = 1;
12
13
  export const PROJECT_COMPONENT_DEADLINE_MS = 5_000;
@@ -16,7 +17,7 @@ const REF_KINDS = new Set(['prefab', 'clip', 'action', 'stat']);
16
17
  const FALLBACK_PACKAGE_DIRECTORIES = [
17
18
  ['@waica/engine', 'engine'],
18
19
  ['@waica/behaviors', 'behaviors'],
19
- ['@waica/archetype-platformer', 'archetype-platformer'],
20
+ ...KNOWN_ARCHETYPES.map(({ packageName, directory }) => [packageName, directory]),
20
21
  ];
21
22
  const execFileAsync = promisify(execFile);
22
23
  let sourceFallbackEntries;
@@ -5,10 +5,14 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
5
5
  const PROTOCOL_VERSION = 1;
6
6
  const { createRequire } = nodeModule;
7
7
  const hostRequire = createRequire(import.meta.url);
8
+ // This file runs as a standalone forked child (see runnerFromModule in the
9
+ // loader) and cannot import siblings, so it mirrors known-archetypes.ts by
10
+ // hand: one entry per KNOWN_ARCHETYPES row, plus engine and behaviors.
8
11
  const FALLBACK_PACKAGES = new Set([
9
12
  '@waica/engine',
10
13
  '@waica/behaviors',
11
14
  '@waica/archetype-platformer',
15
+ '@waica/archetype-topdown',
12
16
  ]);
13
17
  const FALLBACK_SPECIFIERS = new Set([...FALLBACK_PACKAGES, 'three']);
14
18
  const REF_KINDS = new Set(['prefab', 'clip', 'action', 'stat']);
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
5
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
6
6
  import { createProject } from './create-project.js';
7
+ import { DEFAULT_ARCHETYPE_ID, knownArchetype, knownArchetypeIds, } from './known-archetypes.js';
7
8
  import { describeArchetype, listComponents, projectSummary, } from './introspection.js';
8
9
  import { ABSOLUTE_PATH_MESSAGE, WaicaToolError, assertAbsoluteProjectPath, requireWaicaProject, } from './project-path.js';
9
10
  import { scaffoldComponent, scaffoldPrefab, scaffoldRole, scaffoldState, scaffoldUi, } from './scaffolds.js';
@@ -34,6 +35,12 @@ export const TOOLS = [
34
35
  default: 'demo',
35
36
  description: 'demo includes archetype content; blank creates only the chassis.',
36
37
  },
38
+ archetype: {
39
+ type: 'string',
40
+ enum: knownArchetypeIds(),
41
+ default: DEFAULT_ARCHETYPE_ID,
42
+ description: 'Archetype the project is created for.',
43
+ },
37
44
  }),
38
45
  annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: false },
39
46
  },
@@ -352,7 +359,17 @@ async function execute(name, args, runtime, signal, componentLoader) {
352
359
  projectPath,
353
360
  });
354
361
  }
355
- return { ...(await createProject(projectPath, start)) };
362
+ const archetype = args.archetype === undefined
363
+ ? DEFAULT_ARCHETYPE_ID
364
+ : requiredString(args, 'archetype', projectPath);
365
+ if (!knownArchetype(archetype)) {
366
+ throw new WaicaToolError({
367
+ code: 'unknown-archetype',
368
+ message: `Unknown archetype "${archetype}"; available: ${knownArchetypeIds().join(', ')}.`,
369
+ projectPath,
370
+ });
371
+ }
372
+ return { ...(await createProject(projectPath, start, archetype)) };
356
373
  }
357
374
  case 'list_components':
358
375
  return listComponents(projectPath);
@@ -9,7 +9,7 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@waica/archetype-platformer": "^__WAICA_VERSION__",
12
+ "__ARCHETYPE_PACKAGE__": "^__WAICA_VERSION__",
13
13
  "@waica/behaviors": "^__WAICA_VERSION__",
14
14
  "@waica/engine": "^__WAICA_VERSION__"
15
15
  },
@@ -2,11 +2,12 @@ import {
2
2
  collectModuleComponents,
3
3
  Game,
4
4
  installArchetype,
5
+ installDirectionalAnimation,
5
6
  loadScene,
6
7
  mergeRegistryComponents,
7
8
  type PrefabJson,
8
9
  } from '@waica/engine'
9
- import { PLATFORMER_BUNDLE, PLATFORMER_REGISTRY } from '@waica/archetype-platformer'
10
+ import { ARCHETYPE } from '__ARCHETYPE_PACKAGE__'
10
11
  import scene from './scenes/main.scene.json'
11
12
  import controls from './controls.json'
12
13
  import stats from './stats.json'
@@ -60,14 +61,14 @@ for (const [path, url] of Object.entries(artFiles)) {
60
61
  }
61
62
 
62
63
  const registryBase = {
63
- ...PLATFORMER_REGISTRY,
64
+ ...ARCHETYPE.registry,
64
65
  // Keep these two: the spread above carries the archetype's own catalogs,
65
66
  // and these replace them with yours. Drop one and the game starts
66
67
  // resolving pieces that are nowhere in src/.
67
68
  prefabs,
68
69
  ui,
69
70
  resolveAsset: (uri: string) =>
70
- artUrls[uri] ?? PLATFORMER_REGISTRY.resolveAsset?.(uri) ?? uri,
71
+ artUrls[uri] ?? ARCHETYPE.registry.resolveAsset?.(uri) ?? uri,
71
72
  }
72
73
 
73
74
  const canvas = document.querySelector<HTMLCanvasElement>('#game')
@@ -82,7 +83,10 @@ if (canvas.dataset.waica) {
82
83
  }
83
84
 
84
85
  async function main(canvas: HTMLCanvasElement): Promise<void> {
85
- installArchetype(PLATFORMER_BUNDLE)
86
+ installArchetype(ARCHETYPE.bundle)
87
+ // installArchetype resets the directional registry, so the contract goes
88
+ // right after it (archetypes without one install null — a no-op).
89
+ installDirectionalAnimation(ARCHETYPE.animation ?? null)
86
90
  const projectModules = await Promise.all(Object.values(projectCode).map((load) => load()))
87
91
  const registry = mergeRegistryComponents(
88
92
  registryBase,
@@ -1,11 +1,12 @@
1
1
  import { access, readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
+ import { KNOWN_ARCHETYPES } from './known-archetypes.js';
4
5
  const here = path.dirname(fileURLToPath(import.meta.url));
5
6
  const WORKSPACE_DIRECTORIES = {
6
7
  '@waica/engine': 'engine',
7
8
  '@waica/behaviors': 'behaviors',
8
- '@waica/archetype-platformer': 'archetype-platformer',
9
+ ...Object.fromEntries(KNOWN_ARCHETYPES.map(({ packageName, directory }) => [packageName, directory])),
9
10
  };
10
11
  let workspaceHooks;
11
12
  let workspacePackages;
@@ -68,6 +69,40 @@ export async function workspacePackageRoot(packageName) {
68
69
  workspacePackages ??= loadWorkspacePackages();
69
70
  return (await workspacePackages).get(packageName);
70
71
  }
72
+ /**
73
+ * Which workspace mappings the runtime hook should install. Engine and
74
+ * behaviors gate the whole plan — nothing loads without them — but each
75
+ * archetype only gates itself: a missing archetype dist drops that
76
+ * archetype's mappings with a warning instead of disabling every mapping.
77
+ */
78
+ export async function planWorkspaceRuntime(repositoryRoot, fileExists = exists) {
79
+ const core = {
80
+ '@waica/engine': path.join(repositoryRoot, 'packages/engine/dist/index.js'),
81
+ '@waica/behaviors': path.join(repositoryRoot, 'packages/behaviors/dist/index.js'),
82
+ };
83
+ if (!(await Promise.all(Object.values(core).map(fileExists))).every(Boolean))
84
+ return undefined;
85
+ const files = { ...core };
86
+ const directories = ['engine', 'behaviors'];
87
+ const warnings = [];
88
+ for (const { packageName, directory } of KNOWN_ARCHETYPES) {
89
+ const index = path.join(repositoryRoot, 'packages', directory, 'dist/index.js');
90
+ const manifest = path.join(repositoryRoot, 'packages', directory, 'dist/manifest.js');
91
+ if ((await fileExists(index)) && (await fileExists(manifest))) {
92
+ files[packageName] = index;
93
+ files[`${packageName}/manifest`] = manifest;
94
+ directories.push(directory);
95
+ }
96
+ else {
97
+ warnings.push(`waica-mcp: workspace archetype ${packageName} has no built dist; its workspace mappings were skipped.`);
98
+ }
99
+ }
100
+ return {
101
+ mappings: Object.fromEntries(Object.entries(files).map(([specifier, file]) => [specifier, pathToFileURL(file).href])),
102
+ parentPrefixes: directories.map((directory) => `${pathToFileURL(path.join(repositoryRoot, 'packages', directory, 'dist')).href}/`),
103
+ warnings,
104
+ };
105
+ }
71
106
  /**
72
107
  * Built workspace packages still import one another by bare package name while
73
108
  * checkout exports point at source TypeScript. Map only imports whose parent is
@@ -78,16 +113,12 @@ export async function prepareWorkspaceRuntime() {
78
113
  const repositoryRoot = await findWorkspaceRoot();
79
114
  if (repositoryRoot === undefined)
80
115
  return;
81
- const files = {
82
- '@waica/engine': path.join(repositoryRoot, 'packages/engine/dist/index.js'),
83
- '@waica/behaviors': path.join(repositoryRoot, 'packages/behaviors/dist/index.js'),
84
- '@waica/archetype-platformer': path.join(repositoryRoot, 'packages/archetype-platformer/dist/index.js'),
85
- '@waica/archetype-platformer/manifest': path.join(repositoryRoot, 'packages/archetype-platformer/dist/manifest.js'),
86
- };
87
- if (!(await Promise.all(Object.values(files).map(exists))).every(Boolean))
116
+ const plan = await planWorkspaceRuntime(repositoryRoot);
117
+ if (plan === undefined)
88
118
  return;
89
- const mappings = Object.fromEntries(Object.entries(files).map(([specifier, file]) => [specifier, pathToFileURL(file).href]));
90
- const parentPrefixes = ['engine', 'behaviors', 'archetype-platformer'].map((directory) => `${pathToFileURL(path.join(repositoryRoot, 'packages', directory, 'dist')).href}/`);
119
+ for (const warning of plan.warnings)
120
+ console.warn(warning);
121
+ const { mappings, parentPrefixes } = plan;
91
122
  const moduleApi = await import('node:module');
92
123
  if (typeof moduleApi.registerHooks === 'function') {
93
124
  workspaceHooks = moduleApi.registerHooks({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waica/cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Waica in one command — `npx @waica/cli` opens the editor, `waica mcp` serves the MCP server",
5
5
  "license": "MIT",
6
6
  "type": "module",