Skip to content

nimbalyst/nimbalyst-electronics

Repository files navigation

Electronics Studio — Nimbalyst extension

CI License: MIT

com.nimbalyst.electronics

Electronics Studio showing a 3D-rendered motherboard PCB with a placed-parts navigator and a design-readiness advisor

The thing that makes it different: the AI 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.

Built on tscircuit

We use, and are grateful for:

If you like what you see here, star and support the tscircuit project — this extension would not exist without it.

Files

  • *.circuit.tsx — tscircuit React/TSX code, the source of truth.
  • *.circuit.json — raw Circuit JSON, render-only.

What works today

Design

  • Direct tscircuit canvases — exact-version Schematic, PCB, Assembly, and 3D viewers sharing the host React tree. Failures stay in the affected pane with a reload action. Schematic ports drive click-to-wire; PCB body drag persists through upstream manual-edits.json with host undo/redo; 3D is a read-only offline view.
  • Design cockpit — searchable parts library, reusable functional blocks (status LED, Arduino blink, I²C sensor port, decoupled NeoPixel), schematic/PCB/code/simulation views, and a live design advisor — all over the code-native source of truth.
  • Hybrid authoring — insert catalog parts and pre-wired blocks into the .tsx, or edit the code directly. Blank projects offer starter blocks and three agent-staged controller templates (XIAO ESP32-C3 carrier, Raspberry Pi Pico carrier, Arduino Nano-style carrier).
  • Direct canvas interaction — click rendered schematic/PCB components to select their source part; in schematic Wire mode, click two pins to add one undoable trace. Nudge, rotate, or duplicate selected parts. Selectors come from Circuit JSON, not label guessing.
  • BOM workspace — summary counts, filter/sort/paging, grouped rows, per-ref sources, and copy actions for MPNs and supplier IDs. Supplier searches open in the external browser; no stock or orderability is implied.
  • Shared project guidance — a versioned electronics.project.json records power/interface/connector requirements, preferred footprints, suppliers, named trace widths, and optional PCB scalar minima. Capture it via the agent, review the JSON, then load it read-only.

Agent-driven workflow

PCB and controller design for makers and hardware engineers, inside Nimbalyst: design → simulate → test → manufacture-export. The agent drives the editor through registered tools. Selections in the navigator, schematic, PCB, or advisor publish exact part/pin/net identity to the host context indicator, and the various "Scout" / "Ask agent" cards start a named session with a bounded, untrusted-delimited brief. Nothing sends until you click, nothing mutates until the approval gate is resolved, and grants are one-shot — a selection or source change revokes them.

  • Selection-aware assistants — Pin Scout, Wire Scout, Evidence Scout, Net Detective, Pair & Ask, and the advisor handoff each frame exact source identity and offer read-only "explain" intents plus, where applicable, a single guarded mutation (e.g. one preview_connection) that stops at approval.
  • Inspectable edit transactions — every agent mutation is a named local transaction. The History panel shows before/after previews; user and agent can undo/redo during the session.
  • High-impact approval gate — broad or destructive operations (add_block, remove_part, set_board, geometry/mounting-hole/keep-out proposals, readiness actions) open a local review with exact source and evaluated-impact diffs. Nothing changes until it's applied.
  • Truthful post-approval reveal — after an approved edit, the editor waits for the exact source projection before showing before→after part/connection/PCB/board deltas, and offers Undo while the transaction is latest.

Analysis

  • ERC-style lint — missing current-limit resistor, missing decoupling cap, unconnected pins.
  • Explainable readiness preflight — a 0–100 review of connectivity, electrical recommendations, board outline, PCB geometry/routing, and supplier identification, with prioritized next actions. Guidance, not final ERC/DRC or fab DFM.
  • PCB Rule Lens — a read-only tool comparing evaluated trace widths and via/pad/hole dimensions against the board's own minimums, loaded project guidance, or a dated reviewed JLCPCB FR4 2-layer capability profile. Scalar preflight evidence only — not clearance, DRC/DFM, or fab signoff.
  • Local PCB route proposals — runs the pinned capacity autorouter in a cancellable worker and draws dashed per-layer candidate copper. Nothing is applied or persisted; candidate geometry is not routing truth.
  • Local part evidence — an electronics.parts.json contract classifies each placed part as incomplete / declared / evidenced / conflict from presence-checked local paths. "Evidenced" means an agreeing local record, not verification, authenticity, or availability.
  • PCB overlays — session-only, read-only measurement, coordinate lattice, layer lens, connectivity evidence, part-trust and assembly spotlights. They inspect the current projection; they never edit, save, or claim DRC/fabrication.

