@mavonengine/cli 0.0.8 → 0.0.9

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
@@ -380,7 +380,7 @@ Client tools, for the game tabs open while Vite serves the client in dev:
380
380
  | `network_timeline` | The server's records for one tab and the tab's own, merged by time |
381
381
  | `client_logs` | Console output, uncaught errors and unhandled rejections, filtered by level and text |
382
382
  | `client_screenshot` | What the tab renders, as an image (the WebGL canvas, without HTML UI) |
383
- | `client_trace` | Records a few seconds of the tab and analyses it: frame times, render CPU vs GPU, composer passes, ticks, WebGL work per frame, the bottleneck, and the worst hitches with their causes. Saves a flame chart trace file |
383
+ | `client_trace` | Records a few seconds of the tab and analyses it: frame times, render CPU vs GPU, the render pipeline and its effects, ticks, WebGL work per frame, the bottleneck, and the worst hitches with their causes. Saves a flame chart trace file |
384
384
  | `compare_entity` | One entity on the server next to a tab's copy: position / rotation / scale deltas and differing fields |
385
385
 
386
386
  Plugin tools:
@@ -427,7 +427,7 @@ The server scene and entity tools read `GET /api/game/dev/*` on the game server.
427
427
 
428
428
  The client tools go through the dev bridge of the Vite plugin in `@mavonengine/core/vite.config` (Vite 8). In dev it adds a small module to the page that answers over Vite's hot-reload WebSocket, and serves `GET /__mavonengine/clients` to localhost, or with `MAVONENGINE_METRICS_TOKEN` as bearer token when that is set for the dev server. Builds never include it. Turn it off with `mavonEnginePlugins({ devBridge: false })`.
429
429
 
