@mavonengine/cli 0.0.5 → 0.0.6

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 CHANGED
@@ -109,6 +109,12 @@ npx @mavonengine/cli install @acme/forest@^2 file:../my-plugin --yes
109
109
  - `prefabs`: the plugin prefabs the project uses. The editor adds a prefab here when you place it, and you can edit the list by hand. Only the assets of these prefabs (plus the plugin's shared assets) go into the release.
110
110
  - `options`: passed to the plugin as `ctx.options`.
111
111
 
112
+ Next to `plugins`, the file says what goes for the whole project:
113
+
114
+ - `appUrl`: where the game is, like `https://mygame.com`. Links that leave the game, such as those in mails, point there. Server plugins get it as `ctx.appUrl`. `MAVONENGINE_APP_URL` overrides it, for example per deployment.
115
+ - `appName`: the game's name, in mails and in the browser tab: `%MAVONENGINE_APP_NAME%` in the client's `index.html` becomes it, in dev and in the build (`MavonEngine` without one). Server plugins get it as `ctx.appName`.
116
+ - `database`, `auth`, `notifications`: which plugin to use when more than one of that kind is enabled.
117
+
112
118
  The client reloads when the plugins in `mavonengine.json` change. Restart the game server to load a new server plugin. Without an interactive terminal it only installs, unless `--yes` is given.
113
119
 
114
120
  | Option | Default | |
@@ -117,6 +123,23 @@ The client reloads when the plugins in `mavonengine.json` change. Restart the ga
117
123
  | `-y`, `--yes` | | Add plugins to `mavonengine.json` without asking |
118
124
  | `--no-register` | | Only install |
119
125
 
126
+ ## `mavonengine asset:publish`
127
+
128
+ Copies the files a plugin lets you change into your project, such as the mail plugin's layout:
129
+
130
+ ```sh
131
+ npx @mavonengine/cli asset:publish @mavonengine/mail
132
+ ```
133
+
134
+ They go to `resources/<package>/`, here `resources/@mavonengine/mail/layout.html`. The plugin uses your copy from then on, so change it there and commit it. Files you have already are kept, so publishing again after an update only adds the plugin's new files. `--force` replaces yours with the plugin's.
135
+
136
+ A plugin offers files with `"publish": "<directory>"` under `mavonengine` in its `package.json`, and finds your copy with `ctx.publishedFile('<file>')`.
137
+
138
+ | Option | Default | |
139
+ | --- | --- | --- |
140
+ | `--cwd <dir>` | current directory | Where to start looking for the project |
141
+ | `--force` | | Replace the files you have with the plugin's |
142
+
120
143
  ## `mavonengine build`
121
144
 
122
145
  Runs the project's `build` script, then lists what each plugin put into the release. Plugin assets are copied into the client's output under `plugins/<package>/`. Only the shared ones and those of the prefabs in `mavonengine.json` are copied. The client skips loading the others, so a release never requests a file it doesn't contain.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // package.json
4
- var version = "0.0.5";
4
+ var version = "0.0.6";
5
5
 
6
6
  // src/mcp/config.ts
7
7
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  DEFAULT_DOCS_URL,
4
4
  version
5
- } from "./chunk-WOOU36T7.js";
5
+ } from "./chunk-7UZYGMGO.js";
6
6
 
7
7
  // src/mcp/docs.ts
8
8
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  DocsClient,
4
4
  registerDocsTools
5
- } from "./chunk-WDETVETJ.js";
5
+ } from "./chunk-IIWBECVS.js";
6
6
  import {
7
7
  DEFAULT_DOCS_URL
8
- } from "./chunk-WOOU36T7.js";
8
+ } from "./chunk-7UZYGMGO.js";
9
9
  export {
10
10
  DEFAULT_DOCS_URL,
11
11
  DocsClient,
package/dist/index.js CHANGED
@@ -11,10 +11,10 @@ import {
11
11
  MCP_CONFIG_FILE,
12
12
  version,
13
13
  writeMcpConfig
14
- } from "./chunk-WOOU36T7.js";
14
+ } from "./chunk-7UZYGMGO.js";
15
15
 
16
16
  // src/index.ts
