Guide
POLY-OS
An operating system written in POLYTONE, booted on the POLY-Machine — in the browser at /os/ and headless with ptc machine. Every frame is a .pti display list, every disk a text image, every app a value: boot(disk, machine) builds the system, tick(os, input) advances it, and the machine executes what comes out.
The OS lives in os/ — a kernel (the disk, the window manager, the display-list builder, the app kit) and the apps: a Terminal that runs, tests and checks POLYTONE programs through the machine, Files, an Editor with .pt colors, a Reader and a Browser for .ptw documents (http through the machine, .pt apps as pages), Mail with local delivery and a relay, a Gallery, Paint and Music for the media formats, a Calculator, a Calendar, Notes, Tasks, Settings and a lock screen. F1 opens the manual, Alt+Space the launcher (type to search apps and files), Alt+T a Terminal, Alt+Q closes, Alt+L locks.
ptc machine os/polyos.pt --events session.events --screenshot last.ppm --save disk.ptdHeadless, the machine boots the same image the site embeds, feeds an event script (one batch of lines per tick — key down Enter, text a, mouse down 20 58 1 …), answers the OS's requests itself (a program run, a rendered picture), prints every output section, renders the last frame through the real codec and writes the disk the OS saved. That is how CI boots POLY-OS, types into it and asserts on the frame — the machine protocol is documented in formats/machine.md.
record Os:
typed: Text
/// Boots from the disk image (the text typed so far).
pub fn boot(disk: Text, machine: Text) -> Os = Os(typed: disk.trim())
/// One batch of input lines in, the next state and the output out.
pub fn tick(os: Os, input: Text) -> Tuple[Os, Text]:
mut typed = os.typed
for line in input.split("\n"):
if line.starts_with("text "):
typed = "{typed}{line.slice(5, line.len())}"
let next = Os(typed: typed)
return (next, "@frame 1\nlabel 8 8 2 #f2f0ea {typed}\n")The smallest OS image: two pub functions are the whole contract. Anything that boots and ticks like this runs on the machine — your own OS is one file away.