Simulation & test

  • Three engineslogical (fast interactive state: which LEDs light, is a chip powered), analog (ngspice node-voltage traces), and mcu (real firmware on avr8js / rp2040js: GPIO traces, serial output, peripheral events).
  • Firmware test harness — run a sketch on the emulated MCU and assert on its behavior (serial output, GPIO frequency/duty, SPI TX bytes, ADC samples, I²C write intent, UART responses, NeoPixel frames, EEPROM/watchdog/interrupt intent, and more) for a pass/fail report.
  • Bundled emulator fixtures — assembler-backed, checked-in, digest-verified images that run locally with no external compiler or download: RP2040 Launch Beacon plus a large AVR library (PWM, servo/tone timers, SPI, ADC, ADC→PWM, I²C, UART, step/dir, limit interlock, quadrature, debounce, NeoPixel, EEPROM, watchdog, INT0, Timer1 counter, PCINT). All are emulator evidence, not physical-hardware claims.
  • Pinned regressions & matrices — the agent can save deterministic *.simulation-test.json and *.simulation-matrix.json files that run only while source, projection, fixture, and stimulus still match. Run them headless in CI:
npm run test:simulation -- \
  --circuit examples/rp2040-launch-beacon.circuit.tsx \
  --test tests/beacon.electronics.simulation-test.json \
  --test-manifest tests/beacon.freshness.json \
  --report reports/beacon.electronics.simulation-report.json \
  --report-manifest reports/beacon.freshness.json

npm run test:simulation-matrix -- \
  --circuit examples/avr-uart-command-response.circuit.tsx \
  --matrix tests/uart.electronics.simulation-matrix.json \
  --matrix-manifest tests/uart-matrix.freshness.json \
  --report reports/uart.electronics.simulation-matrix-report.json \
  --report-manifest reports/uart-matrix.freshness.json

The runner never scans for tests, creates directories, or overwrites outputs — create parent directories and choose new paths first. Exit codes: 0 pass, 1 assertion failure, 2 refusal, 3 incomplete write.

Cost & export

  • Cost estimate — offline prototype pricing (PCB + optional SMT) from area, layers, and quantity. Not a live vendor quote.
  • Standalone exports — BOM (vendor-neutral CSV, JLC-style BOM+CPL, or Markdown), design images (schematic/PCB/assembly SVG), and a portable SPICE netlist (.cir).
  • Manufacture export — a vendor-agnostic fab bundle: Gerber X2 + Excellon drill + BOM + pick-and-place CSV + README. Zip and upload to any fab.
  • KiCad handoff — editable .kicad_pro / .kicad_sch / .kicad_pcb for deeper routing and production review, with normalized timestamps for reproducible exports. Also imports KiCad projects as render-only migrations.
  • Enclosure export — a parametric OpenSCAD box sized to the board, handed off to the OpenSCAD / 3D extensions for STL/STEP.
  • Design review packet & freshnesscreate_design_review_packet writes deterministic Markdown, and every export writes a SHA-256 freshness/provenance manifest so check_artifact_freshness can tell you when an artifact is stale.

Electronics Studio is, first and foremost, a Nimbalyst-native home for tscircuit. tscircuit does the hard part — turning React/TypeScript into real circuits — and we lean on it heavily. Nearly every core capability here is tscircuit's work; our job is the editor, the agent contract, and the local-first workflow around it. Every export writes its provenance manifest last and returns the path.

AI tools