430
- `client_trace` patches the tab only while it records and puts everything back afterwards. It times every frame and composer pass, counts the WebGL calls on the context, keeps slow single calls (shader compiles, texture uploads, `readPixels` / `getError` stalls), long animation frames with the scripts that ran, and your own `performance.measure()` spans. GPU time per frame needs `EXT_disjoint_timer_query_webgl2` (Chrome and Edge on most GPUs; the three-perf panel pauses while tracing since it uses the same queries). JS call stacks come from the [JS Self-Profiling API](https://wicg.github.io/js-self-profiling/) in Chromium browsers: the Vite plugin serves dev pages with `Document-Policy: js-profiling` for it, so reload tabs opened before you updated. The trace file is [Chrome Trace Event](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU) JSON with tracks for frames, passes, GPU time, ticks, JS samples and slow WebGL calls: open it in [Perfetto](https://ui.perfetto.dev), `chrome://tracing` or [speedscope](https://www.speedscope.app). Keep the tab in the foreground while it records, browsers throttle hidden tabs.
430
+ `client_trace` patches the tab only while it records and puts everything back afterwards. It times every frame and the render pipeline, counts the WebGL calls on the context (so it needs the WebGL 2 backend, the default), keeps slow single calls (shader compiles, texture uploads, `readPixels` / `getError` stalls), long animation frames with the scripts that ran, and your own `performance.measure()` spans. GPU time per frame needs `EXT_disjoint_timer_query_webgl2` (Chrome and Edge on most GPUs; the inspector's GPU timing pauses while tracing since it uses the same queries). JS call stacks come from the [JS Self-Profiling API](https://wicg.github.io/js-self-profiling/) in Chromium browsers: the Vite plugin serves dev pages with `Document-Policy: js-profiling` for it, so reload tabs opened before you updated. The trace file is [Chrome Trace Event](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU) JSON with tracks for frames, passes, GPU time, ticks, JS samples and slow WebGL calls: open it in [Perfetto](https://ui.perfetto.dev), `chrome://tracing` or [speedscope](https://www.speedscope.app). Keep the tab in the foreground while it records, browsers throttle hidden tabs.
431
431
 
432
432
  The network tools read what both sides record while developing: every message through the game socket, the engine's and your own, with its size, and events such as `connect`, `disconnect`, `dropped` (the transport dropped a message), `sync_enter` / `sync_leave` (entities coming into or leaving a player's sync distance) and, on a client, `state_gap` (state updates that never arrived) and `state_out_of_order`. Each side keeps its last 2000 records, and 8 MB of their payloads. The server records when `NODE_ENV` is not `production` and serves them on `GET /api/game/dev/net/packets`, `/packets/:id` and `/sync`; a tab records while the dev bridge or the editor runs. Nothing is recorded, and the socket is left untouched, in a production build. `network_timeline` orders the two sides by their own clocks, which line up on one machine.
433
433
 
@@ -512,6 +512,41 @@ export default defineServerPlugin({
512
512
 
513
513
  A hook that throws is logged and turned off for that plugin, and the game keeps running.
514
514
 
515
+ ### Graphs and nodes
516
+
517
+ A plugin can ship material and logic graphs: put `<name>.graph.json` files (made in the editor's Graphs view, then copied over) in a `graphs/` directory in the package. They go by `<package>:<name>`, e.g. `my-custom-plugin:ocean`, wherever a graph is picked: a primitive's material graph, a Logic Graph object's graph. They are served at `/graphs/<package>/<name>.graph.json`, shipped in every release, and the server reads them from the package. The editor lists them under the project's graphs, read-only: *Copy to project* makes an editable copy.
518
+
519
+ It can also add node types, from `setup`. Their key in graph files is `<package>:<type>`, which `registerNode` returns. Material nodes take their TSL implementation as a second argument; logic nodes need registering in the server entry too, for graphs that run there:
520
+
521
+ ```ts
522
+ // client.ts
523
+ import { defineClientPlugin } from '@mavonengine/core/Plugins/types'
524
+ import { sin, time } from 'three/tsl'
525
+
526
+ export default defineClientPlugin({
527
+ setup(ctx) {
528
+ ctx.registerNode({
529
+ type: 'wobble',
530
+ label: 'Wobble',
531
+ category: 'Math',
532
+ kinds: ['material', 'logic'],
533
+ inputs: {
534
+ speed: { type: 'float', default: 1 }
535
+ },
536
+ outputs: {
537
+ value: { type: 'float' }
538
+ },
539
+ // In logic graphs
540
+ eval: ({ speed }, { time }) => ({
541
+ value: Math.sin(time * Number(speed))
542
+ }),
543
+ }, ({ speed }) => ({
544
+ value: sin(time.mul(speed))
545
+ }))
546
+ },
547
+ })
548
+ ```
549
+
515
550
  ### Dev entries
516
551
 
517
552
  A plugin's `dev` entry runs in the client's Vite dev server, only in dev: tooling for the editor that has to work with the project's files, like downloading something and writing it into `client/public/`. It is never part of a build, and the game server never loads it.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // package.json
4
- var version = "0.0.8";
4
+ var version = "0.0.9";
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-33OMMYNV.js";
5
+ } from "./chunk-KNBPVBMA.js";
6
6
  import {
7
7
  READ_ONLY
8
8
  } from "./chunk-WMXVMJDM.js";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  DocsClient,
4
4
  registerDocsTools
5
- } from "./chunk-HRMANFDB.js";
5
+ } from "./chunk-UD5YAJCQ.js";
6
6
  import {
7
7
  DEFAULT_DOCS_URL
8
- } from "./chunk-33OMMYNV.js";
8
+ } from "./chunk-KNBPVBMA.js";
9
9
  import "./chunk-WMXVMJDM.js";
10
10
  import "./chunk-K3NQKI34.js";
11
11
  export {
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  MCP_CONFIG_FILE,
12
12
  version,
13
13
  writeMcpConfig
14
- } from "./chunk-33OMMYNV.js";
14
+ } from "./chunk-KNBPVBMA.js";
15
15
  import {
16
16
  __export
17
17
  } from "./chunk-K3NQKI34.js";
@@ -4172,7 +4172,7 @@ import process4 from "process";
4172
4172
  import { Readable, Transform } from "stream";
