Skip to content

nimbalyst/nimbalyst-electronics

Repository files navigation

Electronics Studio — Nimbalyst extension

com.nimbalyst.electronics

PCB & controller design for makers and hardware engineers, inside Nimbalyst: design → simulate → test → manufacture-export. Powered by tscircuit with Circuit JSON as the on-disk, version-controllable, AI-mutable source of truth.

The differentiator is that the agent operates the whole loop — it places parts, wires nets, lints, simulates, tests firmware, estimates cost, and exports a fab bundle by driving the live editor through a small registered API.

What works today

  • Two file types
    • *.circuit.tsx — tscircuit React/TSX code (the source of truth)
    • *.circuit.json — raw Circuit JSON (render-only projection)
  • Live render of schematic + PCB via tscircuit's circuit-to-svg (pan with drag, zoom with the wheel, double-click to reset).
  • Hybrid authoring — a parts palette (MCUs, motor drivers, motors, sensors, inputs, outputs, passives, connectors) inserts parts into the .tsx; a code view edits it directly. .tsx is evaluated to Circuit JSON in a tscircuit Web Worker.
  • ERC-style lint — missing current-limit resistor, missing decoupling cap, unconnected pins.
  • Simulation across three engines:
    • logical — fast interactive state model (which LEDs light, is a chip powered).
    • analog — SPICE node-voltage traces (e.g. "the 3.3V rail sags to 2.9V").
    • mcu — runs the actual firmware on avr8js / rp2040js: GPIO traces + serial output.
  • Firmware test harness — run a sketch on the emulated MCU and assert on its behaviour (serial output, GPIO toggles/frequency, LED state) for a pass/fail report.
  • Cost estimate — an offline prototype-pricing estimate (PCB + optional SMT assembly) from board area, layer count, and quantity. Not a live vendor quote.
  • Manufacture export — writes a vendor-agnostic bundle next to the file: Gerber X2 (all layers) + Excellon drill + BOM (with JLCPCB part numbers) + pick-and-place CSV + a README. Zip it and upload to any fab.
  • Enclosure export — a parametric OpenSCAD box sized to the board (PCB standoffs + connector cutouts), handed off to the OpenSCAD / three-d extensions for STL/STEP.
  • AI tools (the agent operates the loop): electronics.list_nets, electronics.add_part, electronics.connect, electronics.lint, electronics.simulate, electronics.test, electronics.quote, electronics.export_fab, electronics.export_enclosure.

Not yet built: direct fab-API ordering (live quoting/ordering needs vendor credentials and is intentionally not automated).

Architecture (and why it is the way it is)

The renderer realm uses the host's React 18, but tscircuit's React components are coupled to React 19. So:

  • Rendering uses circuit-to-svg (a plain SVG string, no React) — not the @tscircuit/schematic-viewer / pcb-viewer components, which crash under React 18.
  • .tsx → Circuit JSON evaluation runs in a tscircuit Web Worker (@tscircuit/eval/worker), a separate JS realm with its own React fetched from the tscircuit CDN on first use — no host-React conflict, and it keeps the heavy evaluator out of the extension bundle.
  • The extension ships as a single dist/index.js (the host loads it from a blob: URL, which can't resolve sibling chunks); only react/react-dom are externalized.
  • An optional firmware backend module (dist/backend.js, utility-process) builds firmware with your installed arduino-cli / PlatformIO and runs ESP32 firmware under QEMU. It is disabled by default and prompts on first use.
src/
  index.tsx              extension entry (components + aiTools + activate)
  aiTools.ts             AI tools, driving the editor via context.editorAPI
  editorApi.ts           the imperative API the editor registers for tools
  backend.ts             optional firmware build / ESP32-QEMU backend module
  nimbalyst-sdk.d.ts     local type stubs for @nimbalyst/extension-sdk
  components/
    ElectronicsEditor.tsx  the custom editor (host integration, tabs, status)
    CircuitViews.tsx       schematic/PCB SVG panes (circuit-to-svg + pan/zoom)
    PartsPalette.tsx       click-to-insert parts catalog
    SimulationPanel.tsx    run simulations and inspect results
    Scope.tsx              waveform/trace viewer
  circuit/
    circuitJson.ts         parse + query (components, nets) + lint
    tscircuitCode.ts       part catalog + .tsx authoring helpers
    evalCode.ts            .tsx -> Circuit JSON via the eval Web Worker
    fab.ts                 Gerber/Excellon/BOM/pick-and-place export
  fab/
    board.ts               board geometry helpers
    quote.ts               offline cost estimate
    enclosure.ts           parametric OpenSCAD enclosure
  sim/
    simulate.ts            engine dispatch (logical / analog / mcu)
    logicalSim.ts          interactive state model
    analogSim.ts           SPICE (ngspice) analog simulation
    mcuSim.ts              MCU firmware emulation orchestration
    avrRunner.ts           avr8js runner
    rp2040Runner.ts        rp2040js runner
    testHarness.ts         behavioural assertions for firmware tests
    netlist.ts, detect.ts, intelHex.ts, types.ts  support

Develop

npm install
npm run build      # produces dist/index.js + dist/index.css + dist/backend.js
npm run dev        # rebuild on change

Install into a running Nimbalyst dev build via the extension-dev MCP tools (extension_install with this directory), or through the app's extensions panel.

Try the examples in examples/: blinky.circuit.tsx (code, live-evaluated), blinky.circuit.json (Circuit JSON, rendered directly), and rc-filter.circuit.tsx (an analog circuit for the SPICE engine).

Contributing

Contributions are welcome — see CONTRIBUTING.md. Bugs and feature ideas go to the issue tracker.

License

MIT © Nimbalyst

About

Electronics Studio — PCB & controller design, simulation, test, and manufacture-export for Nimbalyst. Powered by tscircuit + Circuit JSON.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors