Skip to content
ZOGWORKPublic
forked from GrowlyX/mantis

About

Agentic Hardware IDE

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

37 Commits

Folders and files

Repository files navigation

Mantis

Describe a circuit board in plain words, watch it take shape in 3D, and export a package you can order from PCBWay.

Mantis is a native Mac app built entirely in Rust on GPUI. Projects are listed down the left, the conversation is in the middle and the live board is on the right, where you can click any part, pad or track to ask about it.

Layout

Crate What it does
mantis-core Board IR in integer nanometres, KiCad and EasyEDA footprint importers, part library, circuit blocks, auto-placer, two-layer autorouter, enclosures derived from the board (case, button caps, custom parts drawn as stacked prisms), wire physics, verification tiers
mantis-fab Gerber X2, Excellon, PCBWay BOM and centroid files, order sheet, live LCSC price and stock, any-part import
mantis-cad Programmatic CAD: a JavaScript modelling API on the OpenCascade kernel (booleans, fillets, chamfers, shells, lofts, sweeps, revolves, STEP), run in a worker process
mantis-sim Gravity test: every piece, screw and off-board item as a rigid body, joined only where a thread, a plug or a stated fixing joins them
mantis-render 3D renderer with per-pixel picking: Metal on macOS, with a CPU rasteriser as fallback and reference; runs headless
mantis-agent Claude Opus 5.5 design agent through aisdk, with typed board tools. Every turn is streamed: the reply, the model's summary of its reasoning and each tool call arrive as they are written
mantis-app The GPUI app. Its window follows the Breezy workspace: a rail of projects, the conversation in a column with its composer docked under it, and the board in a panel that can be resized, filled or put away. The conversation and the rail are drawn here, in workspace/thread.rs and workspace/sidebar.rs, at the sizes and timings of the Breezy web app; menus, dialogs, tabs, tables and toasts come from the Mantis UI kit (GrowlyX/mantis-ui, pinned by commit in crates/mantis-app/Cargo.toml)
mantis-design The design format: parameters and expressions, feature trees, assemblies with joints and links, kinematics, involute gears, URDF/MJCF export, files and diffs
mantis-store Where everything that outlives the window is kept: projects, each one's design and conversation, the trace of every turn, the agent's memory and each project's workspace files. One contract (Api), a SQLite store behind it, an HTTP server in front of that, and the client the app uses. Also builds mantis-server, the same server as a program of its own
mantis-cli The same pipeline without a window, on .mantis folders

Run

cargo run --release -p mantis-app            # opens the project that was open last
cargo run --release -p mantis-app -- my.mantis   # brings a .mantis folder in as a project and opens it
scripts/bundle.sh                            # builds target/Mantis.app, with its icon
scripts/make-icon.sh <tile.png>              # remakes assets/Mantis.icns from the brand kit's icon tile
scripts/install-remote.sh <ssh host>         # installs it on another Mac

Building needs CMake and a C++17 compiler (brew install cmake). The first build compiles OpenCascade 8.0.1 from its official sources, which takes a few minutes; the result is kept in .occt/ so cargo clean does not discard it. OpenCascade is LGPL-2.1 with an exception and is linked statically, which matters if the app is ever distributed.

The agent runs through the coding agent you already use, on the plan you are signed in to there, the way T3 Code does: Claude Code, OpenAI's Codex or Meta's Muse Code. Each turn drives that program on the conversation's own session, and the app serves its board tools to it over MCP on a loopback port, so every call acts on the live design. Mantis passes its own instructions and tools only, with none of your settings, hooks, plugins or MCP servers. Without any of them it calls Anthropic's API directly: set ANTHROPIC_API_KEY, or paste a key into the composer on first launch.

The model picker in the composer lists every provider down its left side, their models in the middle (searchable, with favourites) and the chosen model's reasoning efforts on the right. Each conversation keeps its own model; moving a conversation to another provider hands that provider what was said so far. MANTIS_CLAUDE/claude_path, MANTIS_CODEX/codex_path and MANTIS_MUSE/muse_path point at programs that are not in the usual places.

mantis-cli demo board.mantis                 # build and route the reference board
mantis-cli check board.mantis                # run every verification tier
mantis-cli export board.mantis out/          # write the PCBWay package
mantis-cli part C25744                       # import any LCSC part and print its pins
mantis-cli chat board.mantis "add a status LED on IO10"

