Skip to content

Development

Mehrdad Pajuhaan edited this page Nov 30, 2026 · 1 revision

Development

Robot Studio is written in TypeScript: an Electron desktop shell, a Node server that owns the project, and a React interface. This page is a map for people who want to read or change the code.

Read AGENTS.md first. It is the entry point for human and AI contributors alike, and its links lead to the architecture, engineering standards and status of each part of the studio.

Repository map

Path What it holds
src/core/ The pure typed model: project types, commands (the only way the project changes), checks and engineering logic. No Electron, DOM or Node APIs; three.js only for maths.
src/server/ Node only. Owns the live project: saving the package, undo and redo, the MCP server (src/server/mcp/, http.ts), background jobs and the engines (solid kernel, physics, KiCad, slicers, firmware, AI runtime).
src/main/ The Electron shell: starts the server, opens the windows, native dialogs.
src/renderer/ The React interface, a client of the server over WebSocket (src/renderer/src/state/api.ts). It holds no authority.
eda/ The EDA core's own package folder: the pinned tscircuit set.
runtimes/onnx/ ONNX Runtime, pinned, for running AI models.
addons/ The official add-ons (Bambu Lab, OrcaSlicer, Isaac Lab).
library/ The standard libraries: board components, bearings, fasteners.
samples/ The sample robots as project packages, written by npm run samples.
scripts/ Development, sandbox, sample, MCP check and library import scripts.
native/pns/ Source and build scripts of the native KiCad router helper.
third_party/ Notices and licences of third-party code and data.
docs/ The project format standard, plans, verification records and the detailed agent guidance.
spikes/ Experiments kept for reference.

.tools/ is a local, uncommitted folder for tool caches and sandbox builds.

How it fits together

  • One model. Every place (Robot, Schematic, PCB …) is a view of one typed project. Every edit is a command, and the window and MCP share the same validated commands, checks and undo history.
  • The server owns the project. The interface sends commands and re-renders when the server broadcasts the new project. The same interface runs in the Electron window and in a browser at http://localhost:5173.
  • MCP is stateless Streamable HTTP on 127.0.0.1 only, with Host and Origin checks. /mcp is the full profile and /mcp/compact the compact one, both built from the same tool registry.
  • Conventions. Millimetres and degrees; Z up, right-handed; Euler XYZ rotations; part ids are reference designators that never change; pins are PART.PIN and ports PART.PORT.

Useful commands

Command What it does
npm run dev Start the app with live reload
npm start Build and launch a production preview
npm run build Production build into out/
npm run typecheck Type-check everything
npm test Headless tests: core logic, engines and MCP end-to-end runs on private servers
npm run sandbox A second, isolated app window with its own data folder and MCP on port 7811
npm run sandbox:web An isolated backend for the web UI, no window (keep npm run dev running); MCP on port 7831 by default
npm run samples Write the sample packages in samples/ from the code that builds them (npm run samples -- tripod-t2 for one)
npm run mcp:smoke Read-only end-to-end check of the MCP server; the app must be running
node scripts/mcp-call.mjs <tool> [json] Call one MCP tool from the shell
npm run addons Seal the addons/ folder after changing an add-on
npm run library:footprints, npm run library:fasteners Regenerate library data from their sources

npm run mcp:smoke -- --demo also builds a demo robot in a new project, which switches the running app to it. Run it only against a sandbox:

$env:ROBOT_STUDIO_MCP = "http://127.0.0.1:7811/mcp"; npm run mcp:smoke -- --demo

ROBOT_STUDIO_DATA_DIR and ROBOT_STUDIO_PORT choose the data folder and port of an instance; the sandboxes set them for you.

Tests

npm test runs Vitest over src/**/*.test.ts(x). The tests run on temporary data folders and private servers and never touch the running app or your projects. Tests that need a program such as KiCad skip themselves when it is not installed. To run one file:

npm test -- src/server/mcp/compact.e2e.test.ts

The Hexapod H1 sample is rebuilt and checked whole on every run, so it is also what the software is debugged against.

Adding a capability

Follow the existing path of its domain instead of inventing a new one:

  1. the typed model in src/core and backwards-compatible normalization;
  2. a validated command;
  3. the MCP tool, in the matching file of src/server/mcp/;
  4. the window;
  5. diagnostics, so problems reach both the window and agents;
  6. persistence in the project package (src/core/package/pack.ts is the single layout writer);
  7. a test.

Keep expensive work in cancellable background jobs. Keep existing MCP tool names and saved project ids stable: saved projects and agents depend on them. When a feature can return large results, return a summary first and let the agent fetch detail by id, query or page.

Contributing

  • Report bugs and ideas in Issues. Pull requests are welcome.
  • Before opening a pull request, run npm run typecheck and the tests your change affects. New logic needs a test.
  • Check interface changes in the real app, in both the light and the dark theme. Use a sandbox so your own projects are not touched.
  • After changing the sample robots' code, the catalog parts they use or the package layout, run npm run samples and commit what it wrote.
  • Catalog and manufacturing data must come from standards, datasheets or measurable geometry. Say what is assumed.

Licence

Robot Studio is free software under the GNU Affero General Public License v3.0 or later. Its third-party code, libraries and models keep their own licences, listed with their notices in third_party/. The KiCad-derived router helper in native/pns and third_party/kicad-pns is GPL-3.0-or-later. See External Programs and Add-ons for the full list.

Clone this wiki locally