Monorepo for Aesthetic.Computer aesthetic.computer
at main 171 lines 8.1 kB view raw view rendered
1# FedAC Native OS — Progress Report 2 3_Last updated: 2026-03-12_ 4 5## What It Is 6 7Bare-metal Linux OS that boots from USB via UEFI as PID 1. Runs a QuickJS engine 8executing `.mjs` pieces (interactive programs) with direct hardware access — DRM 9display, ALSA audio, evdev input, WiFi, TTS, camera. No userspace, no systemd, no shell. 10 11## Current State: Fully Functional 12 13### Boot & Runtime 14- Custom kernel (6.14.2) with embedded LZ4 initramfs 15- Boot time: ~7.3s from power to piece running 16- Per-user config: `config.json` on EFI partition injects `@handle` into boot splash 17 (rainbow animated text), TTS greeting ("hi jeffrey"), and shutdown ("bye jeffrey") 18- **Build naming**: Each build gets a unique adjective-animal name (e.g., "keen-egret") 19 displayed in golden text on boot screen (top-right panel) and spoken via TTS 20 - Animal rotates daily (365 pool), adjective bumps every build (200 pool) 21 - Counter persisted in `.build-counter`, auto-bumped by Makefile 22- Auth-gated image generation: `GET /api/os-native?piece=notepat` requires handle 23- Piece navigation: `system.jump("prompt")` hot-swaps pieces without reboot 24 25### Pieces 26- **notepat.mjs** (~7800 lines) — Full chromatic keyboard instrument 27 - 12-note grid, 6 octaves, 5 wave types (sine/tri/saw/square/noise) 28 - Echo (room reverb) slider, pitch shift slider, metronome 29 - Touch + keyboard + NuPhy analog pressure support 30 - Status bar: clock (LA time w/ DST), wave, octave, kHz, vol, brt, battery, WiFi 31 - HDMI secondary display output (blended note colors) 32- **prompt.mjs** — Command-line piece with pink block cursor, history, escape→notepat 33- **os.mjs** — System management & hardware info 34 - OTA update: check version, download, flash, verify, reboot (with animations) 35 - Flash target selector (tab to cycle USB/NVMe/etc.) 36 - Responsive layout: two-column on wide screens (>260px) 37 - System stats: model/vendor, CPU, RAM usage (text + graphical bar), battery 38 - Cores, process count, load average (1/5/15 min), CPU governor 39 - Connected devices list: USB, input/HID, cameras, audio, disks (with size/removable), display connectors (with connected status) 40- **claude.mjs** — Claude AI chat client 41 - OAuth refresh token auth (via Claude Code subscription) 42 - Token provisioning: QR code scan (camera) or manual paste 43 - Camera preview: live V4L2 feed during QR scan with crosshair overlay 44 - Chat mode: word-wrapped conversation, scrollable history 45 - Commands: `/clear`, `/token`, `/scan` 46 47### Camera (V4L2 + quirc) 48- UVC driver built into kernel (CONFIG_USB_VIDEO_CLASS) 49- V4L2 capture: tries /dev/video0-3, YUYV format, 640x480 50- Background scan thread: grabs frames at ~30fps, scans for QR codes 51- Display buffer: mutex-protected grayscale copy for main thread rendering 52- `system.cameraBlit(x, y, w, h)`: renders camera feed to framebuffer with nearest-neighbor scaling 53- quirc library (vendored v1.2) for QR code decoding 54 55### Audio 56- ALSA direct `hw:` access, 192kHz (negotiated), 128-sample periods 57- 32 max voices with oldest-voice stealing 58- Room reverb: 3-tap delay, 0.55 feedback, controllable wet mix 59- Glitch mode: sample-hold + 6-bit bitcrush 60- TTS via flite (male + female voices) 61 62### WiFi 63- Auto-connect: scan → pick strongest known SSID → connect (fully silent, no TTS) 64- 5s timeout on failed connects, retry with next scan cycle 65- Only connects to networks actually detected in scan (no blind attempts) 66- WiFi panel: select-then-confirm interface (first tap selects, second connects) 67- Panel doesn't disrupt active connections (no scan while connected) 68- Deduplicated SSID list (strongest signal per network) 69- Saved/preset networks shown below scan results with visual distinction 70- Password entry mode for new encrypted networks 71 72### Chat (WebSocket) 73- Connects to `wss://chat-system.aesthetic.computer/` after WiFi 74- Displays latest message in status bar with TTS 75- Dedup: same message not re-TTS'd on WS reconnect cycles 76- Silent reconnection (server sends history then closes, client auto-reconnects) 77- Mute toggle (M key or tap) 78 79### OS Update System 80- Background auto-update: checks version on WiFi connect, silent download + flash + reboot 81- Manual OS panel: responsive layout, connection-aware, version check with 10s timeout 82- Release uploads to Digital Ocean Spaces (`upload-release.sh`) 83- Progress bar for downloads, "do not power off" during flash 84- Shutdown animation with scrolling telemetry 85 86### Hardware Info (`system.hw`) 87Exposed to JS pieces every frame: 88- `model`, `vendor` — DMI product/vendor strings 89- `cpu` — model name from /proc/cpuinfo 90- `cores` — logical core count 91- `ramTotalMB`, `ramAvailMB` — from /proc/meminfo 92- `processes` — count of running PIDs 93- `load1`, `load5`, `load15` — from /proc/loadavg 94- `governor` — CPU frequency scaling governor 95- `buildName` — compile-time adjective-animal name 96- `devices[]` — array of detected peripherals: 97 - USB devices (product name, vendor, bus ID) 98 - Input/HID devices (evdev name) 99 - Cameras (V4L2 device name) 100 - Audio cards (ALSA card name) 101 - Block devices (model, size in GB, removable flag) 102 - Display connectors (DRM name, connected status) 103 104### Controls 105- Volume & brightness: hardware keys (F1-F6) + mouse drag on status bar indicators 106- JS bindings: `system.volumeAdjust(delta)`, `system.brightnessAdjust(delta)` 107- Echo/pitch sliders: touch drag or trackpad 108- Trackpad FX mode (\ toggle): trackpad X→echo, Y→pitch 109- Pixel scaling: Ctrl+= / Ctrl+- (wraps through 1-8x) 110 111### Fonts 112- `font_0`: built-in 8x8 bitmap 113- `font_1`: 6x10 BDF (from system assets) 114- `font_matrix`: MatrixChunky8 BDF 115 116## Key Files 117| File | Description | 118|------|-------------| 119| `src/ac-native.c` | Main loop, DRM init, boot splash, shutdown | 120| `src/js-bindings.c` | QuickJS API surface, lifecycle calls, system bindings | 121| `src/js-bindings.h` | ACRuntime struct (state for everything) | 122| `src/audio.c` | ALSA engine, synthesis, reverb, glitch | 123| `src/graph.c` | Software framebuffer (wipe/ink/box/line/circle/write) | 124| `src/font.c` | BDF font renderers | 125| `src/input.c` | evdev keyboard/mouse/touchpad, NuPhy hidraw analog | 126| `src/wifi.c` | WiFi management (wpa_supplicant, dhclient) | 127| `src/ws-client.c` | WebSocket client (TLS, background thread) | 128| `src/udp-client.c` | UDP fairy point co-presence | 129| `src/camera.c` | V4L2 capture, grayscale conversion, QR scanning | 130| `src/camera.h` | ACCamera struct (V4L2 state, display buffer, scan results) | 131| `src/tts.c` | Text-to-speech via flite | 132| `src/drm-display.c` | KMS/DRM modesetting | 133| `pieces/notepat.mjs` | Main instrument piece | 134| `pieces/prompt.mjs` | Command-line navigation piece | 135| `pieces/os.mjs` | OS update + system info piece | 136| `pieces/claude.mjs` | Claude AI chat client piece | 137| `lib/quirc/` | Vendored quirc v1.2 QR decoder | 138| `scripts/build-name.sh` | Unique build name generator (adjective-animal) | 139| `scripts/build-and-flash.sh` | Full build pipeline (binary + initramfs + kernel) | 140| `scripts/upload-release.sh` | Publish release to DO Spaces | 141| `Makefile` | Binary build (auto-bumps build name) | 142| `ac-os` | Single-command build/flash/upload tool | 143 144## Build & Flash 145 146```bash 147# Full build + flash (ALWAYS use this — never just `make` alone): 148cd fedac/native 149./ac-os flash 150 151# Build only (no flash): 152./ac-os build 153 154# Build + flash + upload OTA release: 155./ac-os flash+upload 156 157# Upload current build as OTA: 158./ac-os upload 159``` 160 161**Important**: Always use `./ac-os flash` for the full pipeline. Running `make` alone 162only compiles the binary but doesn't rebuild the initramfs or kernel. The kernel embeds 163the initramfs, so a standalone `make` + separate flash results in stale code on the USB. 164 165## Known Issues / Next Steps 166- Audio tearing at high echo + many simultaneous voices (buffer underrun) 167- No regulatory.db for WiFi (region defaults) 168- i915 DMC firmware missing (cosmetic kernel warning, no functional impact) 169- `console.log` from JS writes to USB log (`[js]` prefix) — useful for debugging 170- NuPhy analog keyboard support compiled in but untested on current hardware 171- Camera preview is grayscale only (YUYV Y-channel extraction)