4173
4173
  import { pipeline } from "stream/promises";
4174
4174
  import AdmZip from "adm-zip";
4175
- var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.22-alpha.zip";
4175
+ var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.23-alpha.zip";
4176
4176
  var TEMPLATE_SUBPATH = "packages/multiplayer-template";
4177
4177
  var PROJECT_NAME_RE = /^[\w@./-][\w@./\- ]*$/;
4178
4178
  var NAME_SEPARATORS_RE = /[-_\s]+/;
@@ -5344,7 +5344,32 @@ var appNameTitle = {
5344
5344
  }
5345
5345
  }
5346
5346
  };
5347
- var MIGRATIONS = [devScript, appNameTitle];
5347
+ var PACKAGE_JSONS = ["client/package.json", "package.json"];
5348
+ var THREE_PERF = "three-perf";
5349
+ var dropThreePerf = {
5350
+ id: "0.0.28-drop-three-perf",
5351
+ since: "0.0.28",
5352
+ description: "Remove three-perf, which core no longer uses: frame stats come from three's inspector",
5353
+ applies({ files }) {
5354
+ return PACKAGE_JSONS.some((path) => {
5355
+ const pkg = files.readJson(path);
5356
+ return !!(pkg?.dependencies?.[THREE_PERF] || pkg?.devDependencies?.[THREE_PERF]);
5357
+ });
5358
+ },
5359
+ run({ files }) {
5360
+ for (const path of PACKAGE_JSONS) {
5361
+ const pkg = files.readJson(path);
5362
+ if (!pkg?.dependencies?.[THREE_PERF] && !pkg?.devDependencies?.[THREE_PERF])
5363
+ continue;
5364
+ for (const field of ["dependencies", "devDependencies"]) {
5365
+ if (pkg[field]?.[THREE_PERF])
5366
+ delete pkg[field][THREE_PERF];
5367
+ }
5368
+ files.writeJson(path, pkg);
5369
+ }
5370
+ }
5371
+ };
5372
+ var MIGRATIONS = [devScript, appNameTitle, dropThreePerf];
5348
5373
 
5349
5374
  // ../core/dist/Migrations/ProjectFiles.js
5350
5375
  import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