17
- import process11 from "process";
17
+ import process12 from "process";
18
18
 
19
19
  // src/commands/build.ts
20
20
  import { spawn as spawn4 } from "child_process";
@@ -99,6 +99,8 @@ function validateManifest(pkg, value) {
99
99
  if (runsOn(manifest.target, side) && typeof manifest[side] !== "string")
100
100
  throw new PluginConfigError(`${pkg}: "mavonengine.${side}" is required for target "${manifest.target}"`);
101
101
  }
102
+ if (manifest.publish !== void 0 && (typeof manifest.publish !== "string" || !manifest.publish))
103
+ throw new PluginConfigError(`${pkg}: "mavonengine.publish" must be a directory of the package`);
102
104
  return manifest;
103
105
  }
104
106
  function readPluginManifest(root, pkg) {
@@ -287,6 +289,16 @@ function tickSample(t) {
287
289
  maxCommandsPerTick: num(t.maxCommandsPerTick)
288
290
  };
289
291
  }
292
+ function queueSample(q) {
293
+ return {
294
+ timestamp: num(q.timestamp),
295
+ size: num(q.size),
296
+ running: num(q.running),
297
+ processed: num(q.processed),
298
+ retried: num(q.retried),
299
+ failed: num(q.failed)
300
+ };
301
+ }
290
302
  function accountFrom(value) {
291
303
  if (!isRecord(value) || typeof value.id !== "string" || !value.id)
292
304
  return null;
@@ -301,6 +313,7 @@ function normalizeSnapshot(raw) {
301
313
  const memory = section(s.memory);
302
314
  const physics = isRecord(s.physics) ? s.physics : null;
303
315
  const latency = isRecord(s.latencySimulation) ? s.latencySimulation : null;
316
+ const queue = isRecord(s.queue) ? s.queue : null;
304
317
  return {
305
318
  schemaVersion: num(s.schemaVersion, SUPPORTED_SCHEMA_VERSION),
306
319
  engineVersion: str(s.engineVersion, "unknown"),
@@ -357,7 +370,14 @@ function normalizeSnapshot(raw) {
357
370
  heapTotal: num(memory.heapTotal),
358
371
  external: num(memory.external)
359
372
  },
360
- latencySimulation: latency ? { fixedLatency: num(latency.fixedLatency), jitter: num(latency.jitter), packetLoss: num(latency.packetLoss) } : null
373
+ latencySimulation: latency ? { fixedLatency: num(latency.fixedLatency), jitter: num(latency.jitter), packetLoss: num(latency.packetLoss) } : null,
374
+ // Servers older than the queue have none
375
+ queue: queue ? {
376
+ driver: str(queue.driver, "unknown"),
377
+ working: queue.working !== false,
378
+ latest: isRecord(queue.latest) ? queueSample(queue.latest) : null,
379
+ history: arr(queue.history, queueSample)
380
+ } : null
361
381
  };
362
382
  }
363
383
  function normalizeLogs(raw) {
@@ -1019,6 +1039,8 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1019
1039
  const cpuHistory = [];
1020
1040
  const bandwidthHistory = [];
1021
1041
  const tickHistory = [];
1042
+ const queueHistory = [];
1043
+ let queued = 0;
1022
1044
  const logs = [];
1023
1045
  let previousPlayers = 0;
1024
1046
  const joinedAt = [];
@@ -1145,6 +1167,13 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1145
1167
  commandsPerSecond,
1146
1168
  maxCommandsPerTick: playerCount + Math.floor(random() * 3)
1147
1169
  });
1170
+ const dispatched = Math.round(playerCount * 0.3) + (step % 20 === 0 ? 25 : 0);
1171
+ const processed = Math.min(queued + dispatched, 4 + step % 3);
1172
+ const failed = processed > 0 && step % 13 === 0 ? 1 : 0;
1173
+ queued = queued + dispatched - processed;
1174
+ if (failed)
1175
+ log("error", "Job grant-reward failed all 3 tries: Error: reward service unavailable");
1176
+ push(queueHistory, { timestamp: now, size: queued, running: Math.min(queued, 1), processed: processed - failed, retried: step % 7 === 0 ? 1 : 0, failed });
1148
1177
  const average = (ms) => {
1149
1178
  const recent = cpuHistory.slice(-Math.max(1, Math.round(ms / sampleIntervalMs)));
1150
1179
  return Math.round(recent.reduce((acc, h) => acc + h.cpuPercentage, 0) / recent.length * 100) / 100;
@@ -1183,7 +1212,8 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1183
1212
  heapTotal: heapUsed + 3e7,
1184
1213
  external: 5e6
1185
1214
  },
