virtualmatter 0.6.4 → 0.6.5
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 +3 -2
- package/dist/agentfiles.js +19 -7
- package/dist/agents-md.generated.js +1 -1
- package/dist/atomo.js +157 -0
- package/dist/ignore.js +3 -3
- package/dist/index.js +26 -2
- package/dist/pull.js +18 -2
- package/dist/skills.js +73 -0
- package/dist/sync.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,11 +123,12 @@ deploying it.
|
|
|
123
123
|
| --- | --- |
|
|
124
124
|
| `make <name> [dir]` (`create`) | Make a world (region defaults to the nearest; `--region`, `--track`, `--description`, `--no-pull`, `--open`, `--json`) and mirror it into `./<slug>`. |
|
|
125
125
|
| `list` (`ls`, `projects`) | Your worlds with framing ids and edit/play URLs (`--json`). |
|
|
126
|
-
| `pull [target] [dir]` | Mirror a world's file tree. `target` is any link to the world (or your website) or a framing id, and always resolves to the world's editor; omitted, it uses this folder's world or your only one. |
|
|
127
|
-
| `sync [dir]` | Watch + two-way sync with the live session. Ctrl-C to stop. |
|
|
126
|
+
| `pull [target] [dir]` | Mirror a world's file tree. `target` is any link to the world (or your website) or a framing id, and always resolves to the world's editor; omitted, it uses this folder's world or your only one. Also writes the harness files: `AGENTS.md`, `CLAUDE.md`, MCP registrations, the world's skill packages copied into `.claude/skills/`, and (macOS, Linux) an executable `./atomo`. |
|
|
127
|
+
| `sync [dir]` | Watch + two-way sync with the live session. Ctrl-C to stop. Refreshes `AGENTS.md` and `.claude/skills/` whenever the world's `Skills/` changes. |
|
|
128
128
|
| `open [target]` (`client`) | Optional: open a world in the native desktop client, downloading and signing it in on first use. `--install-only`, `--print` (just the download URL), `--force`. |
|
|
129
129
|
| `run-lua [dir] --code "<lua>" [--target server\|client] [--client <id>]` | Execute Lua in the running engine. A client run uses the only connected client unless `--client` names one (list them with `--code "return Server:GetClients()"`). Exit code 3 means the engine did not answer in time and may still be running the code: check its effect before sending code that changes the world again. It is never retried for you. |
|
|
130
130
|
| `errors [dir]` | Recent engine errors. Retried twice when the engine is busy or briefly unreachable, since it only reads. |
|
|
131
|
+
| `atomo [--dir <dir>] -- <command> ...` | The engine SDK's `atomo` commands (`run-lua`, `run-lua-client [id]`, `errors`) in atomo's own output format, for tools written against atomo such as the starter builder. The folder's `./atomo` calls this; a bridge timeout exits 3. |
|
|
131
132
|
| `screenshot [dir] [-o out.png] [--client <id>]` | Capture the engine's view; `--client` captures through a connected client, UI included. |
|
|
132
133
|
| `mcp [dir] [--framing <id>]` | Run the stdio MCP server. |
|
|
133
134
|
| `login` / `logout` / `whoami` | Device-code sign-in; every other command signs you in automatically when needed. Tokens live in `~/.config/virtualmatter/credentials.json` (mode 0600) and refresh automatically. |
|
package/dist/agentfiles.js
CHANGED
|
@@ -103,15 +103,18 @@ export function composeAgentsMd(platformDoc, engineDoc) {
|
|
|
103
103
|
|
|
104
104
|
The section below is the engine SDK's own agent guide, mirrored from this
|
|
105
105
|
world's Montage tree. It assumes an agent running INSIDE a Virtual Matter
|
|
106
|
-
session, where an \`atomo\` command talks to the live engine.
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
session, where an \`atomo\` command talks to the live engine. On macOS and
|
|
107
|
+
Linux this folder has its own \`./atomo\`, written by the CLI: \`./atomo run-lua\`,
|
|
108
|
+
\`./atomo run-lua-client\` and \`./atomo errors\` work as the guide writes them,
|
|
109
|
+
straight against the engine, and so do the skill tools under \`Skills/\` that
|
|
110
|
+
call them (the starters' \`starterctl.py\`). Everything else maps to the
|
|
111
|
+
\`virtualmatter\` CLI or its MCP tools:
|
|
109
112
|
|
|
110
113
|
| Engine doc says | Do this instead |
|
|
111
114
|
| --- | --- |
|
|
112
|
-
| \`atomo run-lua '<code>'\` | \`npx virtualmatter run-lua --code '<code>'\` (MCP: \`run_lua\`) |
|
|
113
|
-
| \`atomo run-lua-client ...\` | \`npx virtualmatter run-lua --target client --code '<code>'\` |
|
|
114
|
-
| \`atomo errors\` | \`npx virtualmatter errors\` (MCP: \`get_engine_errors\`) |
|
|
115
|
+
| \`atomo run-lua '<code>'\` | \`./atomo run-lua '<code>'\`, or \`npx virtualmatter run-lua --code '<code>'\` (MCP: \`run_lua\`) |
|
|
116
|
+
| \`atomo run-lua-client ...\` | \`./atomo run-lua-client <id> '<code>'\`, or \`npx virtualmatter run-lua --target client --code '<code>'\` |
|
|
117
|
+
| \`atomo errors\` | \`./atomo errors\`, or \`npx virtualmatter errors\` (MCP: \`get_engine_errors\`) |
|
|
115
118
|
| \`atomo screenshot\` / \`screenshot-at\` / \`screenshot-obj\` | \`npx virtualmatter screenshot -o shot.png\` (MCP: \`capture_screenshot\`); aim the camera with run-lua first if needed |
|
|
116
119
|
| \`atomo prints\` / \`atomo status\` | not available locally; use \`return\` values from run-lua |
|
|
117
120
|
| edit a .lua file, then check \`atomo errors\` | save the file with \`npx virtualmatter sync\` running (or MCP \`write_file\`), then check errors the same way |
|
|
@@ -120,7 +123,16 @@ tools) wherever the text says \`atomo\`:
|
|
|
120
123
|
|
|
121
124
|
Everything else in it - the Skills/ table, the server/client rules, the Lua
|
|
122
125
|
API rules, the mandatory error check after every change - applies as written.
|
|
123
|
-
The \`Skills/\` files it references are in this folder
|
|
126
|
+
The \`Skills/\` files it references are in this folder; when the world has the
|
|
127
|
+
platform's skill packages (\`Skills/atomontage-*\`), \`pull\` and \`sync\` also
|
|
128
|
+
copy them into \`.claude/skills/\` so Claude Code loads them as skills.
|
|
129
|
+
|
|
130
|
+
You are the agent doing the work. Where the guide or a skill says only the
|
|
131
|
+
in-game agent may use \`atomo\` or run engine-backed tools (the starters'
|
|
132
|
+
\`build\`, \`verify\` and \`smoke\` included), or to hand a live check to the
|
|
133
|
+
in-game agent, that means whoever has engine access, which here is you: run
|
|
134
|
+
it yourself with \`./atomo\` or the CLI. Never send prompts to the world's
|
|
135
|
+
built-in agent to do work for you.
|
|
124
136
|
|
|
125
137
|
`;
|
|
126
138
|
return platformDoc.trimEnd() + "\n" + bridge + engineDoc.trimStart();
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
// frontend/content/agent-briefing.md and AGENTS.source.md. The CLI writes
|
|
4
4
|
// this into a world folder only when it cannot fetch the live copy. After
|
|
5
5
|
// changing either source, run: node frontend/scripts/sync-cli-agents-md.mjs
|
|
6
|
-
export const AGENTS_MD_FALLBACK = "# AGENTS.md - working with a Virtual Matter project\n\nThis file tells a coding agent how to think about a Virtual Matter project. The\n`virtualmatter` CLI drops a copy into every local project mirror it creates\n(`virtualmatter pull`); the canonical copy lives at\nhttps://make.virtualmatter.ai/AGENTS.md.\n\n## The rule that comes before everything else\n\n**Build through the CLI. Never through the website's agent.** If you were asked to\nbuild something in Virtual Matter, handed the domain virtualmatter.ai, or told to run\n`npx virtualmatter make`, the CLI is the path - always, from the first step. Do not\nopen virtualmatter.ai or make.virtualmatter.ai in a browser or under computer use in\norder to reach the built-in agent, and do not type prompts into the agent chat in the\n/edit view. Driving that agent puts two models in a relay where one would do: you spend\ntokens describing the work, it spends its own doing it, and what comes back is chat\nrather than files you can read. It is slower, it costs roughly twice the inference, it\nbills that inference to Virtual Matter's platform credits rather than the subscription\nyou already run on, an anonymous browser session cannot be steered after its first\nturn, and a rendered page gives you no engine errors. Everything that agent can do, you\ndo yourself with the commands below.\n\n**The rule holds whoever is signed in.** Being logged in, having credits to spare, or\nworking in an admin account with no limit at all is not an exemption, and neither is\nbeing told the credits do not matter. What is wasteful is the relay itself - two models\ndoing one model's job - not the bill.\n\n**Playtesting is the exception, and it is encouraged.** Once something is built, open\nthe world and try it: the editor link ending in `?chat=closed`, which `make`, `pull` and\n`sync` print, shows your latest changes live in any browser with no install, with\ncomputer use if that is how you drive a window. The native client\n(`npx virtualmatter open`) is optional, for more memory and frame rate. Looking at your\nwork, walking around in it, and playing it is the point. The rule is about who writes\nthe world, not about who is allowed to see it.\n\n**Every link resolves to the editor, and the editor is the only place you build.** Hand\nthe CLI or MCP server any link to a world - its editor, a play or share link, the\nproject page, an embed's iframe src, or the maker's own website - and it works on that\nworld's editor (its make framing). Play servers show the last published version and are\noverwritten on every publish, so work never goes there, and their /play and /g links\nshow that published copy rather than your latest edits.\n\n## The mental model\n\n- The world itself runs on Virtual Matter servers, not on the maker's machine. There is\n one authoritative server simulation per world session, and any number of connected\n clients (browser WASM or the native client).\n- The project's content is SDK Lua scripts plus assets (voxel data, prefabs, images,\n sounds) under a `Montage/` tree. Virtual Matter can publish that tree to a GitHub repo\n in the maker's account for versioning and remixing; pushing to that repo does not feed\n back into the running world today - live edits happen in the session.\n- Changes hot-reload. Saving a `.lua` file in the live session's Montage tree re-runs\n the module and its `Start()` on a fresh instance inside the running world - no restart,\n no build step.\n- Prefabs are reusable scene-graph snippets: JSON files with a `.prefab` extension in the\n Montage folder, instantiated at runtime via `Server:InsertPrefab(asset)`.\n- There is no local runtime - the world cannot run on the maker's machine. The\n `virtualmatter` CLI (npm) is how you reach it from a local harness, and it needs no\n setup: the first command that needs an account signs you in with a device code.\n `npx virtualmatter make \"My world\"` makes a world and mirrors its Montage tree\n into `./my-world`; `npx virtualmatter pull <any Virtual Matter link>` mirrors an\n existing one (/edit, /play, /g, /p, /projects links all work, with or without a\n readable slug); `npx virtualmatter list` shows your worlds; `npx virtualmatter sync`\n live-pushes saves into the running session (which hot-reloads them);\n `npx virtualmatter run-lua` / `errors` / `screenshot` drive the engine;\n `npx virtualmatter open` optionally opens the world in the native desktop client,\n downloaded and signed in on first use; and `npx virtualmatter mcp` serves\n all of it over MCP. A mirrored folder carries `.mcp.json` and `.cursor/mcp.json`\n (so Claude Code and Cursor register the MCP server on their own), this file, and a\n `CLAUDE.md` that imports it. Folders from virtualmatter 0.5.0 on also carry\n `.codex/config.toml`, which Codex loads once you trust the folder; with an older\n CLI, or if Codex does not list the server, register it once with\n `codex mcp add virtualmatter -- npx -y virtualmatter mcp`. In Claude Code outside a\n mirrored folder, use `claude mcp add virtualmatter -- npx -y virtualmatter mcp`. The\n server works before a world\n is selected (`list_projects`, `create_project`, `select_project`), then exposes\n `list_files`, `read_file`, `write_file`, `run_lua`, `get_engine_errors`,\n `capture_screenshot`, `open_native_client`, and `world_info`.\n- Work through the CLI, not the website - see the rule above. Prompting the built-in\n agent to do your building is the one thing to avoid; opening the world to play it is\n not.\n- Seeing your work: `virtualmatter screenshot` shoots a default overview of the world\n origin, `--target <object>` frames one object by name or id, and `--at x,y,z --rot\n yaw,pitch,roll` places the camera exactly. Y is up and -Z is forward, and the\n rotation really is yaw first: yaw 0 faces -Z, pitch -90 looks straight down, pitch 0\n is the horizon. The MCP `capture_screenshot`\n tool takes the same arguments. Verify a change with a screenshot plus `errors` rather\n than assuming a write worked.\n- A `run-lua` that fails with HTTP 504 (`run-lua timed out`, exit code 3 from CLI\n 0.6.4 on; the MCP `run_lua` tool returns the same text) reached the engine, which\n may still be running it. Do not send code that changes the world again: check its\n effect first, by reading back what it sets or taking a screenshot. Any other\n failure never reached the engine and is safe to retry.\n- The mirrored folder's AGENTS.md is this guide followed by the engine SDK's own agent guide\n (the AGENTS.md that lives in every Montage tree and inside the desktop client's\n Data/Sdk/Montage/). The engine guide assumes an in-session agent driving the engine\n through `atomo`; the merged file maps each `atomo` step to the CLI or MCP equivalent, and\n the `Skills/*.md` references it points at are in the folder. The SDK's own tooling\n (`atomo`, `vm_auth.py`, the agent-log hooks) is not mirrored: it only works inside a\n session. Sandboxed agents need network access for every CLI command.\n\n## Reference\n\nThe same facts as terse lists, for quick lookup.\n\n### Project model\n- A project (\"montage\") is one voxel world hosted with Virtual Matter.\n- A project has framings: \"make\" framings (editing sessions) and \"play\"\n framings (public play sessions). A framing is a running session slot\n on a voxel host.\n- Project content = SDK Lua scripts + assets under a Montage/ tree.\n Edits made in the live session hot-reload into the running world.\n The tree can be published to a maker-owned GitHub repo.\n\n### URL shapes (make.virtualmatter.ai)\n- /new builder for people: create a world from a prompt\n (also at https://virtualmatter.ai/); coding agents\n use npx virtualmatter make instead\n- /edit/<framing-id> maker session: live world + agent chat. The chat is\n for people; a coding agent builds with the CLI and\n never prompts it\n (also /edit/<slug>-<framing-id>; the CLI accepts both)\n- /play/<framing-id> play session for a specific framing\n- /g/<id> share URL resolver: 302s to a live session\n\n### APIs (unauthenticated)\n- GET https://make.virtualmatter.ai/api/v1/public/native-clients\n JSON: { iteration, clients: [{ platform, kind, variant, url, filename,\n file_size, branch, commit, match }] } - per-platform native client\n installers (kind \"download\") or store links (kind \"store\", iOS).\n Windows and Linux list two downloads each: variant \"installer\" /\n \"flatpak\" for people, and \"portable\" / \"tarball\", the file tree the\n CLI installs.\n\n### CLI + MCP (npm package \"virtualmatter\", Node >= 20)\n- npx virtualmatter make \"<name>\" make a world, mirror it into ./<slug>\n- npx virtualmatter pull <link> mirror an existing world (any link shape)\n- npx virtualmatter list your worlds with framing ids + URLs\n- npx virtualmatter sync live-push saves into the running world\n- npx virtualmatter open optional: open it in the native client\n- npx virtualmatter mcp stdio MCP server (list_projects,\n create_project, select_project, list_files, read_file, write_file,\n run_lua, get_engine_errors, capture_screenshot, open_native_client,\n world_info)\n- Sign-in happens on first use (device code); no separate login step.\n- These commands are the whole build path. Never prompt the built-in\n agent on the site to do the work; a browser or the native client is\n for playtesting what you built.\n- Any link to a world (editor, play or share link, project page, embed,\n or the maker's own website) resolves to its editor, the only place\n the CLI and MCP server work. Play servers show the last published\n version and are overwritten on publish.\n- Watch changes land live at the editor link ending in ?chat=closed,\n in any browser, no install. The native client is optional.\n- A mirrored folder carries .mcp.json, .cursor/mcp.json, AGENTS.md and\n CLAUDE.md, so Claude Code and Cursor register the server on their own.\n- Codex: folders from 0.5.0 on carry .codex/config.toml, loaded once the\n folder is trusted; otherwise register the server once:\n codex mcp add virtualmatter -- npx -y virtualmatter mcp\n\n## SDK Lua cheat sheet\n\nThe scripting language is Lua 5.4, sandboxed: `os`, `io`, `require`, `package`,\n`dofile`, `loadfile`, `loadstring` are nil. `math`, `string`, `table`, `coroutine`\nremain. No `os.time` - use `Time.time` (sim time), `Time.frame`, or\n`AE:GetDebugTime()` (wall clock).\n\n### Script shape\n\nEvery persistent behavior is a `.lua` file in the Montage tree returning a `self` table:\n\n```lua\nlocal self = {}\nfunction self:Start() end\nfunction self:Update(deltaTime) end\nreturn self\n```\n\nAttach to an object with `obj:AddScript(\"My Folder/Example.lua\", sync)` - the path is\nrelative to the Montage root; `sync = true` replicates the script to clients.\n`obj:FindScript(\"Example\")` returns the live instance.\n\n### Server / client split\n\nThe same script runs on the server and (when synced) on every client. Branch with\n`self.onServer` / `self.onClient`:\n\n```lua\nfunction self:Update(dt)\n if self.onClient then return end -- voxel edits are server-only\n -- authoritative logic here\nend\n```\n\nNothing replicates automatically: set `syncToClients = true` on the script or\nVoxelData component, and use `util:makeNetworkedTable(self, { hp = 100 })` for\nproperties that should sync (server writes, clients read, deltas only).\n`obj.pos` / `obj.rot` do not auto-sync - replicate them yourself.\n\n### RPC\n\n```lua\nself:RPC(\"serverDoSomething\", pos, dir) -- on a client: goes to the server\nfunction self:serverDoSomething(pos, dir, clientID) -- clientID auto-appended\n assert(self.onServer)\nend\n```\n\nOn the server, `self:RPC(...)` fans out to all clients. Reliable, FIFO per direction.\nRequires `self.component.syncToClients = true`.\n\n### Scene and objects (server)\n\n```lua\nlocal ob = Scene:CreateObject(\"Name\")\nob.save = true\nob:AddScript(\"Path/Script.lua\")\nScene:GetObjectByName(\"Name\")\nScene:CloneObject(ob) -- prefer over rebuilding\nob.active = false -- prefer over destroy\nob:AddTag(\"Enemy\"); FindObjectsWithTag(\"Enemy\") -- tags are runtime-only state\n```\n\n### Voxel editing (server only, async)\n\n```lua\nVox:Add(Sphere(pos, 2)):Color(1, 0, 0):Run()\nVox:Add(Box(Vec3(0, -1, 0), Vec3(20, 2, 20))):ForceStatic():Run()\n```\n\nShapes: `Box(center, fullSize)`, `Sphere(center, r)`, `Capsule(p1, p2, r)`,\n`Cylinder(p1, p2, r1[, r2])`. `Run()` is async - chain `:OnFinished(fn)` before\n`:Run()` to read post-commit state. Big edits stall the frame for every client;\nkeep in-game edits small and infrequent.\n\n### Input (event-driven, client input reaches the server)\n\n```lua\nself.component.syncToClients = true\nevents.keyDown.addListener(self, function(key, from) self.keys[key] = true end)\nevents.keyUp.addListener(self, function(key, from) self.keys[key] = false end)\n```\n\nPlayer-driven movement must be client-predicted - never gate the player's own\nfeedback on the server round-trip.\n\n### Physics\n\n```lua\nlocal rb = obj:AddComponent(\"RigidBody\")\nrb:AddImpulse(Vec3(0, 50, 0), obj.pos)\nrb.velocity; rb.mass; rb.gravityScale\n```\n\n### Time and diagnostics\n\n```lua\nTime.dt; Time.time; Time.frame; Time.timeScale\nAE:GetLogValue(\"Raycasts\") -- engine counters, e.g. raycasts this frame\nAE:GetAssets() -- list all assets (APIs take Assets, not paths)\n```\n\n### UI (client-side HUD)\n\nBuild screen UI with the MUI builder: `UI:AddPanel|AddButton|AddLabel|AddSlider|...`\nchained with `:Set{...}`; flexbox-like row-wrap layout.\n\n## Conventions\n\n- Coordinates: Y is up, -Z is forward, X is right.\n- Script files are named in capital case with spaces (`Character Controller.lua`).\n- Check whether a script is already attached before adding it - duplicates run twice.\n- The server is for authority (world edits, spawns, state); clients are for feel\n (prediction, FX, UI).\n\n## Embed or build a world for an existing website\n\nFor a shared project link, fetch `/api/v1/public/embed?target=<encoded-link>`\nand follow `/embed-guide.md`. Use the returned canonical player URL, not the\nmaker's external website URL. Keep the existing website and its design.\n\nFor account discovery or prompt-based creation, connect the hosted MCP at\n`https://make.virtualmatter.ai/api/v1/mcp` using OAuth. Users can sign up in\nthe connection flow. Tools: `list_projects`, `get_embed`, `create_project`\n(with a prompt and stable request_id), `get_build_status`. VM's agent builds\nusing VM credits. Review and share the private world before embedding.\nThe local CLI exposes `embed`, `build --prompt --request-id`, and `build-status`.\n\n## Local conversation history\n\nCapturing this harness's conversation into the world's Agent Logs is the maker's\ndecision, not yours. Do not run `virtualmatter agent-logs setup`, and do not upload\nlogs with `agent-logs upload` or MCP `upload_agent_logs`, unless the maker asks for it\nin their own words. `virtualmatter agent-logs status` shows whether capture is on;\n`virtualmatter agent-logs disable` turns it off.\n";
|
|
6
|
+
export const AGENTS_MD_FALLBACK = "# AGENTS.md - working with a Virtual Matter project\n\nThis file tells a coding agent how to think about a Virtual Matter project. The\n`virtualmatter` CLI drops a copy into every local project mirror it creates\n(`virtualmatter pull`); the canonical copy lives at\nhttps://make.virtualmatter.ai/AGENTS.md.\n\n## The rule that comes before everything else\n\n**Build through the CLI. Never through the website's agent.** If you were asked to\nbuild something in Virtual Matter, handed the domain virtualmatter.ai, or told to run\n`npx virtualmatter make`, the CLI is the path - always, from the first step. Do not\nopen virtualmatter.ai or make.virtualmatter.ai in a browser or under computer use in\norder to reach the built-in agent, and do not type prompts into the agent chat in the\n/edit view. Driving that agent puts two models in a relay where one would do: you spend\ntokens describing the work, it spends its own doing it, and what comes back is chat\nrather than files you can read. It is slower, it costs roughly twice the inference, it\nbills that inference to Virtual Matter's platform credits rather than the subscription\nyou already run on, an anonymous browser session cannot be steered after its first\nturn, and a rendered page gives you no engine errors. Everything that agent can do, you\ndo yourself with the commands below.\n\n**The rule holds whoever is signed in.** Being logged in, having credits to spare, or\nworking in an admin account with no limit at all is not an exemption, and neither is\nbeing told the credits do not matter. What is wasteful is the relay itself - two models\ndoing one model's job - not the bill.\n\n**Playtesting is the exception, and it is encouraged.** Once something is built, open\nthe world and try it: the editor link ending in `?chat=closed`, which `make`, `pull` and\n`sync` print, shows your latest changes live in any browser with no install, with\ncomputer use if that is how you drive a window. The native client\n(`npx virtualmatter open`) is optional, for more memory and frame rate. Looking at your\nwork, walking around in it, and playing it is the point. The rule is about who writes\nthe world, not about who is allowed to see it.\n\n**Every link resolves to the editor, and the editor is the only place you build.** Hand\nthe CLI or MCP server any link to a world - its editor, a play or share link, the\nproject page, an embed's iframe src, or the maker's own website - and it works on that\nworld's editor (its make framing). Play servers show the last published version and are\noverwritten on every publish, so work never goes there, and their /play and /g links\nshow that published copy rather than your latest edits.\n\n## The mental model\n\n- The world itself runs on Virtual Matter servers, not on the maker's machine. There is\n one authoritative server simulation per world session, and any number of connected\n clients (browser WASM or the native client).\n- The project's content is SDK Lua scripts plus assets (voxel data, prefabs, images,\n sounds) under a `Montage/` tree. Virtual Matter can publish that tree to a GitHub repo\n in the maker's account for versioning and remixing; pushing to that repo does not feed\n back into the running world today - live edits happen in the session.\n- Changes hot-reload. Saving a `.lua` file in the live session's Montage tree re-runs\n the module and its `Start()` on a fresh instance inside the running world - no restart,\n no build step.\n- Prefabs are reusable scene-graph snippets: JSON files with a `.prefab` extension in the\n Montage folder, instantiated at runtime via `Server:InsertPrefab(asset)`.\n- There is no local runtime - the world cannot run on the maker's machine. The\n `virtualmatter` CLI (npm) is how you reach it from a local harness, and it needs no\n setup: the first command that needs an account signs you in with a device code.\n `npx virtualmatter make \"My world\"` makes a world and mirrors its Montage tree\n into `./my-world`; `npx virtualmatter pull <any Virtual Matter link>` mirrors an\n existing one (/edit, /play, /g, /p, /projects links all work, with or without a\n readable slug); `npx virtualmatter list` shows your worlds; `npx virtualmatter sync`\n live-pushes saves into the running session (which hot-reloads them);\n `npx virtualmatter run-lua` / `errors` / `screenshot` drive the engine;\n `npx virtualmatter open` optionally opens the world in the native desktop client,\n downloaded and signed in on first use; and `npx virtualmatter mcp` serves\n all of it over MCP. A mirrored folder carries `.mcp.json` and `.cursor/mcp.json`\n (so Claude Code and Cursor register the MCP server on their own), this file, and a\n `CLAUDE.md` that imports it. Folders from virtualmatter 0.5.0 on also carry\n `.codex/config.toml`, which Codex loads once you trust the folder; with an older\n CLI, or if Codex does not list the server, register it once with\n `codex mcp add virtualmatter -- npx -y virtualmatter mcp`. In Claude Code outside a\n mirrored folder, use `claude mcp add virtualmatter -- npx -y virtualmatter mcp`. The\n server works before a world\n is selected (`list_projects`, `create_project`, `select_project`), then exposes\n `list_files`, `read_file`, `write_file`, `run_lua`, `get_engine_errors`,\n `capture_screenshot`, `open_native_client`, and `world_info`.\n- Work through the CLI, not the website - see the rule above. Prompting the built-in\n agent to do your building is the one thing to avoid; opening the world to play it is\n not.\n- Seeing your work: `virtualmatter screenshot` shoots a default overview of the world\n origin, `--target <object>` frames one object by name or id, and `--at x,y,z --rot\n yaw,pitch,roll` places the camera exactly. Y is up and -Z is forward, and the\n rotation really is yaw first: yaw 0 faces -Z, pitch -90 looks straight down, pitch 0\n is the horizon. The MCP `capture_screenshot`\n tool takes the same arguments. Verify a change with a screenshot plus `errors` rather\n than assuming a write worked.\n- A `run-lua` that fails with HTTP 504 (`run-lua timed out`, exit code 3 from CLI\n 0.6.4 on; the MCP `run_lua` tool returns the same text) reached the engine, which\n may still be running it. Do not send code that changes the world again: check its\n effect first, by reading back what it sets or taking a screenshot. Any other\n failure never reached the engine and is safe to retry.\n- The mirrored folder's AGENTS.md is this guide followed by the engine SDK's own agent guide\n (the AGENTS.md that lives in every Montage tree and inside the desktop client's\n Data/Sdk/Montage/). The engine guide assumes an in-session agent driving the engine\n through `atomo`; the merged file maps each `atomo` step to the CLI or MCP equivalent, and\n the `Skills/*.md` references it points at are in the folder. The SDK's own tooling\n (`atomo`, `vm_auth.py`, the agent-log hooks) is not mirrored: it only works inside a\n session. From CLI 0.6.5 on, macOS and Linux folders get their own `./atomo`, which\n serves the guide's `./atomo run-lua`, `run-lua-client` and `errors` through the CLI.\n Sandboxed agents need network access for every CLI command.\n- Worlds with the platform's skill packages carry them in `Skills/atomontage-*`.\n From CLI 0.6.5 on, `pull` and `sync` also copy them into `.claude/skills/`, so Claude\n Code loads them as skills; other harnesses follow the routing table in AGENTS.md.\n Start from `atomontage-game-starters` for any of the 15 homepage starter games: its\n `starterctl.py build <preset>` builds a playable starter in seconds through\n `./atomo`. Where a skill says to hand a live check to the in-game agent, run it\n yourself: never send prompts to the world's built-in agent.\n\n## Reference\n\nThe same facts as terse lists, for quick lookup.\n\n### Project model\n- A project (\"montage\") is one voxel world hosted with Virtual Matter.\n- A project has framings: \"make\" framings (editing sessions) and \"play\"\n framings (public play sessions). A framing is a running session slot\n on a voxel host.\n- Project content = SDK Lua scripts + assets under a Montage/ tree.\n Edits made in the live session hot-reload into the running world.\n The tree can be published to a maker-owned GitHub repo.\n\n### URL shapes (make.virtualmatter.ai)\n- /new builder for people: create a world from a prompt\n (also at https://virtualmatter.ai/); coding agents\n use npx virtualmatter make instead\n- /edit/<framing-id> maker session: live world + agent chat. The chat is\n for people; a coding agent builds with the CLI and\n never prompts it\n (also /edit/<slug>-<framing-id>; the CLI accepts both)\n- /play/<framing-id> play session for a specific framing\n- /g/<id> share URL resolver: 302s to a live session\n\n### APIs (unauthenticated)\n- GET https://make.virtualmatter.ai/api/v1/public/native-clients\n JSON: { iteration, clients: [{ platform, kind, variant, url, filename,\n file_size, branch, commit, match }] } - per-platform native client\n installers (kind \"download\") or store links (kind \"store\", iOS).\n Windows and Linux list two downloads each: variant \"installer\" /\n \"flatpak\" for people, and \"portable\" / \"tarball\", the file tree the\n CLI installs.\n\n### CLI + MCP (npm package \"virtualmatter\", Node >= 20)\n- npx virtualmatter make \"<name>\" make a world, mirror it into ./<slug>\n- npx virtualmatter pull <link> mirror an existing world (any link shape)\n- npx virtualmatter list your worlds with framing ids + URLs\n- npx virtualmatter sync live-push saves into the running world\n- npx virtualmatter open optional: open it in the native client\n- npx virtualmatter mcp stdio MCP server (list_projects,\n create_project, select_project, list_files, read_file, write_file,\n run_lua, get_engine_errors, capture_screenshot, open_native_client,\n world_info)\n- Sign-in happens on first use (device code); no separate login step.\n- These commands are the whole build path. Never prompt the built-in\n agent on the site to do the work; a browser or the native client is\n for playtesting what you built.\n- Any link to a world (editor, play or share link, project page, embed,\n or the maker's own website) resolves to its editor, the only place\n the CLI and MCP server work. Play servers show the last published\n version and are overwritten on publish.\n- Watch changes land live at the editor link ending in ?chat=closed,\n in any browser, no install. The native client is optional.\n- A mirrored folder carries .mcp.json, .cursor/mcp.json, AGENTS.md and\n CLAUDE.md, so Claude Code and Cursor register the server on their own.\n- Codex: folders from 0.5.0 on carry .codex/config.toml, loaded once the\n folder is trusted; otherwise register the server once:\n codex mcp add virtualmatter -- npx -y virtualmatter mcp\n\n## SDK Lua cheat sheet\n\nThe scripting language is Lua 5.4, sandboxed: `os`, `io`, `require`, `package`,\n`dofile`, `loadfile`, `loadstring` are nil. `math`, `string`, `table`, `coroutine`\nremain. No `os.time` - use `Time.time` (sim time), `Time.frame`, or\n`AE:GetDebugTime()` (wall clock).\n\n### Script shape\n\nEvery persistent behavior is a `.lua` file in the Montage tree returning a `self` table:\n\n```lua\nlocal self = {}\nfunction self:Start() end\nfunction self:Update(deltaTime) end\nreturn self\n```\n\nAttach to an object with `obj:AddScript(\"My Folder/Example.lua\", sync)` - the path is\nrelative to the Montage root; `sync = true` replicates the script to clients.\n`obj:FindScript(\"Example\")` returns the live instance.\n\n### Server / client split\n\nThe same script runs on the server and (when synced) on every client. Branch with\n`self.onServer` / `self.onClient`:\n\n```lua\nfunction self:Update(dt)\n if self.onClient then return end -- voxel edits are server-only\n -- authoritative logic here\nend\n```\n\nNothing replicates automatically: set `syncToClients = true` on the script or\nVoxelData component, and use `util:makeNetworkedTable(self, { hp = 100 })` for\nproperties that should sync (server writes, clients read, deltas only).\n`obj.pos` / `obj.rot` do not auto-sync - replicate them yourself.\n\n### RPC\n\n```lua\nself:RPC(\"serverDoSomething\", pos, dir) -- on a client: goes to the server\nfunction self:serverDoSomething(pos, dir, clientID) -- clientID auto-appended\n assert(self.onServer)\nend\n```\n\nOn the server, `self:RPC(...)` fans out to all clients. Reliable, FIFO per direction.\nRequires `self.component.syncToClients = true`.\n\n### Scene and objects (server)\n\n```lua\nlocal ob = Scene:CreateObject(\"Name\")\nob.save = true\nob:AddScript(\"Path/Script.lua\")\nScene:GetObjectByName(\"Name\")\nScene:CloneObject(ob) -- prefer over rebuilding\nob.active = false -- prefer over destroy\nob:AddTag(\"Enemy\"); FindObjectsWithTag(\"Enemy\") -- tags are runtime-only state\n```\n\n### Voxel editing (server only, async)\n\n```lua\nVox:Add(Sphere(pos, 2)):Color(1, 0, 0):Run()\nVox:Add(Box(Vec3(0, -1, 0), Vec3(20, 2, 20))):ForceStatic():Run()\n```\n\nShapes: `Box(center, fullSize)`, `Sphere(center, r)`, `Capsule(p1, p2, r)`,\n`Cylinder(p1, p2, r1[, r2])`. `Run()` is async - chain `:OnFinished(fn)` before\n`:Run()` to read post-commit state. Big edits stall the frame for every client;\nkeep in-game edits small and infrequent.\n\n### Input (event-driven, client input reaches the server)\n\n```lua\nself.component.syncToClients = true\nevents.keyDown.addListener(self, function(key, from) self.keys[key] = true end)\nevents.keyUp.addListener(self, function(key, from) self.keys[key] = false end)\n```\n\nPlayer-driven movement must be client-predicted - never gate the player's own\nfeedback on the server round-trip.\n\n### Physics\n\n```lua\nlocal rb = obj:AddComponent(\"RigidBody\")\nrb:AddImpulse(Vec3(0, 50, 0), obj.pos)\nrb.velocity; rb.mass; rb.gravityScale\n```\n\n### Time and diagnostics\n\n```lua\nTime.dt; Time.time; Time.frame; Time.timeScale\nAE:GetLogValue(\"Raycasts\") -- engine counters, e.g. raycasts this frame\nAE:GetAssets() -- list all assets (APIs take Assets, not paths)\n```\n\n### UI (client-side HUD)\n\nBuild screen UI with the MUI builder: `UI:AddPanel|AddButton|AddLabel|AddSlider|...`\nchained with `:Set{...}`; flexbox-like row-wrap layout.\n\n## Conventions\n\n- Coordinates: Y is up, -Z is forward, X is right.\n- Script files are named in capital case with spaces (`Character Controller.lua`).\n- Check whether a script is already attached before adding it - duplicates run twice.\n- The server is for authority (world edits, spawns, state); clients are for feel\n (prediction, FX, UI).\n\n## Embed or build a world for an existing website\n\nFor a shared project link, fetch `/api/v1/public/embed?target=<encoded-link>`\nand follow `/embed-guide.md`. Use the returned canonical player URL, not the\nmaker's external website URL. Keep the existing website and its design.\n\nFor account discovery or prompt-based creation, connect the hosted MCP at\n`https://make.virtualmatter.ai/api/v1/mcp` using OAuth. Users can sign up in\nthe connection flow. Tools: `list_projects`, `get_embed`, `create_project`\n(with a prompt and stable request_id), `get_build_status`. VM's agent builds\nusing VM credits. Review and share the private world before embedding.\nThe local CLI exposes `embed`, `build --prompt --request-id`, and `build-status`.\n\n## Local conversation history\n\nCapturing this harness's conversation into the world's Agent Logs is the maker's\ndecision, not yours. Do not run `virtualmatter agent-logs setup`, and do not upload\nlogs with `agent-logs upload` or MCP `upload_agent_logs`, unless the maker asks for it\nin their own words. `virtualmatter agent-logs status` shows whether capture is on;\n`virtualmatter agent-logs disable` turns it off.\n";
|
package/dist/atomo.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `virtualmatter atomo`: the engine SDK's `atomo` commands for a pulled folder.
|
|
3
|
+
*
|
|
4
|
+
* The SDK's agent guide and the partner skill tools (the starters'
|
|
5
|
+
* `starterctl.py`) drive the engine through `./atomo run-lua ...`, and the
|
|
6
|
+
* real atomo only works inside a session. This serves the same commands
|
|
7
|
+
* through the session's engine API, which the CLI calls directly - never
|
|
8
|
+
* through the world's built-in agent - and prints them in atomo's own format
|
|
9
|
+
* (`atomo_cli.py`: `_print_run_lua_payload`, `cmd_errors`), so those tools
|
|
10
|
+
* parse it unchanged. `pull` writes a `./atomo` wrapper that calls this.
|
|
11
|
+
*/
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { EngineTimeoutError } from "./files.js";
|
|
15
|
+
const CLI_EQUIVALENTS = {
|
|
16
|
+
screenshot: "npx virtualmatter screenshot -o shot.png (aim with --at/--rot or --target)",
|
|
17
|
+
"screenshot-at": "npx virtualmatter screenshot --at x,y,z -o shot.png",
|
|
18
|
+
"screenshot-close": "npx virtualmatter screenshot --at x,y,z -o shot.png",
|
|
19
|
+
"screenshot-obj": "npx virtualmatter screenshot --target <object> -o shot.png",
|
|
20
|
+
prints: "return values from ./atomo run-lua",
|
|
21
|
+
status: "./atomo run-lua 'return 1' (it fails when the engine is unreachable)",
|
|
22
|
+
};
|
|
23
|
+
/** atomo's run-lua printing: label sections only when mixed, or when there is an error. */
|
|
24
|
+
export function printRunLuaPayload(output, out) {
|
|
25
|
+
let data;
|
|
26
|
+
try {
|
|
27
|
+
data = JSON.parse(output);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
out.stdout(output);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
34
|
+
out.stdout(output);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const record = data;
|
|
38
|
+
const items = (key) => (Array.isArray(record[key]) ? record[key].map(String) : []);
|
|
39
|
+
const sections = [
|
|
40
|
+
["RESULT", items("result"), out.stdout],
|
|
41
|
+
["PRINT", items("print"), out.stdout],
|
|
42
|
+
["ERROR", items("error"), out.stderr],
|
|
43
|
+
];
|
|
44
|
+
const nonEmpty = sections.filter(([, lines]) => lines.length > 0);
|
|
45
|
+
const label = nonEmpty.length > 1 || nonEmpty.some(([name]) => name === "ERROR");
|
|
46
|
+
for (const [name, lines, write] of nonEmpty) {
|
|
47
|
+
lines.forEach((line, i) => write(label && i === 0 ? `[${name}] ${line}` : line));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** atomo's errors printing: one labelled stderr line per error, nothing when clean. */
|
|
51
|
+
export function printErrors(output, out) {
|
|
52
|
+
let data;
|
|
53
|
+
try {
|
|
54
|
+
data = JSON.parse(output);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
out.stdout(output);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
61
|
+
out.stdout(output);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const record = data;
|
|
65
|
+
const list = (key) => (Array.isArray(record[key]) ? record[key].map(String) : []);
|
|
66
|
+
for (const err of list("server_errors"))
|
|
67
|
+
out.stderr(`[SERVER ERROR] ${err}`);
|
|
68
|
+
for (const err of list("client_errors"))
|
|
69
|
+
out.stderr(`[CLIENT ERROR] ${err}`);
|
|
70
|
+
}
|
|
71
|
+
/** Run one atomo command; returns the exit code. */
|
|
72
|
+
export async function runAtomo(client, argv, out) {
|
|
73
|
+
const [command, ...args] = argv;
|
|
74
|
+
try {
|
|
75
|
+
if (command === "run-lua") {
|
|
76
|
+
if (args.length < 1) {
|
|
77
|
+
out.stderr("Usage: atomo run-lua '<lua code>'");
|
|
78
|
+
return 2;
|
|
79
|
+
}
|
|
80
|
+
printRunLuaPayload(String((await client.runLua(args[0], "server")) ?? ""), out);
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
if (command === "run-lua-client") {
|
|
84
|
+
if (args.length < 1) {
|
|
85
|
+
out.stderr("Usage: atomo run-lua-client [client_id] '<lua code>'");
|
|
86
|
+
return 2;
|
|
87
|
+
}
|
|
88
|
+
// atomo's own optional leading integer client id
|
|
89
|
+
const withId = args.length >= 2 && /^\d+$/.test(args[0]);
|
|
90
|
+
const clientId = withId ? Number(args[0]) : undefined;
|
|
91
|
+
const code = withId ? args[1] : args[0];
|
|
92
|
+
printRunLuaPayload(String((await client.runLua(code, "client", clientId)) ?? ""), out);
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
if (command === "errors") {
|
|
96
|
+
printErrors(String((await client.engineErrors()) ?? ""), out);
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
if (err instanceof EngineTimeoutError) {
|
|
102
|
+
// atomo's wording for a bridge timeout, which callers treat as
|
|
103
|
+
// "outcome unknown: check, never resend".
|
|
104
|
+
out.stderr(`Error: bridge returned HTTP 504: ${err.message}`);
|
|
105
|
+
return 3;
|
|
106
|
+
}
|
|
107
|
+
out.stderr(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
const instead = command ? CLI_EQUIVALENTS[command] : undefined;
|
|
111
|
+
out.stderr(command
|
|
112
|
+
? `atomo ${command} is not available outside a Virtual Matter session.` +
|
|
113
|
+
(instead ? ` Use instead: ${instead}` : "")
|
|
114
|
+
: "Usage: atomo run-lua '<code>' | run-lua-client [client_id] '<code>' | errors");
|
|
115
|
+
return 2;
|
|
116
|
+
}
|
|
117
|
+
/** Single-quote a string for /bin/sh. */
|
|
118
|
+
function shQuote(value) {
|
|
119
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The `./atomo` wrapper for a pulled folder, or null on Windows: cmd.exe
|
|
123
|
+
* cannot carry the multi-line Lua the starters send, so there the CLI
|
|
124
|
+
* commands are the way in. The wrapper runs this CLI build when it still
|
|
125
|
+
* exists (an npx cache can be cleared) and falls back to npx.
|
|
126
|
+
*/
|
|
127
|
+
export function atomoWrapper(cliEntry, nodePath, platform = process.platform) {
|
|
128
|
+
if (platform === "win32")
|
|
129
|
+
return null;
|
|
130
|
+
const lines = [
|
|
131
|
+
"#!/bin/sh",
|
|
132
|
+
"# Written by the virtualmatter CLI: atomo's engine commands for this folder, served by the CLI.",
|
|
133
|
+
'DIR="$(cd "$(dirname "$0")" && pwd)"',
|
|
134
|
+
];
|
|
135
|
+
if (cliEntry) {
|
|
136
|
+
lines.push(`CLI=${shQuote(cliEntry)}`, `if [ -f "$CLI" ]; then exec ${shQuote(nodePath)} "$CLI" atomo --dir "$DIR" -- "$@"; fi`);
|
|
137
|
+
}
|
|
138
|
+
lines.push('exec npx -y virtualmatter atomo --dir "$DIR" -- "$@"', "");
|
|
139
|
+
return lines.join("\n");
|
|
140
|
+
}
|
|
141
|
+
/** Write `./atomo` into a pulled folder (executable). Returns the relative path written, if any. */
|
|
142
|
+
export function writeAtomoWrapper(dir) {
|
|
143
|
+
let entry;
|
|
144
|
+
try {
|
|
145
|
+
entry = process.argv[1] ? fs.realpathSync(process.argv[1]) : undefined;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
entry = undefined;
|
|
149
|
+
}
|
|
150
|
+
const script = atomoWrapper(entry, process.execPath);
|
|
151
|
+
if (script === null)
|
|
152
|
+
return null;
|
|
153
|
+
const target = path.join(dir, "atomo");
|
|
154
|
+
fs.writeFileSync(target, script, { mode: 0o755 });
|
|
155
|
+
fs.chmodSync(target, 0o755);
|
|
156
|
+
return "atomo";
|
|
157
|
+
}
|
package/dist/ignore.js
CHANGED
|
@@ -22,9 +22,9 @@ export function isIgnoredPath(relPath) {
|
|
|
22
22
|
if (norm.endsWith(".remote-conflict"))
|
|
23
23
|
return true;
|
|
24
24
|
// The SDK's in-session harness tooling at the Montage root. `atomo` only
|
|
25
|
-
// works against a running engine bridge, so
|
|
26
|
-
//
|
|
27
|
-
// both directions.
|
|
25
|
+
// works against a running engine bridge, so the world's copy is never
|
|
26
|
+
// mirrored; `pull` writes the CLI's own `./atomo` wrapper (atomo.ts) in its
|
|
27
|
+
// place. Sync leaves them alone in both directions.
|
|
28
28
|
if (segments.length === 1 && isSdkHarnessTooling(first))
|
|
29
29
|
return true;
|
|
30
30
|
return false;
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import { detectPlatform, ensureClientInstalled, launchClient, seedNativeAuth } f
|
|
|
11
11
|
import { apiBase, packageVersion } from "./config.js";
|
|
12
12
|
import { ENGINE_TIMEOUT_EXIT_CODE, EngineTimeoutError, FilesClient } from "./files.js";
|
|
13
13
|
import { runMcpServer } from "./mcp.js";
|
|
14
|
-
import {
|
|
14
|
+
import { runAtomo } from "./atomo.js";
|
|
15
|
+
import { pullCommand, refreshAgentFiles } from "./pull.js";
|
|
15
16
|
import { NeedsChoiceError, formatProjectList, makeFramingOf, resolveImplicitTarget, resolveTarget, } from "./resolve.js";
|
|
16
17
|
import { loadState, requireState } from "./state.js";
|
|
17
18
|
import { SyncEngine, runSyncLoop } from "./sync.js";
|
|
@@ -133,6 +134,9 @@ function reportPull(result, dest, watchUrl) {
|
|
|
133
134
|
if (files && files.written.length > 0) {
|
|
134
135
|
console.log(`Wrote ${files.written.join(", ")} so Claude Code, Codex, and Cursor find their way around.`);
|
|
135
136
|
}
|
|
137
|
+
if (result.skills && result.skills.mirrored.length > 0) {
|
|
138
|
+
console.log(`Copied ${result.skills.mirrored.length} skill packages into .claude/skills for Claude Code.`);
|
|
139
|
+
}
|
|
136
140
|
const rel = path.relative(process.cwd(), dest) || ".";
|
|
137
141
|
// A relative path is friendlier only while it stays short; a folder far
|
|
138
142
|
// from the cwd reads better as the absolute path it is.
|
|
@@ -306,7 +310,15 @@ program
|
|
|
306
310
|
const engine = new SyncEngine(client, abs, state);
|
|
307
311
|
console.log(`Syncing ${abs} with framing ${state.framing_id}. Ctrl-C to stop.`);
|
|
308
312
|
console.log(`Watch changes land live in any browser: ${editUrl(state.framing_id)}?chat=closed`);
|
|
309
|
-
await runSyncLoop(engine, abs
|
|
313
|
+
await runSyncLoop(engine, abs, {
|
|
314
|
+
onSkillsChanged: async () => {
|
|
315
|
+
const { skills } = await refreshAgentFiles(client, abs);
|
|
316
|
+
if (skills.mirrored.length > 0)
|
|
317
|
+
console.log(`skills: ${skills.mirrored.length} packages in .claude/skills`);
|
|
318
|
+
if (skills.removed.length > 0)
|
|
319
|
+
console.log(`skills: removed ${skills.removed.join(", ")} (the world withdrew them)`);
|
|
320
|
+
},
|
|
321
|
+
});
|
|
310
322
|
}));
|
|
311
323
|
program
|
|
312
324
|
.command("run-lua")
|
|
@@ -327,6 +339,18 @@ program
|
|
|
327
339
|
const result = await client.runLua(opts.code, opts.target, clientId);
|
|
328
340
|
console.log(JSON.stringify({ result }, null, 2));
|
|
329
341
|
}));
|
|
342
|
+
program
|
|
343
|
+
.command("atomo")
|
|
344
|
+
.description("The engine SDK's atomo commands for a synced folder (run-lua, run-lua-client, errors), in atomo's output format; the ./atomo that pull writes calls this. Put -- before the command so Lua code starting with - is not read as an option")
|
|
345
|
+
.option("--dir <dir>", "a synced folder", ".")
|
|
346
|
+
.argument("[args...]", "an atomo command and its arguments")
|
|
347
|
+
.action((args, opts) => run(async () => {
|
|
348
|
+
const { client } = await clientForDir(path.resolve(opts.dir));
|
|
349
|
+
process.exitCode = await runAtomo(client, args, {
|
|
350
|
+
stdout: (line) => console.log(line),
|
|
351
|
+
stderr: (line) => console.error(line),
|
|
352
|
+
});
|
|
353
|
+
}));
|
|
330
354
|
program
|
|
331
355
|
.command("errors")
|
|
332
356
|
.description("Show recent engine errors")
|
package/dist/pull.js
CHANGED
|
@@ -3,6 +3,8 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { resolveEditSession, sessionBaseUrl } from "./api.js";
|
|
5
5
|
import { composeAgentsMd, fetchAgentsMd, writeAgentFiles } from "./agentfiles.js";
|
|
6
|
+
import { writeAtomoWrapper } from "./atomo.js";
|
|
7
|
+
import { mirrorSkills, skillsActive } from "./skills.js";
|
|
6
8
|
import { FilesClient } from "./files.js";
|
|
7
9
|
import { isIgnoredPath } from "./ignore.js";
|
|
8
10
|
import { adoptLocal, saveState } from "./state.js";
|
|
@@ -89,7 +91,21 @@ export async function pullCommand(framingId, dir) {
|
|
|
89
91
|
const client = new FilesClient(sessionBaseUrl(session), editFramingId);
|
|
90
92
|
console.log(`Session ready at ${sessionBaseUrl(session)}. Downloading files ...`);
|
|
91
93
|
const result = await pullTree(client, dir, editFramingId);
|
|
92
|
-
|
|
93
|
-
result.agentFiles = writeAgentFiles(dir, composeAgentsMd(platformDoc, engineDoc));
|
|
94
|
+
Object.assign(result, await refreshAgentFiles(client, dir));
|
|
94
95
|
return result;
|
|
95
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The harness files that follow the world: AGENTS.md (the platform guide plus
|
|
99
|
+
* the world's own), the `./atomo` wrapper, and the `.claude/skills` copies of
|
|
100
|
+
* the platform's skill packages. Run after a pull, and by sync whenever the
|
|
101
|
+
* world's `Skills/` changes, which is how a skills install or withdrawal
|
|
102
|
+
* shows up.
|
|
103
|
+
*/
|
|
104
|
+
export async function refreshAgentFiles(client, dir) {
|
|
105
|
+
const [platformDoc, engineDoc] = await Promise.all([fetchAgentsMd(), fetchEngineAgentsMd(client)]);
|
|
106
|
+
const agentFiles = writeAgentFiles(dir, composeAgentsMd(platformDoc, engineDoc));
|
|
107
|
+
const wrapper = writeAtomoWrapper(dir);
|
|
108
|
+
if (wrapper)
|
|
109
|
+
agentFiles.written.push(wrapper);
|
|
110
|
+
return { agentFiles, skills: mirrorSkills(dir, skillsActive(engineDoc)) };
|
|
111
|
+
}
|
package/dist/skills.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform's agent skills, for a harness on the maker's machine.
|
|
3
|
+
*
|
|
4
|
+
* Inside a session the platform installs partner skill packages
|
|
5
|
+
* (`Skills/atomontage-*`) into the world and routes its agent to them from a
|
|
6
|
+
* managed block in the world's AGENTS.md. The packages reach a pulled folder
|
|
7
|
+
* like any other world file, but Claude Code discovers skills only under
|
|
8
|
+
* `.claude/skills/`, a dot-folder sync never mirrors. So the CLI copies each
|
|
9
|
+
* installed package there while the world's routing block is present, and
|
|
10
|
+
* removes its copies once the platform withdraws them (rollout 0, or an
|
|
11
|
+
* engine the packages do not support). The block is the signal, not the
|
|
12
|
+
* folders: those stay in the world after a withdrawal because games built
|
|
13
|
+
* from the starters attach their scripts by path.
|
|
14
|
+
*/
|
|
15
|
+
import fs from "node:fs";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
export const ROUTING_BEGIN = "<!-- BEGIN MANAGED ATOMONTAGE SKILLS ROUTING -->";
|
|
18
|
+
const PACKAGE_PREFIX = "atomontage-";
|
|
19
|
+
const MIRROR_ROOT = path.join(".claude", "skills");
|
|
20
|
+
/** Marks a `.claude/skills` entry as the CLI's copy; a maker's own skill of the same name is never touched. */
|
|
21
|
+
export const MIRROR_MARKER = ".virtualmatter-mirror";
|
|
22
|
+
/** True when the world's own AGENTS.md routes its agent to the packages. */
|
|
23
|
+
export function skillsActive(engineAgentsMd) {
|
|
24
|
+
return engineAgentsMd !== null && engineAgentsMd.includes(ROUTING_BEGIN);
|
|
25
|
+
}
|
|
26
|
+
/** The skill packages present in the folder's `Skills/`, sorted. */
|
|
27
|
+
export function installedPackages(dir) {
|
|
28
|
+
const root = path.join(dir, "Skills");
|
|
29
|
+
let names;
|
|
30
|
+
try {
|
|
31
|
+
names = fs.readdirSync(root);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return names
|
|
37
|
+
.filter((name) => name.startsWith(PACKAGE_PREFIX) && fs.existsSync(path.join(root, name, "SKILL.md")))
|
|
38
|
+
.sort();
|
|
39
|
+
}
|
|
40
|
+
/** Bring `.claude/skills/` in line with the world's packages; never touches an entry the CLI did not write. */
|
|
41
|
+
export function mirrorSkills(dir, active) {
|
|
42
|
+
const root = path.join(dir, MIRROR_ROOT);
|
|
43
|
+
const wanted = active ? installedPackages(dir) : [];
|
|
44
|
+
const ours = (name) => fs.existsSync(path.join(root, name, MIRROR_MARKER));
|
|
45
|
+
const result = { mirrored: [], removed: [] };
|
|
46
|
+
let existing = [];
|
|
47
|
+
try {
|
|
48
|
+
existing = fs.readdirSync(root);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
/* nothing mirrored yet */
|
|
52
|
+
}
|
|
53
|
+
for (const name of existing) {
|
|
54
|
+
if (wanted.includes(name) || !ours(name))
|
|
55
|
+
continue;
|
|
56
|
+
fs.rmSync(path.join(root, name), { recursive: true, force: true });
|
|
57
|
+
result.removed.push(name);
|
|
58
|
+
}
|
|
59
|
+
for (const name of wanted) {
|
|
60
|
+
const target = path.join(root, name);
|
|
61
|
+
if (fs.existsSync(target) && !ours(name))
|
|
62
|
+
continue;
|
|
63
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
64
|
+
fs.cpSync(path.join(dir, "Skills", name), target, {
|
|
65
|
+
recursive: true,
|
|
66
|
+
// .zma files are the engine's asset records, not part of the skill
|
|
67
|
+
filter: (src) => !src.endsWith(".zma"),
|
|
68
|
+
});
|
|
69
|
+
fs.writeFileSync(path.join(target, MIRROR_MARKER), `Copied by the virtualmatter CLI from Skills/${name} and refreshed on pull and sync.\n`);
|
|
70
|
+
result.mirrored.push(name);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
package/dist/sync.js
CHANGED
|
@@ -417,13 +417,27 @@ export class SyncEngine {
|
|
|
417
417
|
return pushed;
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
/** True when any of these pulled paths can change the world's agent skills. */
|
|
421
|
+
export function touchesSkills(paths) {
|
|
422
|
+
return paths.some((p) => p.replace(/\\/g, "/").startsWith("Skills/"));
|
|
423
|
+
}
|
|
420
424
|
/** Run the full watch loop until SIGINT. Not unit-tested directly; the decisions above are. */
|
|
421
|
-
export async function runSyncLoop(engine, dir) {
|
|
425
|
+
export async function runSyncLoop(engine, dir, opts = {}) {
|
|
422
426
|
const { default: chokidar } = await import("chokidar");
|
|
423
427
|
const { pulled, pushed, conflicts } = await engine.initialSync();
|
|
424
428
|
console.log(`initial sync: ${pulled} pulled, ${pushed} pushed` +
|
|
425
429
|
(conflicts ? `, ${conflicts} conflict${conflicts === 1 ? "" : "s"} (see above)` : "") +
|
|
426
430
|
`. Watching ${dir} ...`);
|
|
431
|
+
const refreshSkills = async () => {
|
|
432
|
+
try {
|
|
433
|
+
await opts.onSkillsChanged?.();
|
|
434
|
+
}
|
|
435
|
+
catch (err) {
|
|
436
|
+
console.warn(`agent files refresh failed: ${String(err)}`);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
// The world may have gained or lost its skills since the last pull.
|
|
440
|
+
await refreshSkills();
|
|
427
441
|
const stopLogs = startLogSync(dir);
|
|
428
442
|
const watcher = chokidar.watch(dir, {
|
|
429
443
|
ignoreInitial: true,
|
|
@@ -452,7 +466,8 @@ export async function runSyncLoop(engine, dir) {
|
|
|
452
466
|
console.warn(`local scan failed: ${String(err)}`);
|
|
453
467
|
}
|
|
454
468
|
try {
|
|
455
|
-
await engine.pollOnce()
|
|
469
|
+
if (touchesSkills(await engine.pollOnce()))
|
|
470
|
+
await refreshSkills();
|
|
456
471
|
}
|
|
457
472
|
catch (err) {
|
|
458
473
|
console.warn(`remote poll failed: ${String(err)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtualmatter",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "CLI + MCP server for building with Virtual Matter - list and create worlds, sync their files, run Lua, capture screenshots, open the native client, and wire coding agents into a live session.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|