Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

AYAB Valdi

Tests E2E

An experimental cross-platform port of ayab-desktop built with Valdi. One TypeScript codebase targets macOS, web (via Web Serial), and Android. iOS is not supported because Apple restricts USB serial access.

What is AYAB?

AYAB (All Yarns Are Beautiful) is a hardware retrofit that lets you control vintage Brother knitting machines from a computer. This app implements the desktop side of the AYAB protocol: serial discovery, image loading, knit settings, and the knitting state machine.

This project is an experimental port — not an official AYAB release. For production knitting today, use ayab-desktop.

Features

  • Serial port discovery (native + Web Serial in the browser)
  • Image loading (PNG, JPG, BMP, GIF, TIFF) and DAK .pat import
  • Experimental Knitout 2 import for AYAB-compatible front-bed stockinette and two-color fair-isle jobs
  • Image transforms (rotate, flip, invert, repeat)
  • Knit settings (mode, colors, needles, alignment, inf repeat)
  • Zoomable preview with machine bed visualization
  • Knit progress and stitch selection
  • Simulation mode for development without hardware
  • Preferences and hardware test mode
  • Broad unit and E2E test coverage

See PORT_AUDIT_AND_PLAN.md for parity details vs. ayab-desktop. See AYAB's Knitout profile before knitting a .k file on hardware.

Platform support

Platform Status Notes
Web Supported Web Serial API; run locally at http://localhost:3030
macOS Supported Native serial via IOKit
Android Experimental USB serial
iOS Not supported No USB serial access

Prerequisites

  • Bazelisk — installed automatically by valdi dev_setup, or install manually
  • Node.js 20+ — for the web dev server and E2E tests
  • Valdi CLI — npm install -g @snap/valdi (install guide)
  • macOS only: Xcode (for native macOS builds)
  • Android only: Android SDK (installed by valdi dev_setup)

Repository layout

All Valdi dependencies are upstream tarballs at pinned SHAs plus local patches in src/patches/:

  • src/MODULE.bazel — archive_override for Valdi and Valdi_Widgets sources
  • src/patches/ — patches applied on top of those tarballs
  • Bazel registry — fetched from the same Valdi pin by ./scripts/ensure-valdi-registry.sh (cached in src/.valdi-registry/, not committed)
ayab-valdi/
└── src/                   # Bazel workspace root
    ├── MODULE.bazel       # upstream pins + archive_override
    └── patches/           # local patches on Valdi / Valdi_Widgets

Quick start

1. Clone and install the Valdi toolchain

git clone https://github.com/clholgat/ayab-valdi.git
cd ayab-valdi

npm install -g @snap/valdi
valdi dev_setup
valdi doctor

2. Fetch the Bazel registry and sync

./scripts/ensure-valdi-registry.sh
cd src && valdi projectsync

3. Run

Web (easiest for development):

cd ayab-valdi/src/web
npm start
# Open http://localhost:3030

macOS native:

cd ayab-valdi/src
valdi install macos

Android:

cd ayab-valdi/src
valdi install android

Hot reload (after a native install):

cd ayab-valdi/src
valdi hotreload

Running tests

All commands run from the src/ directory (the Bazel workspace root).

cd ayab-valdi/src

# All module unit tests
bazel test //modules/serial:test \
  //modules/state_machine:test \
  //modules/knitout:test \
  //modules/machine_job:test \
  //modules/knit_session:test \
  //modules/ayab_valdi:test \
  //modules/preview:test \
  //modules/app_settings:test \
  //modules/image_settings:test \
  //modules/process_image:test \
  //modules/constants:test \
  --test_output=errors

# Or from the repo root:
./scripts/run-tests.sh

# Web E2E (Puppeteer)
cd web
npm ci
npm run e2e

CI runs these automatically on push and pull request.

Valdi version pinning

Pinned SHAs live in .github/valdi-deps.env and src/MODULE.bazel. Local changes not yet upstream live in src/patches/. After bumping pins, re-check patches apply, then run ./scripts/pin-valdi-deps.sh <valdi-sha> <widgets-sha>. See CONTRIBUTING.md.

Project structure

ayab-valdi/
├── src/                       # Bazel workspace
│   ├── modules/
│   │   ├── ayab_valdi/        # Main app UI, knit/hardware-test sessions
│   │   ├── serial/            # Serial communication, Web Serial polyglot
│   │   ├── state_machine/     # AYAB protocol state machine
│   │   ├── preview/           # Image preview, transforms, zoom viewport
│   │   ├── image_settings/    # Knit settings UI
│   │   ├── app_settings/      # Preferences storage and screen
│   │   ├── process_image/     # Image loading, .pat/.stp/.cut import
│   │   ├── knitout/           # Knitout parser, analyzer, and conservative AYAB compiler
│   │   ├── machine_job/       # Portable executable-job contract and preflight
│   │   ├── knit_session/      # Durable pass checkpoints and recovery
│   │   └── constants/         # Shared types, tokens, UI theme
│   ├── patches/               # Local patches applied to upstream Valdi/Widgets
│   └── web/                   # Webpack dev server for ayab_web
├── scripts/                   # ensure-valdi-registry.sh, run-tests.sh, pin-valdi-deps.sh
├── .github/workflows/         # CI (tests + E2E)
├── PORT_AUDIT_AND_PLAN.md     # Feature parity vs ayab-desktop (living doc)
├── TDD_GAP_PLAN.md            # Test-driven gap closure plan (living doc)
└── CONTRIBUTING.md            # Dev setup, conventions, Valdi pin upgrades

Contributing

See CONTRIBUTING.md. Bug reports and pull requests are welcome.

License

MIT — see LICENSE.

Links

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages