Go-based KiCad schematic manipulation toolkit providing an intermediate IR, parser, generator, console/SVG renderer, diffing, and CI/CD-friendly validation.
- Go 98.5%
- Makefile 1.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
kajiya CI / Lint (push) Failing after 3s
kajiya CI / Test (push) Failing after 51s
kajiya CI / Test-1 (push) Failing after 51s
kajiya CI / Test-2 (push) Successful in 38s
kajiya CI / Build (push) Successful in 35s
kajiya CI / Build-1 (push) Successful in 34s
kajiya CI / Build-2 (push) Successful in 33s
kajiya CI / Terminal Output Test (push) Successful in 35s
kajiya CI / Terminal Output Test-1 (push) Successful in 35s
kajiya CI / Terminal Output Test-2 (push) Successful in 29s
kajiya CI / Terminal Output Test-3 (push) Successful in 34s
kajiya CI / Terminal Output Test-4 (push) Successful in 33s
kajiya CI / Benchmark (push) Successful in 47s
kajiya CI / Validate Examples (push) Successful in 34s
- Changed svgScale constant from 8.0 to 10.0 - Increased wire stroke width from 1.5 to 2 - Increased bus stroke width from 3 to 4 - Increased comp-line stroke width from 2 to 3 - Increased font sizes for various SVG elements - Increased junction radius from 3 to 6 - Increased no_connect line size from 12 to 28 - Added stroke-width attribute to no_connect lines - Increased component reference text position from -12 to -28 - Increased component value text position from +6 to +14 - Updated sheet stroke width from 2 to 4 - Updated sheet dash pattern from 8,4 to 16,8 - Updated component label positioning and sizing - Removed conditional width/height attributes from SVG element - Updated component reference width calculation from 7.0 to # Previous message: fix(render): scale SVG fonts and strokes for readability Removed fixed display width/height so SVG scales to 100 percent viewport. Font sizes increased to 28px/22px SVG user units so they map to ~18px/14px CSS pixels on typical displays. Wire widths, junction radius, and no-connect markers scaled up proportionally. Component line width increased from 7 to 18. Scale factor bumped to 10x. |
||
| .forgejo/workflows | ||
| cmd/kajiya | ||
| docs | ||
| examples | ||
| internal | ||
| schema | ||
| testdata | ||
| vendor | ||
| .gitignore | ||
| .golangci.yml | ||
| .pre-commit-config.yaml | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| README.md | ||
| ROADMAP.md | ||
kajiya
KiCad schematic manipulation toolkit. Parse, convert, render, and generate KiCad schematics through a format-agnostic intermediate representation (IR).
Quick Start
go install git.lan.thwap.org/thwap/kajiya/cmd/kajiya@latest
kajiya version
Features
- Parse KiCad
.kicad_schfiles to an intermediate IR - Convert between IR formats: YAML, JSON, TOML
- Generate KiCad schematics from IR documents
- Render schematics to console (ANSI/UTF-8 text) or SVG
- Diff two schematics for version control workflows
- Validate IR documents for structural correctness
- Annotate auto-assign reference designators
Commands
| Command | Description |
|---|---|
convert |
KiCad schematic → YAML/JSON/TOML |
generate |
YAML/JSON/TOML → KiCad schematic |
render |
Schematic → console/SVG output |
diff |
Compare two schematics |
validate |
Validate IR document |
completion |
Generate shell completions |
Installation
go install
go install git.lan.thwap.org/thwap/kajiya/cmd/kajiya@latest
From source
git clone https://git.lan.thwap.org/thwap/kajiya.git
cd kajiya
go build ./cmd/kajiya
Pre-built binaries
See releases for Linux, macOS, and Windows binaries.
Docker
docker run --rm -v "$PWD:/work" ghcr.io/thwap/kajiya render -i /work/schematic.kicad_sch
Tutorial: Convert, Edit, Regenerate
1. Convert KiCad schematic to YAML
kajiya convert -i schematic.kicad_sch -o design.yaml
kajiya convert -i schematic.kicad_sch -o design.json
kajiya convert -i schematic.kicad_sch -o design.toml
2. Edit the YAML
Modify component values, footprints, net names, or add components.
Example: change a resistor value from 10k to 47k.
components:
- reference: R1
value: 47k
3. Regenerate the KiCad schematic
kajiya generate -i design.yaml -o updated.kicad_sch
4. Round-trip verification
kajiya convert -i updated.kicad_sch -o roundtrip.yaml
kajiya diff --left design.yaml --right roundtrip.yaml
Tutorial: Render to Console
Quickly inspect a schematic without launching KiCad:
kajiya render -i schematic.kicad_sch -f console
kajiya render -i schematic.kicad_sch -f console --no-color | less
kajiya render -i schematic.kicad_sch -f console --width 120 --height 60
Render to SVG
kajiya render -i schematic.kicad_sch -f svg -o schematic.svg
kajiya render -i design.yaml -f svg --width 1024 --height 768
CI/CD Integration
Lint schematics in CI
kajiya validate -i schematic.kicad_sch
kajiya validate -i design.yaml
if ! kajiya validate -i schematic.kicad_sch --quiet; then
echo "Schematic validation failed"
exit 1
fi
Auto-annotate in CI
kajiya generate -i design.yaml -o annotated.kicad_sch
kajiya diff --left design.yaml --right annotated.kicad_sch
Git diff for schematics
Add to .gitattributes:
*.kicad_sch diff=kicad
Add to .git/config or ~/.gitconfig:
[diff "kicad"]
textconv = kajiya convert -i
Now git diff for .kicad_sch files shows human-readable YAML diffs.
Shell Completions
# Bash
source <(kajiya completion bash)
# Zsh
source <(kajiya completion zsh)
# Fish
kajiya completion fish | source
Project Structure
cmd/kajiya/ CLI entry point
internal/ir/ IR model types and serialization
internal/parser/ KiCad schematic parser and writer
internal/render/ Console and SVG renderers
internal/sexpr/ S-expression scanner and parser
internal/errors/ Centralized error handling
schema/ JSON Schema for IR
testdata/ Test fixtures
Performance
Typical performance on a mid-range machine:
- Parse 100-component schematic: ~50ms
- Convert to YAML/JSON: ~10ms
- Generate KiCad output: ~20ms
- Console render: ~5ms
- SVG render: ~15ms
License
GPL-3.0