The agent operates the loop through electronics.* tools: runtime_status, load_project_guidance, part_evidence_report, import_kicad, list_nets, describe_part, propose_project_template, add_part, add_block, preview_connection, preview_assembly_metadata, connect, remove_part, remove_connection, update_part, set_board, preview_geometry_change, preview_mounting_holes, preview_keepouts, show_pcb_grid, clear_pcb_grid, set_pcb_layer_view, clear_pcb_layer_view, show_part_trust_spotlight, clear_part_trust_spotlight, show_assembly_handoff_spotlight, clear_assembly_handoff_spotlight, show_connectivity_evidence, clear_connectivity_evidence, measure_pcb, clear_pcb_measurement, apply_readiness_action, resolve_edit_preview, transform_part, duplicate_part, undo, redo, lint, readiness, inspect_assembly_handoff, export_assembly_handoff, simulate, test, quote, check_artifact_freshness, review_part_evidence_contribution, create_design_review_packet, export_bom, export_image, export_netlist, export_fab, export_kicad, export_enclosure.

See docs/TOOL_REFERENCE.md for every tool's inputs and when to use it.

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

Docs

The in-app ? button (top-right of the editor) opens a quick-start with the same essentials.

Architecture (and why it is the way it is)

The renderer uses Nimbalyst's singleton React and React DOM 19.2.7. The extension externalizes React and every React/React-DOM subpath so direct tscircuit components and Electronics Studio share one tree — no iframe, nested root, or second React.

  • One direct editor set renders Schematic, PCB, Assembly, and read-only 3D. Every viewer is measured before mount; contract/render failures become reloadable inline cards.
  • circuit-to-svg is used only in the image-export backend — interactive UI, review packets, fab, and BOM do not import it. The 3D pane uses the pinned package's bundled JSCAD path, blocks external model URLs, and supplies a bundled font.
  • .tsx → Circuit JSON evaluation runs in a tscircuit Web Worker (@tscircuit/eval/worker) for CPU isolation and deterministic projection; it makes no runtime CDN fetch.
  • Simulation bundles eecircuit-engine (inlined ngspice WASM) plus local avr8js / rp2040js assets. RP2040 boots local firmware directly instead of fetching a remote boot ROM.
  • The browser worker uses explicit footprints and disables tscircuit's EasyEDA parts-engine lookup (its endpoint rejects localhost origins). Record supplier IDs explicitly with supplierPartNumbers.
  • Single dist/index.js — the host loads the extension from a blob: URL that can't resolve sibling chunks, so the bundle must stay one file. Only react/react-dom are externalized.
  • An optional firmware backend (dist/backend.js, utility-process) builds firmware with your arduino-cli / PlatformIO and runs ESP32 under QEMU. Disabled by default; prompts on first use.

Core evaluation, deterministic exports, and bundled simulation run offline. A provider explicitly selected for Ask agent may use the network; it is not inherited from the current chat. Ask the agent to call electronics.runtime_status for the machine-readable contract.

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 design cockpit (host integration, views)
    CircuitViews.tsx            shared viewer evidence cards + PCB layer controls
    TscircuitPcbPane.tsx        direct PCB canvas + overlays/manual placements
    TscircuitSchematicPane.tsx  direct schematic canvas + port bridge
    TscircuitAssemblyDirectPane.tsx  direct read-only assembly canvas
    Tscircuit3dPane.tsx         direct read-only offline 3D canvas
    PartsPalette.tsx            searchable parts + functional block library
    DesignAdvisor.tsx           readiness, issues, component, and net inspector
    SimulationPanel.tsx         run simulations and inspect results
    Scope.tsx                   waveform/trace viewer
  circuit/
    circuitJson.ts         parse + query (components, nets) + lint
    readiness.ts           explainable design/manufacturing preflight
    editHistory.ts         local named transactions + undo/redo summaries
    tscircuitCode.ts       part catalog + .tsx authoring helpers
    functionalBlocks.ts    reusable high-level circuit operations
    evalCode.ts            .tsx -> Circuit JSON via the eval Web Worker
    fab.ts                 Gerber/Excellon/BOM/pick-and-place export
    bom.ts                 standalone BOM (generic / JLCPCB / Markdown)
    imageExport.ts         schematic/PCB/assembly SVG export
    spiceExport.ts         portable SPICE (.cir) netlist export
    kicad.ts               editable KiCad project handoff
  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.

Examples

The examples/ folder is a tour of the studio — each sample exercises a different capability. Open the .tsx to render it, then run the matching AI tool.

