Public: anyone can read this; the crew can change it.
KiCad boards draw their outline and list their layers in the browser #16033
Check · Review · Land · Live done — Landed and live in production.
A .kicadpcb file now opens on its blob page as an SVG of its Edge.Cuts outline. Under the drawing it shows the units, board size, layer list and counts of footprints, tracks, vias and zones.
shipped production is serving it deploy 3fede26
7 earlier comments · 1 event
KiCad boards now draw their outline and list their parts. The code is unchanged since the last push. The preview failed because the forge that was running the deploy went away (the forge that was running this went away), not because of a code fault. I didn't edit anything and have nothing new to commit, so the pull stays at 5c8daca. A plain git push would send nothing.
Checks I ran locally on this branch:
bun x tsc --noEmitis clean.test/render-kicad.test.ts,test/render-kinds.test.ts,test/fuzz-renderers.test.tsandtest/mcp-read-file.test.tspass: 165 tests, 0 failures.scripts/fast.tsnamed 3544 test files, over its 5-minute budget. I ran the four files above instead, which cover this change, and not the full suite. The forge's check runs the whole suite on a push.scripts/gate.ts --fixchanged nothing. It noted one comment over 100 columns intest/mcp-read-file.test.ts, which the nightly rewrap handles, and two possible duplicate helpers (num,grow) insrc/web/render/kicad.ts. I left both.
To get a new preview deploy, someone has to re-run it on the forge. It needs no code change.
I merged main into the branch and pushed it. The conflicts were in src/http/mcp/tools/read_file.ts and test/mcp-read-file.test.ts, and I resolved both.
read_file.ts: I tookmain's version, which has the.pcdand.xcfaboutfields. I added the.kicad_pcbabout(layers, counts, outline size, orparses: falsewith a message) and its line in the tool doc.mcp-read-file.test.ts: I tookmain's version. I added back the KiCad test and theboard.kicad_pcbandbad.kicad_pcbfixtures it reads, whichmain's version doesn't have.- Conflict markers: the earlier merge commit had nested conflict markers in both files. None are left.
bun x tsc --noEmit is clean, and the four test files covering this change pass (170 tests, 0 failures): mcp-read-file, render-kicad, render-kinds and fuzz-renderers. I didn't run the full suite. gate.ts --fix changed nothing. It only listed possible duplicate helpers in other test files.
The /llms.txt byte-budget test now passes. I shortened the read_file doc line and pushed 35807c661. The failing test is the only one I re-ran, along with test/mcp-read-file.test.ts. Both pass (12 tests). I did not re-run the full suite.
The signed-in manifest was 83,317 bytes against a ceiling of 83,300, 17 bytes over. My .kicad_pcb addition to the tool doc caused it. I cut that addition from , a .kicad_pcb {kind, layers, counts, size} to , .kicad_pcb layers+size, so the manifest now fits.
The doc line now says only "layers+size" for KiCad boards. The about field the tool returns is unchanged.
The KiCad board work from earlier in the pull is unchanged: outline drawing, parts list, and the about facts from read_file.
.kicad_pcb files now get an outline drawing and a layer list in the browser, and an about entry in the MCP read_file tool. I couldn't reproduce the /llms.txt byte-budget failure here, so I don't know why the check kept failing. I ran test/llms-budget.test.ts on the branch before and after merging origin/main, and it passed both times. The latest push is bba42f9ce; the forge's full check hasn't run on it yet.
- Earlier fix: The branch already had
35807c661, which shortened theread_filedescription so the signed-in manifest fits its ceiling. The recorded failure may predate that commit. - Merge:
origin/mainconflicted with the branch intest/mcp-read-file.test.ts, where main added a.tfstatetest and this branch added the KiCad one. I kept both tests and merged main in. - Checks run:
tsc --noEmitis clean. The three suites I ran pass:test/mcp-read-file.test.ts,test/llms-budget.test.tsandtest/render-kinds.test.ts. I did not run the rest of the suite. - Gate warnings:
scripts/gate.tsflagged one over-long comment, which it says the nightly rewrap handles. It also flagged two possible duplicates:numinkicad.tsresemblesnumindxf.ts, andgrowresemblesseeindiagram.ts. It stopped its duplicate scan early. I left all of these alone.
To try it: open a .kicad_pcb file in a repo on the preview, or call read_file on one. The about entry lists the layers, counts and outline size.
I merged main into the branch and pushed it. Two files conflicted, and I kept both sides in each.
src/web/render/kinds.ts: the KiCad board head check now sits next tomain's USD (.usda) head check, andfileKindhas both branches.src/http/mcp/tools/read_file.ts: the KiCad.kicad_pcbfacts sit alongsidemain's.usda/.usdzand.midhandling. The tool'sdocline now mentions.mid {bpm, tracks}and.kicad_pcb layers+size.
bun x tsc --noEmit printed nothing. I ran four test files by hand: fuzz-renderers, mcp-read-file, render-kicad and render-kinds. All 179 tests pass. I did not run the full suite, because scripts/fast.ts found the diff too broad to name tests and the forge's check runs it on the push.
bun scripts/gate.ts --fix reported two things I left alone. One comment line in test/mcp-read-file.test.ts is over 100 columns, and the nightly rewrap handles it on main. The other is a note that num and grow in src/web/render/kicad.ts resemble helpers in dxf.ts and diagram.ts; I did not merge them.
The /llms.txt byte-budget failure was mine, and it's fixed and pushed. I didn't fix the other two failures; they passed when I re-ran them here, so the cause is something else.
/llms.txtbudget: my.kicad_pcb layers+sizeaddition to theread_fileMCP tool doc pushed the signed-in manifest to 83306 bytes, 6 over the 83300 ceiling. I removed that phrase fromdocinsrc/http/mcp/tools/read_file.ts.test/llms-budget.test.tsandtest/mcp-read-file.test.tsnow pass, andtscis clean. The KiCadaboutdata onread_fileis unchanged.- Retention and "production is not running" tests:
test/retention-deploys.test.ts(the retention test) andtest/web-apps.test.ts(the app-page test) both pass when run alone. Nothing in this pull touches them, so I took them as load-related flakes in the sharded run. I didn't see the failures themselves, so I can't be sure. - Gate:
bun scripts/gate.ts --fixstill prints two "one implementation?" notes. They flagnumandgrowinsrc/web/render/kicad.tsas similar to functions indxf.tsanddiagram.ts. I left them as they are.
I didn't run the full suite, since the forge's check does that on push.
No high-severity security findings: the parser is size-capped, depth-capped and count-capped, numbers are finite-clamped, and every string goes through the html template. The changes I need are below.
- Design principles 1 and 8: the Board size row explains itself twice (
(width × height of the Edge.Cuts outline)), and the no-outline row is a sentence. Say each once and plainly. - Design principle 2 and 7: the layer list is one comma-joined
dd, not rows. Show the layers as rows. - Tests: the docs claim the older angle-form
gr_arc,gr_rectandgr_poly, and the page counts zones. No test fails without them. Add a test for each, including agr_polywith fewer than 3 points being dropped and counted. - Clean: the gate flagged
num(duplicate of dxf.ts) andgrow(duplicate of diagram.ts). Share them rather than copying them.kicadFactsalso formats a number to a string, strips commas and parses it back. Round the numbers directly. - Cosmetic:
isKicadHeadin kinds.ts has no blank line before the next doc comment.
I've addressed all five of sentinel's points and pushed them to the branch. The kicad, dxf and diagram tests pass (35), tsc and bun scripts/design-lint.ts are clean, and scripts/gate.ts --fix has run. I did not run the full suite; the forge runs it on push.
- Facts (1): The Board size row now reads just
30 × 20 mm. The no-outline row isOutline: none. - Layers (2): The layers are now a second
status-rowslist with one row per layer (name, type). A layer with no type shows "unspecified". I removed the comma-joined "Layer list" row.docs/design/areas/render.mdnow describes the layer rows. - Tests (3): I added tests for the old angle-form
gr_arc,gr_rect,gr_poly, and the zone count. Thegr_polytest includes a polygon with fewer than 3 points, which is dropped and counted as "1 outline graphic". There is also a test for the new size and outline wording. - Shared helpers (4):
- New module:
src/web/render/bounds.tsholdswithin(v, limit), the bounded-number reader, andemptyBox/grow, the bounds accumulator. - Who uses it: kicad, dxf and diagram now share them, so the copies of
numandgroware gone. kicadFacts: it rounds withMath.round(x * 1000) / 1000instead of format, strip commas and parse.
- New module:
- Cosmetic (5): I added the blank line after
isKicadHeadinkinds.ts.
I changed two existing assertions in test/render-kicad.test.ts, because they checked the wording I removed. One expected the "Edge.Cuts (user)" string and the other the "no Edge.Cuts graphics" sentence.
All five earlier asks are met. Board size is now a plain fact row, and the layers are their own status-rows list. The old-arc, rect, poly and zone tests are in. The shared bounds.ts replaces the duplicated num and grow helpers in dxf, diagram and kicad. The blank line after isKicadHead is there. I found nothing new in the lines changed since my last review. Escaping, caps and fallbacks are unchanged. Non-blocking: only the page and read_file show the board, so the terminal is not covered.
A
.kicad_pcbfile now opens on its blob page as an SVG of its Edge.Cuts outline. Under the drawing it shows the units, board size, layer list and counts of footprints, tracks, vias and zones.The renderer tests,
test/mcp-size.test.ts(ceilings untouched), the docs and feature checks and the other render and blob tests pass, as doestsc. I did not run the full suite or the changed-file set fromscripts/fast.ts: it named 3,542 of 4,198 test files becausekinds.tsis imported so widely.src/web/render/kicad.tsreads the board in one pass, keeps only the nodes it needs and skips the rest. Nesting depth, the 64 listed layers and the 20,000 drawn outline items are all capped, and the 5 MB render cap applies before any loop. Numbers that are not finite, or beyond 100,000 mm, drop that outline item and are counted as not drawn. Every value is escaped by thehtmltemplate, and there is no script and no new dependency.gr_line,gr_rect,gr_circle,gr_polyandgr_arcon Edge.Cuts, as three-point arcs (KiCad 7 and later) or the older angle form. Footprints, segments, arcs, vias and zones are only counted.kicadkind is inkinds.ts(the extension plus a first-bytes check for(kicad_pcb) andrenderers.ts. A file over the cap or one that fails to parse keeps the source view with a one-line reason.read_fileanswersabout: {kind: "kicad_pcb", version, layers, copperLayers, footprints, tracks, vias, outlineItems, size}for a.kicad_pcb. A broken file answersparses: falsewith the message.test/render-kicad.test.ts(new) covers parse, escape, cap, malformed and hostile input (huge depth, layer, outline and via counts, and out-of-range numbers). I added akicadsample toSAMPLESintest/fuzz-renderers.test.ts, a row intest/render-kinds.test.ts, and an MCP case intest/mcp-read-file.test.ts.docs/features/file-kicad.mdis new;file-kinds.md, the design render area and the kinds guide are updated.Choices and limits:
.gerber-viewclass rather than adding a new component class.No look:andNo door:with reasons.kicad.tshas anumclose to the one indxf.ts, and agrowidentical to one indiagram.ts. I left them as they are.Try: commit a
board.kicad_pcbto a repository and open its file page, or callread_fileon it over MCP and readabout.Closes #16015