1186
- latencySimulation: null
1215
+ latencySimulation: null,
1216
+ queue: { driver: "database", working: true, latest: queueHistory.at(-1), history: [...queueHistory] }
1187
1217
  };
1188
1218
  return snapshot;
1189
1219
  },
@@ -1782,12 +1812,22 @@ function waiting(ui, theme, state) {
1782
1812
  });
1783
1813
  }
1784
1814
  function wideLayout(ui, theme, state, snapshot, view, transparent) {
1785
- ui.grid({ columns: ["1fr", "1fr"], rows: [11, 11], size: 22 }, (grid) => {
1786
- grid.panel({ title: "CPU" }, (p) => cpuPanel(p, theme, snapshot));
1787
- grid.panel({ title: "Network" }, (p) => networkPanel(p, theme, snapshot));
1788
- grid.panel({ title: "Tick" }, (p) => tickPanel(p, theme, snapshot));
1789
- grid.panel({ title: "World" }, (p) => worldPanel(p, theme, snapshot));
1790
- });
1815
+ if (snapshot.queue) {
1816
+ ui.grid({ columns: ["1fr", "1fr", "1fr"], rows: [11, 11], size: 22 }, (grid) => {
1817
+ grid.panel({ title: "CPU" }, (p) => cpuPanel(p, theme, snapshot));
1818
+ grid.panel({ title: "Network" }, (p) => networkPanel(p, theme, snapshot));
1819
+ grid.panel({ title: "Tick" }, (p) => tickPanel(p, theme, snapshot));
1820
+ grid.panel({ title: queueTitle(snapshot.queue), colSpan: 2 }, (p) => queuePanel(p, theme, snapshot.queue));
1821
+ grid.panel({ title: "World" }, (p) => worldPanel(p, theme, snapshot));
1822
+ });
1823
+ } else {
1824
+ ui.grid({ columns: ["1fr", "1fr"], rows: [11, 11], size: 22 }, (grid) => {
1825
+ grid.panel({ title: "CPU" }, (p) => cpuPanel(p, theme, snapshot));
1826
+ grid.panel({ title: "Network" }, (p) => networkPanel(p, theme, snapshot));
1827
+ grid.panel({ title: "Tick" }, (p) => tickPanel(p, theme, snapshot));
1828
+ grid.panel({ title: "World" }, (p) => worldPanel(p, theme, snapshot));
1829
+ });
1830
+ }
1791
1831
  ui.row({ size: "1fr" }, (row) => {
1792
1832
  playersPanel(row, theme, snapshot, view, transparent);
1793
1833
  logsPanel(row, theme, state, view);
@@ -1797,6 +1837,8 @@ function narrowLayout(ui, theme, state, snapshot, view, transparent) {
1797
1837
  ui.panel({ title: "CPU", size: 9 }, (p) => cpuPanel(p, theme, snapshot));
1798
1838
  ui.panel({ title: "Network", size: 9 }, (p) => networkPanel(p, theme, snapshot));
1799
1839
  ui.panel({ title: "Tick", size: 9 }, (p) => tickPanel(p, theme, snapshot));
1840
+ if (snapshot.queue)
1841
+ ui.panel({ title: queueTitle(snapshot.queue), size: 9 }, (p) => queuePanel(p, theme, snapshot.queue));
1800
1842
  ui.panel({ title: "World", size: 11 }, (p) => worldPanel(p, theme, snapshot));
1801
1843
  playersPanel(ui, theme, snapshot, view, transparent);
1802
1844
  logsPanel(ui, theme, state, view);
@@ -1864,6 +1906,38 @@ function tickPanel(ui, theme, { tick, tickRate }) {
1864
1906
  { label: "Commands/s", value: `${latest?.commandsPerSecond ?? 0} (max ${latest?.maxCommandsPerTick ?? 0}/tick)` }
1865
1907
  ], { spread: true });
1866
1908
  }
1909
+ function queueTitle(queue) {
1910
+ return `Queue (${queue.driver}${queue.working ? "" : ", not worked here"})`;
1911
+ }
1912
+ function queueTotals(queue) {
1913
+ return queue.history.reduce((sum, s) => ({ processed: sum.processed + s.processed, failed: sum.failed + s.failed, retried: sum.retried + s.retried }), { processed: 0, failed: 0, retried: 0 });
1914
+ }
1915
+ function queuePanel(ui, theme, queue) {
1916
+ const latest = queue.latest;
1917
+ const totals = queueTotals(queue);
1918
+ const seconds = Math.round(queue.history.length > 1 ? (queue.history.at(-1).timestamp - queue.history[0].timestamp) / 1e3 : 0);
1919
+ const window = seconds >= 60 ? `${Math.round(seconds / 60)}m` : `${seconds}s`;
1920
+ ui.multiGraph([
1921
+ { label: "queued", values: queue.history.map((s) => s.size), color: theme.graph[0] },
1922
+ { label: "processed", values: queue.history.map((s) => s.processed), color: theme.graph[1] },
1923
+ { label: "failed", values: queue.history.map((s) => s.failed), color: theme.danger }
1924
+ ], {
1925
+ min: 0,
1926
+ max: Math.max(4, ...queue.history.map((s) => Math.max(s.size, s.processed, s.failed))),
1927
+ axis: true,
1928
+ axisFormat: (v) => String(Math.round(v)),
1929
+ legend: true,
1930
+ legendAlign: "right",
1931
+ size: "1fr"
1932
+ });
1933
+ ui.keyValues([
1934
+ { label: "Queued", value: String(latest?.size ?? 0), color: theme.graph[0] },
1935
+ { label: "Running", value: String(latest?.running ?? 0) },
1936
+ { label: `Processed ${window}`, value: String(totals.processed), color: theme.graph[1] },
1937
+ { label: `Retried ${window}`, value: String(totals.retried), color: totals.retried ? theme.warning : void 0 },
1938
+ { label: `Failed ${window}`, value: String(totals.failed), color: totals.failed ? theme.danger : void 0 }
1939
+ ], { spread: true });
1940
+ }
1867
1941
  function worldPanel(ui, theme, { players, world, physics, memory }) {
1868
1942
  ui.keyValues([
1869
1943
  { label: "Players", value: String(players.length), color: theme.primary },
@@ -2855,9 +2929,15 @@ import process4 from "process";
2855
2929
  import { Readable, Transform } from "stream";
2856
2930
  import { pipeline } from "stream/promises";
2857
2931
  import AdmZip from "adm-zip";
2858
- var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.19-alpha.zip";
2932
+ var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.20-alpha.zip";
2859
2933
  var TEMPLATE_SUBPATH = "packages/multiplayer-template";
2860
2934
  var PROJECT_NAME_RE = /^[\w@./-][\w@./\- ]*$/;
2935
+ var NAME_SEPARATORS_RE = /[-_\s]+/;
2936
+ var PATH_SEPARATORS_RE = /[\\/]/;
2937
+ function appNameFor(projectName) {
2938
+ const words = projectName.split(PATH_SEPARATORS_RE).at(-1).split(NAME_SEPARATORS_RE).filter(Boolean);
2939
+ return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ") || projectName;
2940
+ }
2861
2941
  function projectDirFor(projectName, parentDir) {
2862
2942
  return resolve2(parentDir, projectName);
2863
2943
  }
@@ -2960,6 +3040,12 @@ async function createProject({ projectName, parentDir, report, signal, templateU
2960
3040
  writeFileSync2(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}
2961
3041
  `);
2962
3042
  }
3043
+ updateConfig(projectDir, (config) => {
3044
+ if (typeof config.appName === "string" && config.appName.trim())
3045
+ return false;
3046
+ config.appName = appNameFor(projectName);
3047
+ return true;
3048
+ });
2963
3049
  if (writeMcpConfig(projectDir))
2964
3050
  report.output(`Wrote ${MCP_CONFIG_FILE} so AI assistants with MCP support can inspect the running game server
2965
3051
  `);
@@ -3215,7 +3301,7 @@ var PluginInstaller = class {
3215
3301
  // src/dev/control.ts
3216
3302
  var MAX_BODY_BYTES = 8192;
3217
3303
  function readBody(req) {
3218
- return new Promise((resolve7, reject) => {
3304
+ return new Promise((resolve8, reject) => {
3219
3305
  let body = "";
3220
3306
  req.setEncoding("utf8");
3221
3307
  req.on("data", (chunk) => {
@@ -3225,7 +3311,7 @@ function readBody(req) {
3225
3311
  req.destroy();
3226
3312
  }
3227
3313
  });
3228
- req.on("end", () => resolve7(body));
3314
+ req.on("end", () => resolve8(body));
3229
3315
  req.on("error", reject);
3230
3316
  });
3231
3317
  }
@@ -3277,11 +3363,11 @@ function startDevControl(installer) {
3277
3363
  res.end(JSON.stringify({ error: err.message }));
3278
3364
  });
3279
3365
  });
3280
- return new Promise((resolve7, reject) => {
3366
+ return new Promise((resolve8, reject) => {
3281
3367
  server.once("error", reject);
3282
3368
  server.listen(0, "127.0.0.1", () => {
3283
3369
  const url = `http://127.0.0.1:${server.address().port}`;
3284
- resolve7({
3370
+ resolve8({
3285
3371
  url,
3286
3372
  token,
3287
3373
  env: { [DEV_CONTROL_URL_ENV]: url, [DEV_CONTROL_TOKEN_ENV]: token },
@@ -3530,7 +3616,7 @@ function startDevSession(root, options = {}) {
3530
3616
  let dev = startDev(root, options);
3531
3617
  let restarting = false;
3532
3618
  let settle;
3533
- const exited = new Promise((resolve7, reject) => settle = { resolve: resolve7, reject });
3619
+ const exited = new Promise((resolve8, reject) => settle = { resolve: resolve8, reject });
3534
3620
  const watch = (current) => {
3535
3621
  current.exited.then((code) => {
3536
3622
  if (current === dev && !restarting)
@@ -4073,15 +4159,15 @@ function parseMcpArgs(args, env = process9.env) {
4073
4159
  async function runMcpCommand({ client, docsUrl, pluginsUrl }) {
4074
4160
  const [{ StdioServerTransport }, { createMcpServer }, { DocsClient }] = await Promise.all([
4075
4161
  import("@modelcontextprotocol/sdk/server/stdio.js"),
4076
- import("./server-GC2XXFIG.js"),
4077
- import("./docs-WADOFPOK.js")
4162
+ import("./server-AC5LBJ6A.js"),
4163
+ import("./docs-S2SWFUIL.js")
4078
4164
  ]);
4079
4165
  const docs = docsUrl ? new DocsClient(docsUrl) : void 0;
4080
4166
  const server = createMcpServer(client, docs, pluginsUrl ? { url: pluginsUrl } : void 0);
4081
4167
  const transport = new StdioServerTransport();
4082
- const closed = new Promise((resolve7) => {
4083
- transport.onclose = resolve7;
4084
- process9.stdin.on("end", resolve7);
4168
+ const closed = new Promise((resolve8) => {
4169
+ transport.onclose = resolve8;
4170
+ process9.stdin.on("end", resolve8);
4085
4171
  });
4086
4172
  await server.connect(transport);
4087
4173
  process9.stderr.write(`mavonengine mcp: reading the game server at ${client.url}
@@ -4185,17 +4271,152 @@ async function runPluginsCommand(options, io = { write: (text) => process10.stdo
4185
4271
  return 0;
4186
4272
  }
4187
4273
 
4274
+ // src/commands/publish.ts
4275
+ import { relative as relative4, resolve as resolve7 } from "path";
4276
+ import process11 from "process";
4277
+ import { parseArgs as parseArgs8 } from "util";
4278
+
4279
+ // ../core/dist/Plugins/publish.js
4280
+ import { copyFileSync, existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync as readdirSync2, statSync } from "fs";
4281
+ import { dirname as dirname4, join as join6, relative as relative3, sep } from "path";
4282
+ var PUBLISHED_DIR = "resources";
4283
+ function publishedDir(root, pkg) {
4284
+ return join6(root, PUBLISHED_DIR, ...pkg.split("/"));
4285
+ }
4286
+ function publishSourceDir(plugin) {
4287
+ const dir = plugin.manifest.publish;
4288
+ if (dir === void 0)
4289
+ return void 0;
4290
+ const full = resolveInside(plugin.dir, dir);
4291
+ if (!full)
4292
+ throw new PluginConfigError(`${plugin.package}: "mavonengine.publish" must be inside the package`);
4293
+ return full;
4294
+ }
4295
+ function filesIn(dir) {
4296
+ const files = [];
4297
+ for (const entry of readdirSync2(dir, { withFileTypes: true })) {
4298
+ const path = join6(dir, entry.name);
4299
+ if (entry.isDirectory())
4300
+ files.push(...filesIn(path));
4301
+ else if (entry.isFile())
4302
+ files.push(path);
4303
+ }
4304
+ return files.sort();
4305
+ }
4306
+ function publishFiles(root, plugin, { force = false } = {}) {
4307
+ const source = publishSourceDir(plugin);
4308
+ if (!source)
4309
+ throw new PluginConfigError(`${plugin.package} has no files to publish`);
4310
+ if (!existsSync7(source) || !statSync(source).isDirectory())
4311
+ throw new PluginConfigError(`${plugin.package}: its publish directory ${relative3(plugin.dir, source)} is missing`);
4312
+ const target = publishedDir(root, plugin.package);
4313
+ return filesIn(source).map((from) => {
4314
+ const path = relative3(source, from).split(sep).join("/");
4315
+ const to = join6(target, ...path.split("/"));
4316
+ const existed = existsSync7(to);
4317
+ if (existed && !force)
4318
+ return { path, to, status: "kept" };
4319
+ mkdirSync2(dirname4(to), { recursive: true });
4320
+ copyFileSync(from, to);
4321
+ return { path, to, status: existed ? "replaced" : "published" };
4322
+ });
4323
+ }
4324
+
4325
+ // src/commands/publish.ts
4326
+ var PUBLISH_HELP = `Usage: mavonengine asset:publish <package...> [options]
4327
+
4328
+ Copy the files a plugin lets you change, like the mail plugin's layout, into the project's
4329
+ ${PUBLISHED_DIR}/<package>/. The plugin uses your copy from then on, so change it there.
4330
+
4331
+ Files you have already are kept, so publishing again only adds the plugin's new files.
4332
+
4333
+ Options:
4334
+ --force Replace the files you have with the plugin's
4335
+ --cwd <dir> Start looking for the project here (default: current directory)
4336
+ -h, --help Show this help
4337
+ `;
4338
+ function parsePublishArgs(args, cwd = process11.cwd()) {
4339
+ const { values, positionals } = parseArgs8({
4340
+ args,
4341
+ options: {
4342
+ force: { type: "boolean", default: false },
4343
+ cwd: { type: "string" },
4344
+ help: { type: "boolean", short: "h", default: false }
4345
+ },
4346
+ strict: true,
4347
+ allowPositionals: true
4348
+ });
4349
+ if (values.help)
4350
+ return "help";
4351
+ if (positionals.length === 0)
4352
+ throw new UsageError(`name the plugin to publish, e.g. mavonengine asset:publish @mavonengine/mail
4353
+
4354
+ ${PUBLISH_HELP}`);
4355
+ return { cwd: resolve7(cwd, values.cwd ?? "."), packages: positionals, force: values.force };
4356
+ }
4357
+ async function runPublishCommand(options, io = { write: (text) => void process11.stdout.write(text) }) {
4358
+ const root = findProjectRoot(options.cwd);
4359
+ if (!root) {
4360
+ io.write(`No MavonEngine project found from ${options.cwd}. Run this inside one.
4361
+ `);
4362
+ return 1;
4363
+ }
4364
+ let failed = false;
4365
+ for (const pkg of options.packages) {
4366
+ const plugin = (() => {
4367
+ try {
4368
+ return readPluginManifest(root, pkg);
4369
+ } catch (err) {
4370
+ io.write(`${pkg}: ${err.message}
4371
+ `);
4372
+ return null;
4373
+ }
4374
+ })();
4375
+ if (plugin === null) {
4376
+ failed = true;
4377
+ continue;
4378
+ }
4379
+ if (!plugin) {
4380
+ io.write(`${pkg} isn't installed, or is no MavonEngine plugin. Install it with: mavonengine install ${pkg}
4381
+ `);
4382
+ failed = true;
4383
+ continue;
4384
+ }
4385
+ try {
4386
+ const files = publishFiles(root, plugin, { force: options.force });
4387
+ io.write(`${pkg}:
4388
+ `);
4389
+ for (const file of files) {
4390
+ const shown = relative4(root, file.to).split("\\").join("/");
4391
+ io.write(file.status === "kept" ? ` kept ${shown} (you have it already, --force replaces it)
4392
+ ` : ` ${file.status.padEnd(10)} ${shown}
4393
+ `);
4394
+ }
4395
+ if (files.length === 0)
4396
+ io.write(" nothing to publish\n");
4397
+ } catch (err) {
4398
+ if (!(err instanceof PluginConfigError))
4399
+ throw err;
4400
+ io.write(`${err.message}
4401
+ `);
4402
+ failed = true;
4403
+ }
4404
+ }
4405
+ return failed ? 1 : 0;
4406
+ }
4407
+
4188
4408
  // src/index.ts
4189
4409
  var HELP = `Usage: mavonengine <command> [options]
4190
4410
 
4191
4411
  Commands:
4192
- create Create a project from the multiplayer template and start it
4193
- dashboard Live terminal dashboard for a running game server
4194
- dev Run the project's dev servers (game server and client)
4195
- install Install packages and register engine plugins in mavonengine.json
4196
- plugins List the plugins that are available to install
4197
- build Build the project for release, with the plugin assets it uses
4198
- mcp MCP server so AI assistants (any MCP client) can inspect a running game server
4412
+ create Create a project from the multiplayer template and start it
4413
+ dashboard Live terminal dashboard for a running game server
4414
+ dev Run the project's dev servers (game server and client)
4415
+ install Install packages and register engine plugins in mavonengine.json
4416
+ plugins List the plugins that are available to install
4417
+ asset:publish Copy a plugin's files you may change, like the mail layout, into the project
4418
+ build Build the project for release, with the plugin assets it uses
4419
+ mcp MCP server so AI assistants (any MCP client) can inspect a running game server
4199
4420
 
4200
4421
  Options:
4201
4422
  -h, --help Show help
@@ -4206,18 +4427,18 @@ Run 'mavonengine <command> --help' for command options.
4206
4427
  async function main(argv) {
4207
4428
  const [command, ...args] = argv;
4208
4429
  if (!command || command === "-h" || command === "--help" || command === "help") {
4209
- process11.stdout.write(HELP);
4430
+ process12.stdout.write(HELP);
4210
4431
  return 0;
4211
4432
  }
4212
4433
  if (command === "-v" || command === "--version") {
4213
- process11.stdout.write(`${version}
4434
+ process12.stdout.write(`${version}
4214
4435
  `);
4215
4436
  return 0;
4216
4437
  }
4217
4438
  if (command === "create") {
4218
4439
  const options = parseCreateArgs(args);
4219
4440
  if (options === "help") {
4220
- process11.stdout.write(CREATE_HELP);
4441
+ process12.stdout.write(CREATE_HELP);
4221
4442
  return 0;
4222
4443
  }
4223
4444
  return runCreateCommand(options);
@@ -4225,11 +4446,11 @@ async function main(argv) {
4225
4446
  if (command === "dashboard") {
4226
4447
  const options = parseDashboardArgs(args);
4227
4448
  if (options === "help") {
4228
- process11.stdout.write(DASHBOARD_HELP);
4449
+ process12.stdout.write(DASHBOARD_HELP);
4229
4450
  return 0;
4230
4451
  }
4231
- if (!process11.stdout.isTTY || !process11.stdin.isTTY) {
4232
- process11.stderr.write("mavonengine dashboard needs an interactive terminal\n");
4452
+ if (!process12.stdout.isTTY || !process12.stdin.isTTY) {
4453
+ process12.stderr.write("mavonengine dashboard needs an interactive terminal\n");
4233
4454
  return 1;
4234
4455
  }
4235
4456
  await runDashboard(options);
@@ -4238,7 +4459,7 @@ async function main(argv) {
4238
4459
  if (command === "dev") {
4239
4460
  const options = parseDevArgs(args);
4240
4461
  if (options === "help") {
4241
- process11.stdout.write(DEV_HELP);
4462
+ process12.stdout.write(DEV_HELP);
4242
4463
  return 0;
4243
4464
  }
4244
4465
  return runDevCommand(options);
@@ -4246,7 +4467,7 @@ async function main(argv) {
4246
4467
  if (command === "install" || command === "i" || command === "add") {
4247
4468
  const options = parseInstallArgs(args);
4248
4469
  if (options === "help") {
4249
- process11.stdout.write(INSTALL_HELP);
4470
+ process12.stdout.write(INSTALL_HELP);
4250
4471
  return 0;
4251
4472
  }
4252
4473
  return runInstallCommand(options);
@@ -4254,15 +4475,23 @@ async function main(argv) {
4254
4475
  if (command === "plugins") {
4255
4476
  const options = parsePluginsArgs(args);
4256
4477
  if (options === "help") {
4257
- process11.stdout.write(PLUGINS_HELP);
4478
+ process12.stdout.write(PLUGINS_HELP);
4258
4479
  return 0;
4259
4480
  }
4260
4481
  return runPluginsCommand(options);
4261
4482
  }
4483
+ if (command === "asset:publish") {
4484
+ const options = parsePublishArgs(args);
4485
+ if (options === "help") {
4486
+ process12.stdout.write(PUBLISH_HELP);
4487
+ return 0;
4488
+ }
4489
+ return runPublishCommand(options);
4490
+ }
4262
4491
  if (command === "mcp") {
4263
4492
  const options = parseMcpArgs(args);
4264
4493
  if (options === "help") {
4265
- process11.stdout.write(MCP_HELP);
4494
+ process12.stdout.write(MCP_HELP);
4266
4495
  return 0;
4267
4496
  }
4268
4497
  return runMcpCommand(options);
@@ -4270,7 +4499,7 @@ async function main(argv) {
4270
4499
  if (command === "build") {
4271
4500
  const options = parseBuildArgs(args);
4272
4501
  if (options === "help") {
4273
- process11.stdout.write(BUILD_HELP);
4502
+ process12.stdout.write(BUILD_HELP);
4274
4503
  return 0;
4275
4504
  }
4276
4505
  return runBuildCommand(options);
@@ -4279,9 +4508,9 @@ async function main(argv) {
4279
4508
 
4280
4509
  ${HELP}`);
4281
4510
  }
4282
- main(process11.argv.slice(2)).then((code) => process11.exit(code)).catch((err) => {
4511
+ main(process12.argv.slice(2)).then((code) => process12.exit(code)).catch((err) => {
4283
4512
  const isUsage = err instanceof UsageError || err.code?.startsWith("ERR_PARSE_ARGS");
4284
- process11.stderr.write(`mavonengine: ${err.message}
4513
+ process12.stderr.write(`mavonengine: ${err.message}
4285
4514
  `);
4286
- process11.exit(isUsage ? 2 : 1);
4515
+ process12.exit(isUsage ? 2 : 1);
4287
4516
  });
@@ -9,10 +9,10 @@ import {
9
9
  registerDocsTools,
10
10
  run,
11
11
  vec3
12
- } from "./chunk-WDETVETJ.js";
12
+ } from "./chunk-IIWBECVS.js";
13
13
  import {
14
14
  version
15
- } from "./chunk-WOOU36T7.js";
15
+ } from "./chunk-7UZYGMGO.js";
16
16
 
17
17
  // src/mcp/server.ts
18
18
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mavonengine/cli",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "description": "MavonEngine command line tools",
6
6
  "license": "MIT",
7
7
  "keywords": [