Where things are kept

The app keeps nothing in files of its own. Projects, designs, conversations, traces, memory and workspace files all go through the store's HTTP API (mantis-store), and the app holds only a client of it.

  • By default the app starts the store itself, listening only on this machine with a token made for that run, on a SQLite file at ~/Library/Application Support/Mantis/mantis.db.
  • To use a store hosted elsewhere, set MANTIS_STORE_URL and MANTIS_STORE_TOKEN. Nothing else changes. mantis-server --db <file> --listen <address:port> is that store as its own program; it reads its token from MANTIS_STORE_TOKEN, refuses to listen beyond this machine without one, and speaks plain HTTP, so put it behind something that terminates TLS.
  • Nothing in the window waits for the store. Reads happen on background threads and writes go through a queue, where a newer save of the same design replaces one not yet sent. The queue is emptied before the app quits.
  • Project folders from earlier builds are brought in once. Every ~/Mantis/*.mantis folder becomes a project on first launch, with its conversation; the folders are left as they were and are not written to again. Exported PCBWay packages are still written to ~/Mantis/<project>-pcbway, and the Gerber zip is also put in the project's workspace under exports/.

What a project holds:

Design The board, whole, with its operation log. Each save is a new revision number
Conversation The turns as the window shows them
Trace Every event of every turn as it happened: what was sent, text, thinking, each tool call with its arguments and what it returned. It only grows. GET /v1/projects/<id>/trace reads it
Memory Short notes the agent keeps with remember and forget, for this project or for everywhere. They are given to it at the start of each turn, and listed in the Memory tab, where each can be removed
Workspace Files kept with the project, which the agent reads and writes with list_files, read_file, write_file and delete_file: notes under notes/, firmware sources under firmware/. Listed in the Files tab; pressing one opens a copy

Firmware is not built yet. The workspace is where its sources will live, so a firmware toolchain can be added as tools over the same files.

While a turn runs

A message written while a turn runs is not lost and does not stop the turn. It joins a queue shown in the chat box, where each waiting message can be removed or steered:

  • Left in the queue, it is sent as a turn of its own when the running one ends. A turn stopped by hand does not start the next by itself; the queued message shows Send instead.
  • Steered, it is handed to the turn that is running. The model reads it at the start of its next step, between one round of tool calls and the next, and it takes its place in the conversation there. If the turn ends before another step, it goes back to the head of the queue.

A conversation that has grown past 180,000 tokens (MANTIS_COMPACT_AT changes that) is summarized by the model before the next turn, and the agent carries on from the summary and the board. The transcript keeps everything and marks where it happened; typing /compact does it at once.

Looking at the app without sitting at it

A snapshot run opens the app in a given state, optionally presses things, writes a picture and quits. Its window stays behind whatever is in use and does not take the keyboard.

MANTIS_SNAPSHOT=out.png MANTIS_STATE=theme=light,tab=parts,chat=sample mantis board.mantis
MANTIS_SNAPSHOT=out.png MANTIS_DO='rclick@SW4;item@2' MANTIS_SIZE=900x600 mantis board.mantis

MANTIS_STATE takes theme=light|dark, tab=parts|model|files|memory, select=REF or select=piece:<part name>, key=none|bad, upload=1, toast=1, gravity=N, mode=copper, sidebar=collapsed, board=hidden|wide|<width>, search=<text>, rename=1, delete=1, draft=<text>, queue=<first>|<second> and chat= one of sample, open, empty, failed, compacted, or a turn under way: waiting, thinking, calling, writing. A run with MANTIS_STATE or MANTIS_SNAPSHOT set does not save the window's layout or rename a project, but ask= does run a real turn and keep it. To keep a test run away from real projects altogether, give it a home folder of its own (HOME=/tmp/somewhere mantis ...): the store, the project folders it brings in and the saved key are all found under it. MANTIS_STATE is split at commas, so an ask= cannot contain one. hold=<ms> holds the design for that long, a second in, as a slow tool would.

A snapshot run also prints how the interface thread fared: its longest stall, how many frames were built and the slowest of them. A stall of about a second with nothing else slow is macOS making a hidden window wait for a drawable, not the app.

What runs where

The window never waits for the design. A tool can hold the design session for seconds, so every change publishes a snapshot (mantis_agent::Snapshot) and the interface reads that. From each snapshot the checks, the gravity test, the parts to buy and the CAD parts are worked out on a background thread, and the 3D view is built and drawn on a render thread (viewport.rs) that always takes the newest frame asked for. The window's three columns are separate views (workspace/panes.rs), so a shimmering label or streaming text redraws only the column it is in, at thirty frames a second. MANTIS_DO takes steps separated by ;: click@x,y and rclick@x,y in points from the top left of the content, rclick@REF on a component, item@n for the nth row of the menu that opened, and wait@ms. If the pictures come back black, the display is asleep: caffeinate -d -u -t 600.

Mechanical parts are programs

Enclosures, lids, button caps, knobs and every other mechanical part are drawn by a JavaScript program stored with the board. The agent writes it through one tool, cad, which runs the program, reports what the kernel measured (sizes, volumes, parts that share space, what each screw holds), runs the gravity test, and returns rendered views so the agent can see its own work and revise. The program reads the board, so the parts follow it when it changes, and it declares its design dimensions as parameters that can be changed in the app's Model tab without calling the model.

mantis-cli cad board.mantis case.js --views out/   # run a program, save pictures of the result
mantis-cli tool board.mantis cad '{"action":"reference"}'   # the modelling API and a worked example

crates/mantis-cad/src/prelude.js is the whole modelling API and example.js a complete, tested case. Each part is exported as STL and STEP.

Materials and colours

part() takes a material and a colour. The materials the app knows are listed in mantis_core::mech::MATERIALS: printed plastics (PLA, PETG, ABS, ASA, TPU, resin, nylon PA12), milled metals (aluminium 6061, anodized aluminium, stainless steel, brass), and laser-cut acrylic and plywood. Each says how it is made and how it looks, so aluminium is drawn as metal, acrylic as glossy and clear, and plywood as wood. A colour is a name ("black", "dark blue", "clear") or #rrggbb; bare metal and wood are their own colour whatever is written.

Selecting a part of the case in the app shows a menu of materials and a row of colours. A choice there is kept with the board under finishes, wins over what the program says, and does not run the program again; "As drawn" goes back. The agent sees those choices in get_board, and the order sheet and exported files carry them.

Stickers

A program can stick a printed label to the outside of any part with sticker(): its artwork is a React component written in JSX, and <Icon name="..."> draws any of the 4,964 Tabler icons. The label takes the shape of the surface it is laid on, so it wraps a curved lid, and only the nearest surface under it is covered.

sticker("Port", { on: "Tray", facing: "front", at: [20, -4], size: [24, 6], render: ({ width, height }) => (
  <svg viewBox={`0 0 ${width} ${height}`}>
    <rect width={width} height={height} rx={1.5} fill="#111" />
    <Icon name="usb" x={1} y={1} size={4} color="#fff" />
    <text x={6} y={4.2} fontSize={3} fill="#fff">USB-C 5 V</text>
  </svg>
) });

The JSX runs inside the CAD engine with React 19's static renderer and sucrase, bundled into crates/mantis-cad/src/stickers.js and loaded only for programs that make stickers; scripts/make-sticker-runtime.sh rebuilds it and the icon data, and crates/mantis-cad/assets/NOTICE carries their licences. The SVG is drawn with resvg and the system's fonts and laid on the part by both renderers. Each sticker's artwork goes into the order package beside the part, at its printed size, and onto the list of things to buy.

vendor/aisdk is aisdk 0.6.14 with a few patches; see vendor/aisdk/MANTIS.md.

Parametric design: parts, assemblies and robots

Beside CAD programs, a product can have a design in the Mantis design format (crates/mantis-design): parameters, parts and an assembly, the platform Mantis's own parametric CAD grows on. It is how robots, gearboxes and mechanisms are made.

  • Parameters and expressions. Any number may be "=expression" over named parameters, with units (mm, cm, m, in, deg, rad, turn) and functions, so one change moves the whole design.
  • Parts are feature trees, built in order on the OpenCascade kernel in the crash-safe CAD worker: sketches (shapes drawn directly, or points, curves and constraints solved by the sketch constraint solver; closed regions with holes are found automatically), extrude (distance, symmetric, through), revolve, sweep (helix, sketch path, points), loft, hole (counterbore, countersink, thread callout), fillet, chamfer, shell, primitive, involute gear (spur, helical, internal, profile shift, backlash), rack, bevel gear, worm and worm wheel, timing pulley and belt, sheet metal (flanges, hems, reliefs, flat pattern), pattern (linear, circular) and mirror of earlier features, and move. A feature that fails names itself and the part shows as built up to it. Parts are cached by their resolved features, so a change rebuilds only the parts it touches.
  • Assemblies place occurrences of parts and of the board, connected by joints (rigid, revolute, slider, cylindrical, ball, planar) with limits, effort and speed. Links tie joints together: gear pairs, rack and pinion, belts, bevel and worm drives, lead screws, any ratio. Passive joints are solved so linkages close (four-bars, slider-cranks). Driving a joint poses the parts without rebuilding them, and parts that run into each other are reported.
  • Gears mesh. mesh_gears sets the exact centre distance from the gear geometry (including profile-shifted pairs), and finds the ratio's direction and the tooth phase by posing the real tooth outlines through a tooth's worth of turning.
  • Robots export to URDF and MJCF with a binary STL per link, masses and inertia from each part's volume and material, link frames on the joint axes, gear and screw couplings as mimic (URDF) and equality constraints (MJCF).
  • Versions. A design is files (mantis.json, parts/<id>.json, assemblies/<id>.json, pcbs/main.json, programs/case.js), pretty-printed with sorted keys so a change touches only its lines. The store keeps versions of them (each file's contents stored once, by hash); diff reads as engineering changes ("features f1.r: 2 → 3"), and checkout brings a version back as one undoable step. export {format: "files"} writes the folder for git.

In the app, the board panel's Design tab is the CAD browser and inspector: parameters, parts and their feature timelines, the assembly, versions, with values edited in place, joints driven by sliders and features added from a menu.

The agent drives all of it through one design tool; crates/mantis-agent/src/design_reference.md is the reference it reads. From the command line, mantis-cli tool board.mantis design '{"action": "get"}' runs any of its actions.

The roadmap for rebuilding SolidCraft's capabilities natively is in docs/cad-roadmap.md.

Research

The agent settles what a part's own data leaves open instead of handing it to you to check. web_search finds the full datasheet, the manufacturer's hardware design guide, a reference design or an application note; read_url reads a page, a PDF or a picture. A PDF can be searched with find, and chosen pages (pages, up to six at once) are shown to the model as printed, so pinout drawings, tables and package outlines are read as they are. read_datasheet does the same for the datasheet the distributor links. Distributor links that open a PDF viewer are followed to the PDF behind them. Downloaded PDFs are cached in ~/Library/Caches/Mantis/documents.

Search goes through Exa when there is a key: set EXA_API_KEY, or send /exa <key> in the composer, which keeps it as exa_api_key in ~/.config/mantis/config.json. Without one, search runs through Claude Code's own WebSearch, or through the model provider's web search in a request of its own when the agent uses the API.

mantis-cli tool board.mantis web_search '{"query":"Quectel L86 hardware design guide"}'
mantis-cli tool board.mantis read_url '{"url":"https://…/L86_Hardware_Design.pdf","pages":"14-15"}' --views out/   # saves the pages as out/pages.pdf

What the checks mean

Eight tiers run on every change, and export is blocked while any error is unwaived. Tiers 1 and 2 are exact checks of stored data. Tiers 3 to 7 are rules and arithmetic against part data, PCBWay's published limits and the enclosure's fit. No circuit is simulated, so a passing board is manufacturable as drawn, not proven to work.

Tier 8, fastening, is a rigid-body simulation: the assembled product is turned six ways up under gravity and anything that moves out of place is reported. It covers gravity only, not shock, vibration or the strength of tape and glue.

Parts and prices

PCBWay has no parts catalogue: its assembly service sources each BOM line by manufacturer part number. Mantis therefore uses distributor data. Any LCSC part can be imported with its footprint and pin table from the EasyEDA library, and price ladders and stock come from LCSC's product pages. Both endpoints are public but unofficial.

Known limits

  • Two copper layers, no copper pours, no impedance control or length matching.
  • Imported parts are drawn as plain blocks in 3D, and their pin roles are inferred from pin names unless corrected.
  • No BSP generation or simulation yet.

Vendored KiCad footprints in assets/kicad are CC-BY-SA 4.0; see the note there.

About

Agentic Hardware IDE

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages