@waica/cli 0.6.0 → 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.
- package/README.md +1 -1
- package/dist/editor/assets/{cssMode-DfLN2qUF.js → cssMode-eS4pAOyh.js} +1 -1
- package/dist/editor/assets/{freemarker2-BM-wWcXR.js → freemarker2-FMQjZKQk.js} +1 -1
- package/dist/editor/assets/{handlebars-C68SV5M9.js → handlebars-dDYOnqat.js} +1 -1
- package/dist/editor/assets/{html-dQgLbIki.js → html-Ba6xZh4T.js} +1 -1
- package/dist/editor/assets/{htmlMode-Dx91fUdd.js → htmlMode-DC9qJr2p.js} +1 -1
- package/dist/editor/assets/{index-592ABIaz.js → index-CoyeInOT.js} +2031 -269
- package/dist/editor/assets/{javascript-BmsSq5ka.js → javascript-DOwFvmvM.js} +1 -1
- package/dist/editor/assets/{jsonMode-CWoPtX2M.js → jsonMode-CcG7zlSf.js} +1 -1
- package/dist/editor/assets/{liquid-DwnJlNJZ.js → liquid-Dfp71r7J.js} +1 -1
- package/dist/editor/assets/{mdx-DaLkvlR1.js → mdx-Ci7vVeht.js} +1 -1
- package/dist/editor/assets/{python-Cs5X5zFp.js → python-Bluv3Y9Q.js} +1 -1
- package/dist/editor/assets/{razor-PTwWoRk8.js → razor-BtwTXMaK.js} +1 -1
- package/dist/editor/assets/{tsMode-BqUQdgsR.js → tsMode-D3_D-H85.js} +1 -1
- package/dist/editor/assets/{typescript-BsJ7r2RJ.js → typescript-Ch_PS5f7.js} +1 -1
- package/dist/editor/assets/{xml-DyyoPey4.js → xml-CI_bH_MX.js} +1 -1
- package/dist/editor/assets/{yaml-Cjqtlp29.js → yaml-LD9GTZyy.js} +1 -1
- package/dist/editor/index.html +1 -1
- package/dist/mcp/archetypes.js +6 -2
- package/dist/mcp/create-project.js +12 -6
- package/dist/mcp/known-archetypes.js +19 -0
- package/dist/mcp/node_modules/@waica/archetype-platformer/dist/prefabs.js +1 -1
- package/dist/mcp/node_modules/@waica/archetype-platformer/dist/scene-default.js +9 -1
- package/dist/mcp/node_modules/@waica/archetype-platformer/package.json +3 -3
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/ATTRIBUTION.md +28 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-blob.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-fence.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-grass.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-hero.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-npc.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-path.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-potion.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-tree.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/assets/waica-water.png +0 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/animation.d.ts +7 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/animation.js +10 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/art.d.ts +10 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/art.js +19 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/bundle.d.ts +3 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/bundle.js +10 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/controls.d.ts +5 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/controls.js +16 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/index.d.ts +25 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/index.js +16 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/manifest.d.ts +16 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/manifest.js +29 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/prefabs.d.ts +11 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/prefabs.js +178 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry-data.d.ts +9 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry-data.js +54 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry.d.ts +6 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/registry.js +21 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/scene-default.d.ts +57 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/scene-default.js +110 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/ui.d.ts +10 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/dist/ui.js +43 -0
- package/dist/mcp/node_modules/@waica/archetype-topdown/package.json +30 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/index.d.ts +3 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/index.js +3 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/interactable.d.ts +31 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/interactable.js +49 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/platformer-motor.d.ts +4 -2
- package/dist/mcp/node_modules/@waica/behaviors/dist/platformer-motor.js +5 -1
- package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-motor.d.ts +72 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-motor.js +102 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-player-states.d.ts +18 -0
- package/dist/mcp/node_modules/@waica/behaviors/dist/topdown-player-states.js +86 -0
- package/dist/mcp/node_modules/@waica/behaviors/package.json +2 -2
- package/dist/mcp/node_modules/@waica/engine/dist/animation/directional.d.ts +48 -0
- package/dist/mcp/node_modules/@waica/engine/dist/animation/directional.js +68 -0
- package/dist/mcp/node_modules/@waica/engine/dist/archetype.d.ts +3 -0
- package/dist/mcp/node_modules/@waica/engine/dist/camera.d.ts +19 -0
- package/dist/mcp/node_modules/@waica/engine/dist/camera.js +10 -0
- package/dist/mcp/node_modules/@waica/engine/dist/components/animated-sprite.d.ts +8 -1
- package/dist/mcp/node_modules/@waica/engine/dist/components/animated-sprite.js +19 -2
- package/dist/mcp/node_modules/@waica/engine/dist/components/sprite.d.ts +4 -1
- package/dist/mcp/node_modules/@waica/engine/dist/components/sprite.js +5 -0
- package/dist/mcp/node_modules/@waica/engine/dist/game.d.ts +9 -1
- package/dist/mcp/node_modules/@waica/engine/dist/game.js +32 -3
- package/dist/mcp/node_modules/@waica/engine/dist/index.d.ts +7 -3
- package/dist/mcp/node_modules/@waica/engine/dist/index.js +3 -1
- package/dist/mcp/node_modules/@waica/engine/dist/render-sort.d.ts +31 -0
- package/dist/mcp/node_modules/@waica/engine/dist/render-sort.js +39 -0
- package/dist/mcp/node_modules/@waica/engine/dist/scene.d.ts +10 -0
- package/dist/mcp/node_modules/@waica/engine/dist/scene.js +1 -0
- package/dist/mcp/node_modules/@waica/engine/dist/state/hooks.d.ts +1 -1
- package/dist/mcp/node_modules/@waica/engine/dist/state/hooks.js +3 -1
- package/dist/mcp/node_modules/@waica/engine/dist/state/state-machine.d.ts +18 -0
- package/dist/mcp/node_modules/@waica/engine/dist/state/state-machine.js +57 -1
- package/dist/mcp/node_modules/@waica/engine/package.json +1 -1
- package/dist/mcp/package-resolver.js +10 -4
- package/dist/mcp/project-component-loader.js +2 -1
- package/dist/mcp/project-component-runner.js +4 -0
- package/dist/mcp/server.js +18 -1
- package/dist/mcp/template/package.json.tpl +1 -1
- package/dist/mcp/template/src/characters/player.character.json +1 -1
- package/dist/mcp/template/src/main.ts +8 -4
- package/dist/mcp/template/src/scenes/main.scene.json +7 -1
- package/dist/mcp/workspace-runtime.js +41 -10
- 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
|
-
[
|
|
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']);
|
package/dist/mcp/server.js
CHANGED
|
@@ -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
|
-
|
|
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);
|
|
@@ -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 {
|
|
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
|
-
...
|
|
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] ??
|
|
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(
|
|
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
|
-
|
|
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
|
|
82
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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({
|