File Shows off Try
blinky.circuit.tsx the smallest live-evaluated board render
blinky.circuit.json raw Circuit JSON, rendered directly render
avr-pwm-heartbeat.circuit.tsx bundled AVR Timer0 PWM fixture Run, or fixture: "avr-pwm-heartbeat"; assert D6 frequency, duty, and edge count
avr-servo-pulse-intent.circuit.tsx bundled AVR Timer1 servo-pulse fixture Run; inspect D9 50 Hz / 1500 µs / 7.5% modeled-cycle evidence
avr-timer2-tone-intent.circuit.tsx bundled AVR Timer2 tone fixture Run; inspect D3 1 kHz / 50% — no sound is modeled
avr-spi-pixel-palette.circuit.tsx bundled AVR SPI byte fixture Run; inspect SPI0 hex/config and RGB intent, or assert spi_tx_equals
avr-adc-threshold.circuit.tsx bundled AVR modeled ADC fixture choose adc0_voltage 0–5V, Run, assert adc_sample_equals + pin_final
avr-adc-pwm-controller-intent.circuit.tsx bundled ADC→PWM controller fixture choose adc0_voltage, Run; inspect clamped D6 frequency/duty
avr-i2c-display-intent.circuit.tsx bundled AVR I²C write-intent fixture Run; inspect address 0x3c, bytes 00 ae a6 af, assert i2c_write_intent_equals
avr-quadrature-detent.circuit.tsx bundled AVR quadrature-input fixture choose CW/CCW, Run; inspect D2/D3 phases + D5/D6 latches
avr-button-debounce.circuit.tsx bundled AVR button-bounce fixture choose clean or bouncy D7, Run; inspect D4/D5 latches
avr-neopixel-frame-intent.circuit.tsx bundled AVR NeoPixel byte fixture Run; inspect GRB 20 10 40, assert neopixel_frame_intent_equals
avr-eeprom-roundtrip-intent.circuit.tsx bundled AVR EEPROM round-trip fixture Run; inspect 0010:5a cycle, assert eeprom_roundtrip_equals
avr-watchdog-reset-intent.circuit.tsx bundled AVR watchdog reset fixture Run; inspect reset cycle + MCUSR.WDRF, assert watchdog_reset_equals
avr-int0-interrupt-intent.circuit.tsx bundled AVR external-interrupt fixture choose D2 falling-edge cycle, Run; assert external_interrupt_equals
avr-timer1-pulse-counter-intent.circuit.tsx bundled AVR Timer1 pulse-counter fixture choose 1–8 D5/T1 pulses, Run; assert timer_external_count_equals
avr-pcint-mask-intent.circuit.tsx bundled AVR PCINT2 mask fixture choose masked / masked-then-enabled, Run; assert pin_change_interrupt_equals
rp2040-launch-beacon.circuit.tsx bundled RP2040 fixture (rp2040js) Run, or electronics.simulate with fixture: "rp2040-launch-beacon"
xiao-esp32-c3-i2c-carrier.circuit.tsx socketed controller-template golden inspect the 40 × 30 mm source projection
raspberry-pi-pico-sensor-status-carrier.circuit.tsx socketed controller-template golden inspect the 75 × 45 mm, 11-ref Pico header model
arduino-nano-avr-sensor-display-controller-carrier.circuit.tsx socketed controller-template golden inspect the 70 × 45 mm, 13-ref Nano-style carrier
arduino-blink.circuit.tsx MCU firmware emulation (avr8js) electronics.simulate — D13 toggles on the scope; point firmware at your own .hex to run a real sketch
rlc-ringing.circuit.tsx analog SPICE electronics.simulate — a damped sinusoid as the RLC tank rings
rc-filter.circuit.tsx analog RC low-pass electronics.simulate (analog)
stepper-driver.circuit.tsx motors + drivers + fab export electronics.lint, then electronics.export_fab / electronics.quote
electronics.project.json versioned requirements + design rules Capture requirements, review the JSON, then electronics.load_project_guidance
electronics.parts.json reviewed local MPN/footprint evidence copy beside your project, review, then electronics.part_evidence_report
neopixel-chain.circuit.tsx a clean multi-part BOM electronics.export_fab — a real BOM + pick-and-place
broken-board.circuit.tsx the ERC/lint rules, on purpose electronics.lint — flags the missing resistor, cap, and floating pin

Contributing

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

If you build with tscircuit, please also support the upstream project.

License

MIT © Nimbalyst

About

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

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages