rpgmaker-mz-mcp 1.0.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 (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +425 -0
  3. package/dist/events/commandBuilders.d.ts +405 -0
  4. package/dist/events/commandBuilders.d.ts.map +1 -0
  5. package/dist/events/commandBuilders.js +554 -0
  6. package/dist/events/commandBuilders.js.map +1 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +105 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/registry.d.ts +81 -0
  12. package/dist/registry.d.ts.map +1 -0
  13. package/dist/registry.js +49 -0
  14. package/dist/registry.js.map +1 -0
  15. package/dist/tiles/autotile.d.ts +65 -0
  16. package/dist/tiles/autotile.d.ts.map +1 -0
  17. package/dist/tiles/autotile.js +201 -0
  18. package/dist/tiles/autotile.js.map +1 -0
  19. package/dist/tiles/catalog/dungeon.d.ts +16 -0
  20. package/dist/tiles/catalog/dungeon.d.ts.map +1 -0
  21. package/dist/tiles/catalog/dungeon.js +765 -0
  22. package/dist/tiles/catalog/dungeon.js.map +1 -0
  23. package/dist/tiles/catalog/index.d.ts +78 -0
  24. package/dist/tiles/catalog/index.d.ts.map +1 -0
  25. package/dist/tiles/catalog/index.js +115 -0
  26. package/dist/tiles/catalog/index.js.map +1 -0
  27. package/dist/tiles/catalog/inside.d.ts +16 -0
  28. package/dist/tiles/catalog/inside.d.ts.map +1 -0
  29. package/dist/tiles/catalog/inside.js +765 -0
  30. package/dist/tiles/catalog/inside.js.map +1 -0
  31. package/dist/tiles/catalog/outside.d.ts +16 -0
  32. package/dist/tiles/catalog/outside.d.ts.map +1 -0
  33. package/dist/tiles/catalog/outside.js +799 -0
  34. package/dist/tiles/catalog/outside.js.map +1 -0
  35. package/dist/tiles/catalog/overworld.d.ts +16 -0
  36. package/dist/tiles/catalog/overworld.d.ts.map +1 -0
  37. package/dist/tiles/catalog/overworld.js +585 -0
  38. package/dist/tiles/catalog/overworld.js.map +1 -0
  39. package/dist/tiles/catalog/sf.d.ts +16 -0
  40. package/dist/tiles/catalog/sf.d.ts.map +1 -0
  41. package/dist/tiles/catalog/sf.js +1313 -0
  42. package/dist/tiles/catalog/sf.js.map +1 -0
  43. package/dist/tiles/paint.d.ts +20 -0
  44. package/dist/tiles/paint.d.ts.map +1 -0
  45. package/dist/tiles/paint.js +65 -0
  46. package/dist/tiles/paint.js.map +1 -0
  47. package/dist/tiles/png.d.ts +11 -0
  48. package/dist/tiles/png.d.ts.map +1 -0
  49. package/dist/tiles/png.js +180 -0
  50. package/dist/tiles/png.js.map +1 -0
  51. package/dist/tiles/tileCodec.d.ts +95 -0
  52. package/dist/tiles/tileCodec.d.ts.map +1 -0
  53. package/dist/tiles/tileCodec.js +186 -0
  54. package/dist/tiles/tileCodec.js.map +1 -0
  55. package/dist/tiles/tileFlags.d.ts +98 -0
  56. package/dist/tiles/tileFlags.d.ts.map +1 -0
  57. package/dist/tiles/tileFlags.js +129 -0
  58. package/dist/tiles/tileFlags.js.map +1 -0
  59. package/dist/tiles/tilegeom.d.ts +29 -0
  60. package/dist/tiles/tilegeom.d.ts.map +1 -0
  61. package/dist/tiles/tilegeom.js +111 -0
  62. package/dist/tiles/tilegeom.js.map +1 -0
  63. package/dist/tiles/transparency.d.ts +22 -0
  64. package/dist/tiles/transparency.d.ts.map +1 -0
  65. package/dist/tiles/transparency.js +59 -0
  66. package/dist/tiles/transparency.js.map +1 -0
  67. package/dist/tools/actorTools.d.ts +48 -0
  68. package/dist/tools/actorTools.d.ts.map +1 -0
  69. package/dist/tools/actorTools.js +154 -0
  70. package/dist/tools/actorTools.js.map +1 -0
  71. package/dist/tools/allTools.d.ts +8 -0
  72. package/dist/tools/allTools.d.ts.map +1 -0
  73. package/dist/tools/allTools.js +56 -0
  74. package/dist/tools/allTools.js.map +1 -0
  75. package/dist/tools/assetTools.d.ts +113 -0
  76. package/dist/tools/assetTools.d.ts.map +1 -0
  77. package/dist/tools/assetTools.js +97 -0
  78. package/dist/tools/assetTools.js.map +1 -0
  79. package/dist/tools/batchTools.d.ts +3 -0
  80. package/dist/tools/batchTools.d.ts.map +1 -0
  81. package/dist/tools/batchTools.js +138 -0
  82. package/dist/tools/batchTools.js.map +1 -0
  83. package/dist/tools/battleTools.d.ts +72 -0
  84. package/dist/tools/battleTools.d.ts.map +1 -0
  85. package/dist/tools/battleTools.js +322 -0
  86. package/dist/tools/battleTools.js.map +1 -0
  87. package/dist/tools/catalogTools.d.ts +3 -0
  88. package/dist/tools/catalogTools.d.ts.map +1 -0
  89. package/dist/tools/catalogTools.js +134 -0
  90. package/dist/tools/catalogTools.js.map +1 -0
  91. package/dist/tools/classTools.d.ts +85 -0
  92. package/dist/tools/classTools.d.ts.map +1 -0
  93. package/dist/tools/classTools.js +279 -0
  94. package/dist/tools/classTools.js.map +1 -0
  95. package/dist/tools/commonEventTools.d.ts +32 -0
  96. package/dist/tools/commonEventTools.d.ts.map +1 -0
  97. package/dist/tools/commonEventTools.js +150 -0
  98. package/dist/tools/commonEventTools.js.map +1 -0
  99. package/dist/tools/eventCommandTools.d.ts +37 -0
  100. package/dist/tools/eventCommandTools.d.ts.map +1 -0
  101. package/dist/tools/eventCommandTools.js +893 -0
  102. package/dist/tools/eventCommandTools.js.map +1 -0
  103. package/dist/tools/eventPageTools.d.ts +112 -0
  104. package/dist/tools/eventPageTools.d.ts.map +1 -0
  105. package/dist/tools/eventPageTools.js +597 -0
  106. package/dist/tools/eventPageTools.js.map +1 -0
  107. package/dist/tools/itemTools.d.ts +82 -0
  108. package/dist/tools/itemTools.d.ts.map +1 -0
  109. package/dist/tools/itemTools.js +380 -0
  110. package/dist/tools/itemTools.js.map +1 -0
  111. package/dist/tools/listTools.d.ts +58 -0
  112. package/dist/tools/listTools.d.ts.map +1 -0
  113. package/dist/tools/listTools.js +99 -0
  114. package/dist/tools/listTools.js.map +1 -0
  115. package/dist/tools/mapTools.d.ts +270 -0
  116. package/dist/tools/mapTools.d.ts.map +1 -0
  117. package/dist/tools/mapTools.js +1066 -0
  118. package/dist/tools/mapTools.js.map +1 -0
  119. package/dist/tools/moveTools.d.ts +43 -0
  120. package/dist/tools/moveTools.d.ts.map +1 -0
  121. package/dist/tools/moveTools.js +240 -0
  122. package/dist/tools/moveTools.js.map +1 -0
  123. package/dist/tools/objectTools.d.ts +12 -0
  124. package/dist/tools/objectTools.d.ts.map +1 -0
  125. package/dist/tools/objectTools.js +221 -0
  126. package/dist/tools/objectTools.js.map +1 -0
  127. package/dist/tools/paintTools.d.ts +3 -0
  128. package/dist/tools/paintTools.d.ts.map +1 -0
  129. package/dist/tools/paintTools.js +134 -0
  130. package/dist/tools/paintTools.js.map +1 -0
  131. package/dist/tools/pluginScanTools.d.ts +22 -0
  132. package/dist/tools/pluginScanTools.d.ts.map +1 -0
  133. package/dist/tools/pluginScanTools.js +119 -0
  134. package/dist/tools/pluginScanTools.js.map +1 -0
  135. package/dist/tools/pluginTools.d.ts +11 -0
  136. package/dist/tools/pluginTools.d.ts.map +1 -0
  137. package/dist/tools/pluginTools.js +63 -0
  138. package/dist/tools/pluginTools.js.map +1 -0
  139. package/dist/tools/projectTools.d.ts +11 -0
  140. package/dist/tools/projectTools.d.ts.map +1 -0
  141. package/dist/tools/projectTools.js +74 -0
  142. package/dist/tools/projectTools.js.map +1 -0
  143. package/dist/tools/skillTools.d.ts +83 -0
  144. package/dist/tools/skillTools.d.ts.map +1 -0
  145. package/dist/tools/skillTools.js +369 -0
  146. package/dist/tools/skillTools.js.map +1 -0
  147. package/dist/tools/stateTools.d.ts +28 -0
  148. package/dist/tools/stateTools.d.ts.map +1 -0
  149. package/dist/tools/stateTools.js +161 -0
  150. package/dist/tools/stateTools.js.map +1 -0
  151. package/dist/tools/systemTools.d.ts +86 -0
  152. package/dist/tools/systemTools.d.ts.map +1 -0
  153. package/dist/tools/systemTools.js +342 -0
  154. package/dist/tools/systemTools.js.map +1 -0
  155. package/dist/tools/tileTools.d.ts +9 -0
  156. package/dist/tools/tileTools.d.ts.map +1 -0
  157. package/dist/tools/tileTools.js +34 -0
  158. package/dist/tools/tileTools.js.map +1 -0
  159. package/dist/tools/tileTransparency.d.ts +40 -0
  160. package/dist/tools/tileTransparency.d.ts.map +1 -0
  161. package/dist/tools/tileTransparency.js +156 -0
  162. package/dist/tools/tileTransparency.js.map +1 -0
  163. package/dist/tools/tilesetTools.d.ts +23 -0
  164. package/dist/tools/tilesetTools.d.ts.map +1 -0
  165. package/dist/tools/tilesetTools.js +209 -0
  166. package/dist/tools/tilesetTools.js.map +1 -0
  167. package/dist/tools/validationTools.d.ts +50 -0
  168. package/dist/tools/validationTools.d.ts.map +1 -0
  169. package/dist/tools/validationTools.js +229 -0
  170. package/dist/tools/validationTools.js.map +1 -0
  171. package/dist/utils/commit.d.ts +62 -0
  172. package/dist/utils/commit.d.ts.map +1 -0
  173. package/dist/utils/commit.js +119 -0
  174. package/dist/utils/commit.js.map +1 -0
  175. package/dist/utils/fileHandler.d.ts +49 -0
  176. package/dist/utils/fileHandler.d.ts.map +1 -0
  177. package/dist/utils/fileHandler.js +137 -0
  178. package/dist/utils/fileHandler.js.map +1 -0
  179. package/dist/utils/records.d.ts +8 -0
  180. package/dist/utils/records.d.ts.map +1 -0
  181. package/dist/utils/records.js +10 -0
  182. package/dist/utils/records.js.map +1 -0
  183. package/dist/utils/types.d.ts +465 -0
  184. package/dist/utils/types.d.ts.map +1 -0
  185. package/dist/utils/types.js +5 -0
  186. package/dist/utils/types.js.map +1 -0
  187. package/dist/validation/assets.d.ts +53 -0
  188. package/dist/validation/assets.d.ts.map +1 -0
  189. package/dist/validation/assets.js +198 -0
  190. package/dist/validation/assets.js.map +1 -0
  191. package/dist/validation/createRefs.d.ts +37 -0
  192. package/dist/validation/createRefs.d.ts.map +1 -0
  193. package/dist/validation/createRefs.js +89 -0
  194. package/dist/validation/createRefs.js.map +1 -0
  195. package/dist/validation/eventCommands.d.ts +70 -0
  196. package/dist/validation/eventCommands.d.ts.map +1 -0
  197. package/dist/validation/eventCommands.js +273 -0
  198. package/dist/validation/eventCommands.js.map +1 -0
  199. package/dist/validation/gate.d.ts +56 -0
  200. package/dist/validation/gate.d.ts.map +1 -0
  201. package/dist/validation/gate.js +50 -0
  202. package/dist/validation/gate.js.map +1 -0
  203. package/dist/validation/moveCommands.d.ts +31 -0
  204. package/dist/validation/moveCommands.d.ts.map +1 -0
  205. package/dist/validation/moveCommands.js +123 -0
  206. package/dist/validation/moveCommands.js.map +1 -0
  207. package/dist/validation/pluginCommands.d.ts +83 -0
  208. package/dist/validation/pluginCommands.d.ts.map +1 -0
  209. package/dist/validation/pluginCommands.js +134 -0
  210. package/dist/validation/pluginCommands.js.map +1 -0
  211. package/dist/validation/pluginManifest.d.ts +67 -0
  212. package/dist/validation/pluginManifest.d.ts.map +1 -0
  213. package/dist/validation/pluginManifest.js +199 -0
  214. package/dist/validation/pluginManifest.js.map +1 -0
  215. package/dist/validation/references.d.ts +57 -0
  216. package/dist/validation/references.d.ts.map +1 -0
  217. package/dist/validation/references.js +314 -0
  218. package/dist/validation/references.js.map +1 -0
  219. package/package.json +67 -0
package/dist/index.js ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { basename } from 'path';
5
+ import { readFileSync } from 'fs';
6
+ import { validateProjectPath } from './utils/fileHandler.js';
7
+ import { buildRegistry, schemaFor } from './registry.js';
8
+ import { commitStore } from './utils/commit.js';
9
+ import { allToolDefinitions } from './tools/allTools.js';
10
+ /**
11
+ * RPG Maker MZ MCP Server
12
+ *
13
+ * A Model Context Protocol server for reading and writing RPG Maker MZ project
14
+ * data. Tool schemas (Zod) and handlers live in each `tools/*` module and are
15
+ * registered here on a high-level `McpServer`, which validates incoming
16
+ * arguments against each tool's schema before its handler runs.
17
+ */
18
+ const PROJECT_PATH = process.env.RPGMAKER_PROJECT_PATH || '';
19
+ /**
20
+ * Advertised MCP server version, read from package.json so it tracks releases
21
+ * instead of drifting from a hardcoded string. Resolved relative to this module
22
+ * (dist/index.js → ../package.json). Falls back to '0.0.0' if unreadable.
23
+ */
24
+ function serverVersion() {
25
+ try {
26
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
27
+ return typeof pkg.version === 'string' ? pkg.version : '0.0.0';
28
+ }
29
+ catch {
30
+ return '0.0.0';
31
+ }
32
+ }
33
+ /**
34
+ * Run a tool. Mutating tools execute inside a commit context so that, when
35
+ * `dryRun` is requested, every write is intercepted and returned as a preview
36
+ * diff instead of being applied.
37
+ */
38
+ async function runTool(tool, ctx, args) {
39
+ if (!tool.mutates) {
40
+ return tool.handler(ctx, args);
41
+ }
42
+ const dryRun = args.dryRun === true;
43
+ const commitCtx = { dryRun, commits: [] };
44
+ const result = await commitStore.run(commitCtx, () => tool.handler(ctx, args));
45
+ if (!dryRun) {
46
+ return result;
47
+ }
48
+ return {
49
+ dryRun: true,
50
+ wouldChange: commitCtx.commits.map((commit) => ({
51
+ file: basename(commit.path),
52
+ changed: commit.changed,
53
+ ...(commit.deleted ? { deleted: true } : {}),
54
+ diff: commit.diff,
55
+ })),
56
+ // The handler's return value (e.g. `{ event, warnings }`) — surfaced so a
57
+ // dry-run preview shows validation warnings that would otherwise be
58
+ // discarded (the documented dry-run gap). Omitted when the handler returns
59
+ // nothing.
60
+ ...(result === undefined ? {} : { wouldReturn: result }),
61
+ };
62
+ }
63
+ function buildServer(initialProjectPath) {
64
+ const server = new McpServer({ name: 'rpgmaker-mz-server', version: serverVersion() });
65
+ // The project path is session state, not a constant: it starts from the env
66
+ // var and `set_project` may retarget it without a server restart.
67
+ let projectPath = initialProjectPath;
68
+ const setProjectPath = (path) => {
69
+ projectPath = path;
70
+ };
71
+ // Fail loudly on duplicate tool names before wiring anything up.
72
+ buildRegistry(allToolDefinitions);
73
+ for (const def of allToolDefinitions) {
74
+ server.registerTool(def.name, { description: def.description, inputSchema: schemaFor(def) }, async (args) => {
75
+ try {
76
+ if (def.requiresProject !== false) {
77
+ if (!projectPath) {
78
+ throw new Error('No project path set. Set RPGMAKER_PROJECT_PATH or call set_project.');
79
+ }
80
+ if (!(await validateProjectPath(projectPath))) {
81
+ throw new Error(`Invalid RPG Maker MZ project path: ${projectPath}`);
82
+ }
83
+ }
84
+ const result = await runTool(def, { projectPath, setProjectPath }, args);
85
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
86
+ }
87
+ catch (error) {
88
+ const message = error instanceof Error ? error.message : String(error);
89
+ return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
90
+ }
91
+ });
92
+ }
93
+ return server;
94
+ }
95
+ async function main() {
96
+ const server = buildServer(PROJECT_PATH);
97
+ const transport = new StdioServerTransport();
98
+ await server.connect(transport);
99
+ console.error('RPG Maker MZ MCP server running on stdio');
100
+ }
101
+ main().catch((error) => {
102
+ console.error('[MCP Fatal]', error);
103
+ process.exit(1);
104
+ });
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAA+B,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;GAOG;AAEH,MAAM,Y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context passed to every tool handler. Kept as an object (rather than a bare
4
+ * `projectPath` string) so cross-cutting state — e.g. a future dry-run flag or
5
+ * logger — can be threaded through without changing every handler signature.
6
+ */
7
+ export interface ToolContext {
8
+ projectPath: string;
9
+ /**
10
+ * Retarget the server at a different project directory for the rest of the
11
+ * session. Provided by the server entry point; only `set_project` calls it.
12
+ */
13
+ setProjectPath?: (path: string) => void;
14
+ }
15
+ /**
16
+ * A tool's input schema, expressed as a Zod "raw shape" (a map of argument name
17
+ * to Zod type). The MCP SDK's `registerTool` consumes this directly: it both
18
+ * advertises the JSON Schema to clients and validates incoming arguments before
19
+ * the handler runs, so handlers can trust their inputs.
20
+ */
21
+ export type InputShape = Record<string, z.ZodType>;
22
+ /**
23
+ * A single MCP tool: its schema (advertised to clients and used for validation)
24
+ * plus the handler that runs it. Each tool module owns its own definitions, so
25
+ * adding a tool means editing one file instead of a central schema list and a
26
+ * central dispatch switch.
27
+ */
28
+ export interface ToolDefinition {
29
+ name: string;
30
+ description: string;
31
+ inputSchema: InputShape;
32
+ handler: (ctx: ToolContext, args: Record<string, any>) => Promise<unknown>;
33
+ /**
34
+ * True for tools that write to the project. Such tools accept a `dryRun`
35
+ * argument (injected into their advertised schema at registration time) and
36
+ * are run inside a commit context so the write can be previewed instead of
37
+ * applied.
38
+ */
39
+ mutates?: boolean;
40
+ /**
41
+ * True for mutating tools whose validation can *refuse* a write: they check
42
+ * the would-be result before committing and throw on a structural problem
43
+ * rather than writing it and warning. Such tools accept a `force` argument
44
+ * (injected into their advertised schema at registration time) to override.
45
+ * Only set this where a handler actually gates on `args.force` — otherwise the
46
+ * advertised argument would do nothing.
47
+ */
48
+ forceable?: boolean;
49
+ /**
50
+ * False for the few tools that must run without a configured project path
51
+ * (`get_project`/`set_project` — the tools you'd use to diagnose or fix an
52
+ * unset path). Everything else defaults to true and is gated on a valid
53
+ * project path before its handler runs.
54
+ */
55
+ requiresProject?: boolean;
56
+ }
57
+ /**
58
+ * The shared `dryRun` argument advertised on every mutating tool. Injected into
59
+ * the tool's schema at registration so clients can discover it without each tool
60
+ * having to declare it.
61
+ */
62
+ export declare const DRY_RUN_SHAPE: {
63
+ readonly dryRun: z.ZodOptional<z.ZodBoolean>;
64
+ };
65
+ /**
66
+ * The shared `force` argument advertised on mutating tools that gate their write
67
+ * on validation. Injected the same way `dryRun` is, but only for `forceable`
68
+ * tools — advertising it on a tool that never refuses a write would be a lie.
69
+ */
70
+ export declare const FORCE_SHAPE: {
71
+ readonly force: z.ZodOptional<z.ZodBoolean>;
72
+ };
73
+ /**
74
+ * Resolve the Zod raw shape a tool should be registered with. Mutating tools get
75
+ * the shared `dryRun` argument folded in, and those that gate on validation also
76
+ * get `force`.
77
+ */
78
+ export declare function schemaFor(def: ToolDefinition): InputShape;
79
+ /** Index definitions by name, failing loudly on duplicates. */
80
+ export declare function buildRegistry(defs: ToolDefinition[]): Map<string, ToolDefinition>;
81
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa;;CAKhB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,WAAW;;CAOd,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU,CAOzD;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CASjF"}
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The shared `dryRun` argument advertised on every mutating tool. Injected into
4
+ * the tool's schema at registration so clients can discover it without each tool
5
+ * having to declare it.
6
+ */
7
+ export const DRY_RUN_SHAPE = {
8
+ dryRun: z
9
+ .boolean()
10
+ .optional()
11
+ .describe('Preview only: return a diff of what would change without writing to disk.'),
12
+ };
13
+ /**
14
+ * The shared `force` argument advertised on mutating tools that gate their write
15
+ * on validation. Injected the same way `dryRun` is, but only for `forceable`
16
+ * tools — advertising it on a tool that never refuses a write would be a lie.
17
+ */
18
+ export const FORCE_SHAPE = {
19
+ force: z
20
+ .boolean()
21
+ .optional()
22
+ .describe('Write even if validation finds structural problems (wrong parameter count, unterminated command list). Off by default: such a write is refused and nothing is written. Advisory warnings never block regardless.'),
23
+ };
24
+ /**
25
+ * Resolve the Zod raw shape a tool should be registered with. Mutating tools get
26
+ * the shared `dryRun` argument folded in, and those that gate on validation also
27
+ * get `force`.
28
+ */
29
+ export function schemaFor(def) {
30
+ if (!def.mutates)
31
+ return def.inputSchema;
32
+ return {
33
+ ...def.inputSchema,
34
+ ...DRY_RUN_SHAPE,
35
+ ...(def.forceable ? FORCE_SHAPE : {}),
36
+ };
37
+ }
38
+ /** Index definitions by name, failing loudly on duplicates. */
39
+ export function buildRegistry(defs) {
40
+ const registry = new Map();
41
+ for (const def of defs) {
42
+ if (registry.has(def.name)) {
43
+ throw new Error(`Duplicate tool definition: ${def.name}`);
44
+ }
45
+ registry.set(def.name, def);
46
+ }
47
+ return registry;
48
+ }
49
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4DxB;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,CAAC;SACN,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CAAC,2EAA2E,CAAC;CAChF,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,CAAC;SACL,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CACP,kNAAkN,CACnN;CACK,CAAC;AAEX;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAmB;IAC3C,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC,WAAW,CAAC;IACzC,OAAO;QACL,GAAG,GAAG,CAAC,WAAW;QAClB,GAAG,aAAa;QAChB,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,IAAsB;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IACnD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Autotile shape calculator — the deterministic geometry that turns "which of my
3
+ * 8 neighbours are the same autotile kind" into the correct 0–47 shape slot.
4
+ *
5
+ * RPG Maker autotiles (A1–A4) don't store a fixed graphic; the editor picks one
6
+ * of up to 48 shape variants per cell so borders, corners and interiors line up.
7
+ * The runtime never computes this (shapes are baked into the map by the editor),
8
+ * so we reconstruct the editor's logic here. This is a solved geometry problem
9
+ * and must never be left to model reasoning — it's pure and exhaustively tested,
10
+ * the same way {@link tileIndex} is.
11
+ *
12
+ * Method (from the RPG Maker MV/MZ autotile shape-solver spec + the engine's own
13
+ * FLOOR/WALL/WATERFALL_AUTOTILE_TABLE render tables in rmmz_core.js v1.7.0):
14
+ * 1. Normalise diagonals — a diagonal only "connects" if BOTH its adjacent
15
+ * edges also connect (an isolated diagonal can't round a corner).
16
+ * 2. Reduce each of the tile's 4 quarters to a canonical state (solid / inner
17
+ * corner / vertical edge / horizontal edge / outer corner) from its two
18
+ * edges + normalised diagonal.
19
+ * 3. Look the resulting (TL,TR,BL,BR) signature up in a signature→shape map
20
+ * derived from the engine's render tables (see test/autotile.test.ts, which
21
+ * re-derives these maps from the authoritative tables and asserts a match).
22
+ *
23
+ * Three geometries share this shape; see {@link autotileType}. Floor uses all 5
24
+ * quarter states (47 of 48 slots; slot 46 is unused — the isolated tile has its
25
+ * own dedicated slot 47). Wall uses 4 states (no inner corner, 16 slots).
26
+ * Waterfall tiles only left↔right (4 slots).
27
+ */
28
+ import { AutotileType } from './tileCodec.js';
29
+ /**
30
+ * Connectivity of a cell's 8 neighbours: `true` = the neighbour is the *same
31
+ * autotile kind* (see {@link isSameKindTile}), so it should tile seamlessly.
32
+ * Off-map / different-kind / empty neighbours are `false`.
33
+ */
34
+ export interface Neighbors {
35
+ n: boolean;
36
+ e: boolean;
37
+ s: boolean;
38
+ w: boolean;
39
+ ne: boolean;
40
+ se: boolean;
41
+ sw: boolean;
42
+ nw: boolean;
43
+ }
44
+ /** All-disconnected neighbours — the isolated-cell default. */
45
+ export declare const NO_NEIGHBORS: Neighbors;
46
+ /** The 0–47 shape for a FLOOR-type autotile given its neighbours. */
47
+ export declare function computeFloorShape(nb: Neighbors): number;
48
+ /** The 0–15 shape for a WALL-type autotile (roof / wall-side) given its neighbours. */
49
+ export declare function computeWallShape(nb: Neighbors): number;
50
+ /**
51
+ * The 0–3 shape for a WATERFALL-type autotile. Waterfalls flow vertically and
52
+ * only tile left↔right: shape = whether the same fall continues to each side
53
+ * (none 0, left 1, right 2, both 3). Derived from WATERFALL_AUTOTILE_TABLE.
54
+ */
55
+ export declare function computeWaterfallShape(nb: Neighbors): number;
56
+ /** Dispatch to the right shape calculator for an autotile geometry. */
57
+ export declare function computeAutotileShape(type: AutotileType, nb: Neighbors): number;
58
+ /**
59
+ * The finished tile id for an autotile cell: keep the base tile's kind, but swap
60
+ * in the shape its neighbours dictate. Non-autotile base ids are returned as-is
61
+ * (flat tiles have no shape to compute). This is what paint commands (3d) call
62
+ * per cell after gathering same-kind neighbours.
63
+ */
64
+ export declare function autotileIdFor(baseTileId: number, nb: Neighbors): number;
65
+ //# sourceMappingURL=autotile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autotile.d.ts","sourceRoot":"","sources":["../../src/tiles/autotile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,YAAY,EAAiD,MAAM,gBAAgB,CAAC;AAE7F;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,OAAO,CAAC;IACX,CAAC,EAAE,OAAO,CAAC;IACX,CAAC,EAAE,OAAO,CAAC;IACX,CAAC,EAAE,OAAO,CAAC;IACX,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;CACb;AAED,+DAA+D;AAC/D,eAAO,MAAM,YAAY,EAAE,SAS1B,CAAC;AA+HF,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAEvD;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAE3D;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,CAS9E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,CAKvE"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Autotile shape calculator — the deterministic geometry that turns "which of my
3
+ * 8 neighbours are the same autotile kind" into the correct 0–47 shape slot.
4
+ *
5
+ * RPG Maker autotiles (A1–A4) don't store a fixed graphic; the editor picks one
6
+ * of up to 48 shape variants per cell so borders, corners and interiors line up.
7
+ * The runtime never computes this (shapes are baked into the map by the editor),
8
+ * so we reconstruct the editor's logic here. This is a solved geometry problem
9
+ * and must never be left to model reasoning — it's pure and exhaustively tested,
10
+ * the same way {@link tileIndex} is.
11
+ *
12
+ * Method (from the RPG Maker MV/MZ autotile shape-solver spec + the engine's own
13
+ * FLOOR/WALL/WATERFALL_AUTOTILE_TABLE render tables in rmmz_core.js v1.7.0):
14
+ * 1. Normalise diagonals — a diagonal only "connects" if BOTH its adjacent
15
+ * edges also connect (an isolated diagonal can't round a corner).
16
+ * 2. Reduce each of the tile's 4 quarters to a canonical state (solid / inner
17
+ * corner / vertical edge / horizontal edge / outer corner) from its two
18
+ * edges + normalised diagonal.
19
+ * 3. Look the resulting (TL,TR,BL,BR) signature up in a signature→shape map
20
+ * derived from the engine's render tables (see test/autotile.test.ts, which
21
+ * re-derives these maps from the authoritative tables and asserts a match).
22
+ *
23
+ * Three geometries share this shape; see {@link autotileType}. Floor uses all 5
24
+ * quarter states (47 of 48 slots; slot 46 is unused — the isolated tile has its
25
+ * own dedicated slot 47). Wall uses 4 states (no inner corner, 16 slots).
26
+ * Waterfall tiles only left↔right (4 slots).
27
+ */
28
+ import { autotileType, getAutotileKind, makeAutotileId } from './tileCodec.js';
29
+ /** All-disconnected neighbours — the isolated-cell default. */
30
+ export const NO_NEIGHBORS = {
31
+ n: false,
32
+ e: false,
33
+ s: false,
34
+ w: false,
35
+ ne: false,
36
+ se: false,
37
+ sw: false,
38
+ nw: false,
39
+ };
40
+ /**
41
+ * Reduce one quarter to its canonical state. `v` = the quarter's vertical edge
42
+ * connected, `h` = its horizontal edge connected, `d` = its diagonal connected
43
+ * (already normalised — caller ANDs it with both edges). Wall geometry never
44
+ * passes `d=true`, so it never yields `inner`.
45
+ */
46
+ function quarterState(v, h, d) {
47
+ if (v && h && d)
48
+ return 'solid';
49
+ if (v && h)
50
+ return 'inner';
51
+ if (v)
52
+ return 'vedge';
53
+ if (h)
54
+ return 'hedge';
55
+ return 'outer';
56
+ }
57
+ /**
58
+ * Signature→shape map for FLOOR autotiles (A1 water/ground, A2, A4 wall tops).
59
+ * Key is `TL|TR|BL|BR` quarter states. Derived from FLOOR_AUTOTILE_TABLE; 47
60
+ * reachable signatures (slot 46 is unused, and the all-`outer` isolated cell
61
+ * maps to the dedicated slot 47).
62
+ */
63
+ const FLOOR_SHAPES = {
64
+ 'solid|solid|solid|solid': 0,
65
+ 'inner|solid|solid|solid': 1,
66
+ 'solid|inner|solid|solid': 2,
67
+ 'inner|inner|solid|solid': 3,
68
+ 'solid|solid|solid|inner': 4,
69
+ 'inner|solid|solid|inner': 5,
70
+ 'solid|inner|solid|inner': 6,
71
+ 'inner|inner|solid|inner': 7,
72
+ 'solid|solid|inner|solid': 8,
73
+ 'inner|solid|inner|solid': 9,
74
+ 'solid|inner|inner|solid': 10,
75
+ 'inner|inner|inner|solid': 11,
76
+ 'solid|solid|inner|inner': 12,
77
+ 'inner|solid|inner|inner': 13,
78
+ 'solid|inner|inner|inner': 14,
79
+ 'inner|inner|inner|inner': 15,
80
+ 'vedge|solid|vedge|solid': 16,
81
+ 'vedge|inner|vedge|solid': 17,
82
+ 'vedge|solid|vedge|inner': 18,
83
+ 'vedge|inner|vedge|inner': 19,
84
+ 'hedge|hedge|solid|solid': 20,
85
+ 'hedge|hedge|solid|inner': 21,
86
+ 'hedge|hedge|inner|solid': 22,
87
+ 'hedge|hedge|inner|inner': 23,
88
+ 'solid|vedge|solid|vedge': 24,
89
+ 'solid|vedge|inner|vedge': 25,
90
+ 'inner|vedge|solid|vedge': 26,
91
+ 'inner|vedge|inner|vedge': 27,
92
+ 'solid|solid|hedge|hedge': 28,
93
+ 'inner|solid|hedge|hedge': 29,
94
+ 'solid|inner|hedge|hedge': 30,
95
+ 'inner|inner|hedge|hedge': 31,
96
+ 'vedge|vedge|vedge|vedge': 32,
97
+ 'hedge|hedge|hedge|hedge': 33,
98
+ 'outer|hedge|vedge|solid': 34,
99
+ 'outer|hedge|vedge|inner': 35,
100
+ 'hedge|outer|solid|vedge': 36,
101
+ 'hedge|outer|inner|vedge': 37,
102
+ 'solid|vedge|hedge|outer': 38,
103
+ 'inner|vedge|hedge|outer': 39,
104
+ 'vedge|solid|outer|hedge': 40,
105
+ 'vedge|inner|outer|hedge': 41,
106
+ 'outer|outer|vedge|vedge': 42,
107
+ 'outer|hedge|outer|hedge': 43,
108
+ 'vedge|vedge|outer|outer': 44,
109
+ 'hedge|outer|hedge|outer': 45,
110
+ 'outer|outer|outer|outer': 47,
111
+ };
112
+ /**
113
+ * Signature→shape map for WALL autotiles (A3 roofs, A3/A4 wall sides). Only 4
114
+ * cardinal edges matter (no diagonals, no inner corner). Derived from
115
+ * WALL_AUTOTILE_TABLE; a clean 16-entry bijection.
116
+ */
117
+ const WALL_SHAPES = {
118
+ 'solid|solid|solid|solid': 0,
119
+ 'vedge|solid|vedge|solid': 1,
120
+ 'hedge|hedge|solid|solid': 2,
121
+ 'outer|hedge|vedge|solid': 3,
122
+ 'solid|vedge|solid|vedge': 4,
123
+ 'vedge|vedge|vedge|vedge': 5,
124
+ 'hedge|outer|solid|vedge': 6,
125
+ 'outer|outer|vedge|vedge': 7,
126
+ 'solid|solid|hedge|hedge': 8,
127
+ 'vedge|solid|outer|hedge': 9,
128
+ 'hedge|hedge|hedge|hedge': 10,
129
+ 'outer|hedge|outer|hedge': 11,
130
+ 'solid|vedge|hedge|outer': 12,
131
+ 'vedge|vedge|outer|outer': 13,
132
+ 'hedge|outer|hedge|outer': 14,
133
+ 'outer|outer|outer|outer': 15,
134
+ };
135
+ /** FLOOR signature from neighbours: diagonals normalised by both adjacent edges. */
136
+ function floorSignature(nb) {
137
+ const nw = nb.nw && nb.n && nb.w;
138
+ const ne = nb.ne && nb.n && nb.e;
139
+ const sw = nb.sw && nb.s && nb.w;
140
+ const se = nb.se && nb.s && nb.e;
141
+ return [
142
+ quarterState(nb.n, nb.w, nw), // TL
143
+ quarterState(nb.n, nb.e, ne), // TR
144
+ quarterState(nb.s, nb.w, sw), // BL
145
+ quarterState(nb.s, nb.e, se), // BR
146
+ ].join('|');
147
+ }
148
+ /**
149
+ * WALL signature: cardinal edges only, no diagonals and no inner corner. Passing
150
+ * `d = both edges` makes a both-edges quarter resolve to `solid` (walls never
151
+ * round a diagonal), so `inner` never appears — matching WALL_SHAPES' keys.
152
+ */
153
+ function wallSignature(nb) {
154
+ return [
155
+ quarterState(nb.n, nb.w, nb.n && nb.w),
156
+ quarterState(nb.n, nb.e, nb.n && nb.e),
157
+ quarterState(nb.s, nb.w, nb.s && nb.w),
158
+ quarterState(nb.s, nb.e, nb.s && nb.e),
159
+ ].join('|');
160
+ }
161
+ /** The 0–47 shape for a FLOOR-type autotile given its neighbours. */
162
+ export function computeFloorShape(nb) {
163
+ return FLOOR_SHAPES[floorSignature(nb)] ?? 0;
164
+ }
165
+ /** The 0–15 shape for a WALL-type autotile (roof / wall-side) given its neighbours. */
166
+ export function computeWallShape(nb) {
167
+ return WALL_SHAPES[wallSignature(nb)] ?? 0;
168
+ }
169
+ /**
170
+ * The 0–3 shape for a WATERFALL-type autotile. Waterfalls flow vertically and
171
+ * only tile left↔right: shape = whether the same fall continues to each side
172
+ * (none 0, left 1, right 2, both 3). Derived from WATERFALL_AUTOTILE_TABLE.
173
+ */
174
+ export function computeWaterfallShape(nb) {
175
+ return (nb.w ? 1 : 0) + (nb.e ? 2 : 0);
176
+ }
177
+ /** Dispatch to the right shape calculator for an autotile geometry. */
178
+ export function computeAutotileShape(type, nb) {
179
+ switch (type) {
180
+ case 'floor':
181
+ return computeFloorShape(nb);
182
+ case 'wall':
183
+ return computeWallShape(nb);
184
+ case 'waterfall':
185
+ return computeWaterfallShape(nb);
186
+ }
187
+ }
188
+ /**
189
+ * The finished tile id for an autotile cell: keep the base tile's kind, but swap
190
+ * in the shape its neighbours dictate. Non-autotile base ids are returned as-is
191
+ * (flat tiles have no shape to compute). This is what paint commands (3d) call
192
+ * per cell after gathering same-kind neighbours.
193
+ */
194
+ export function autotileIdFor(baseTileId, nb) {
195
+ const type = autotileType(baseTileId);
196
+ if (type === null)
197
+ return baseTileId;
198
+ const shape = computeAutotileShape(type, nb);
199
+ return makeAutotileId(getAutotileKind(baseTileId), shape);
200
+ }
201
+ //# sourceMappingURL=autotile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autotile.js","sourceRoot":"","sources":["../../src/tiles/autotile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAgB,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkB7F,+DAA+D;AA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AE,KAAK,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Semantic tile catalog for the default RPG Maker MZ **Dungeon** tileset
3
+ * sheets (Dungeon_A1, Dungeon_A2, Dungeon_A4, Dungeon_A5, Dungeon_B, Dungeon_C). Names are RPG
4
+ * Maker's own official English tile labels, taken verbatim from the tileset
5
+ * image .txt sidecars that ship in the new-project template
6
+ * (RPGMZ.app .../newdata/img/tilesets/*.txt) — so authoritative, not guessed.
7
+ * Keyed by sheet **filename**; each array is indexed by *local index within the
8
+ * sheet* (autotile kind for A1–A4, tile offset for the flat A5/B/C sheets).
9
+ * Resolution to a real tile id happens in index.ts, which uses the sheet’s
10
+ * *slot* in a project’s Tilesets.json (a slot, not the filename, fixes the id).
11
+ *
12
+ * Generated from the sidecars (see Session History); do not hand-edit — correct
13
+ * the source .txt or the generator instead.
14
+ */
15
+ export declare const DUNGEON_TILE_NAMES: Record<string, string[]>;
16
+ //# sourceMappingURL=dungeon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dungeon.d.ts","sourceRoot":"","sources":["../../../src/tiles/catalog/dungeon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CA6uBvD,CAAC"}