@@ -6612,8 +6637,8 @@ function parseMcpArgs(args, env = process11.env) {
6612
6637
  async function runMcpCommand({ client, docsUrl, pluginsUrl, readOnly }) {
6613
6638
  const [{ StdioServerTransport }, { createMcpServer }, { DocsClient }, { ProjectPluginTools }] = await Promise.all([
6614
6639
  import("@modelcontextprotocol/sdk/server/stdio.js"),
6615
- import("./server-KTKAYX65.js"),
6616
- import("./docs-5J3ZQJSF.js"),
6640
+ import("./server-2C6FBJKE.js"),
6641
+ import("./docs-E733ATRT.js"),
6617
6642
  import("./projectPluginTools-QWULLUMD.js")
6618
6643
  ]);
6619
6644
  const docs = docsUrl ? new DocsClient(docsUrl) : void 0;
@@ -5,10 +5,10 @@ import {
5
5
  } from "./chunk-GOPDTCJD.js";
6
6
  import {
7
7
  registerDocsTools
8
- } from "./chunk-HRMANFDB.js";
8
+ } from "./chunk-UD5YAJCQ.js";
9
9
  import {
10
10
  version
11
- } from "./chunk-33OMMYNV.js";
11
+ } from "./chunk-KNBPVBMA.js";
12
12
  import {
13
13
  LOG_LEVELS,
14
14
  READ_ONLY,
@@ -330,9 +330,9 @@ function analyzeTrace(capture, { maxHitches = 10 } = {}) {
330
330
  findings.push(`${totals.syncCalls} GPU sync calls (${totals.syncMs}ms): readPixels / getError stall the pipeline. renderer.debug.checkShaderErrors = true calls getError after compiles, and picking with readPixels each frame stalls too`);
331
331
  if (bottleneck.verdict === "gpu-bound") {
332
332
  findings.push(`GPU-bound at ${capture.canvas.width}x${capture.canvas.height} (pixel ratio ${capture.canvas.pixelRatio}): lower the pixel ratio (cap it at 1.5\u20132), shadow map size or shadow-casting lights, and look at the most expensive passes`);
333
- const heavyPasses = passes.filter((p) => p.name !== "RenderPass" && p.name !== "OutputPass");
334
- if (heavyPasses.length)
335
- findings.push(`Post-processing passes cost GPU fill rate on every pixel: ${heavyPasses.map((p) => p.name).join(", ")}`);
333
+ const effects = capture.effects ?? passes.map((p) => p.name).filter((name) => name !== "RenderPass" && name !== "OutputPass");
334
+ if (effects.length)
335
+ findings.push(`Post-processing effects cost GPU fill rate on every pixel: ${effects.join(", ")}`);
336
336
  }
337
337
  if (tickStats && budgetMs && tickStats.p95 > budgetMs / 2) {
338
338
  findings.push(`Game ticks are slow (p95 ${tickStats.p95}ms${tickStats.physics ? `, physics p95 ${tickStats.physics.p95}ms` : ""}${tickStats.world ? `, world.update p95 ${tickStats.world.p95}ms` : ""}) and block rendering when they run`);
@@ -390,7 +390,7 @@ var TRACKS = {
390
390
  };
391
391
  var TRACK_NAMES = {
392
392
  [TRACKS.frames]: "Frames (render CPU)",
393
- [TRACKS.passes]: "Composer passes",
393
+ [TRACKS.passes]: "Render passes",
394
394
  [TRACKS.gpu]: "GPU time per frame (duration, not GPU clock)",
395
395
  [TRACKS.ticks]: "Game ticks",
396
396
  [TRACKS.js]: "JS samples",
@@ -751,7 +751,7 @@ function registerClientTools(server, client) {
751
751
  });
752
752
  server.registerTool("client_trace", {
753
753
  title: "Trace client rendering",
754
- description: "Record a tab for a few seconds and analyse its performance: frame time distribution, render CPU vs GPU time per frame, time per composer pass, game tick time (physics, world.update), WebGL work per frame (draw calls, program / texture / framebuffer switches, uniform calls, uploads), the bottleneck, and the worst hitches with their likely causes (shader compiles, texture uploads, GPU syncs, GC, slow ticks, long scripts, hot JS functions). JS sampling uses the browser's JS Self-Profiling API (Chromium) and GPU time EXT_disjoint_timer_query_webgl2. Also saves a Chrome Trace Event file to open as a flame chart in https://ui.perfetto.dev or chrome://tracing. Keep the tab in the foreground while it records.",
754
+ description: "Record a tab for a few seconds and analyse its performance: frame time distribution, render CPU vs GPU time per frame, time in the render pipeline, game tick time (physics, world.update), WebGL work per frame (draw calls, program / texture / framebuffer switches, uniform calls, uploads), the bottleneck, and the worst hitches with their likely causes (shader compiles, texture uploads, GPU syncs, GC, slow ticks, long scripts, hot JS functions). JS sampling uses the browser's JS Self-Profiling API (Chromium) and GPU time EXT_disjoint_timer_query_webgl2. Also saves a Chrome Trace Event file to open as a flame chart in https://ui.perfetto.dev or chrome://tracing. Keep the tab in the foreground while it records.",
755
755
  inputSchema: {
756
756
  clientId,
757
757
  durationMs: z.number().int().min(500).max(15e3).default(3e3).describe("How long to record"),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mavonengine/cli",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.9",
5
5
  "description": "MavonEngine command line tools",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@modelcontextprotocol/sdk": "^1.32.2",
36
- "@profullstack/hqtui": "0.11.1",
37
- "adm-zip": "^0.5.16",
36
+ "@profullstack/hqtui": "0.12.0",
37
+ "adm-zip": "^0.6.1",
38
38
  "zod": "^4.6.7"
39
39
  },
40
40
  "devDependencies": {