# Aster: context for AI assistants You are helping someone build a desktop app with **Aster**. Paste-ready rules for you, the assistant: - Aster draws native windows. The person has installed the free **Aster Runtime**. They write **one small file** in JavaScript (Node.js) or C#. Keep the whole app in that one file unless they ask otherwise. - The screen is a **function of the state**. Handlers change the state; Aster re-runs the view function and redraws. Never mutate the UI directly, never use HTML/CSS/DOM, React, WinForms or WPF: they do not exist here. - After writing the app, tell the person exactly how to run it (below), and suggest `screenshot` to check the result. ## JavaScript (Node.js 18+) Setup once: `npm install @barnyardgreens/aster`. Run: `node app.js`. ```js const { app, col, row, grid, card, panel, header, text, heading, stat, meter, button, input, toggle, badge } = require('@barnyardgreens/aster'); app({ title: 'Plant log', width: 720, height: 480, theme: 'dark', state: { watered: 0, note: '' } }) .view((s) => col( header('Plant log', 'kitchen window', badge('OK', 'success')), col({ gap: 4, pad: 4 }, grid(2, { gap: 4 }, card(stat('Watered', `${s.watered} times`)), card(meter('Soil moisture', 0.42, { role: 'info' }))), input('note', 'Write a note'), // its value is s.note toggle('reminders', 'Remind me daily'), // s.reminders is true/false row({ gap: 2 }, button('Water now', () => s.watered++), button('Clear', () => { s.watered = 0; s.note = ''; }, { tone: 'danger' }))))) .run(); ``` - Containers: `col`, `row`, `wrap`, `grid(columns, ...)`, `card`, `panel(title, subtitle, ...)`, `header(title, subtitle, ...rightSide)`, `scroll`, `overlay`. An optional first argument `{ gap, pad, grow, ... }` styles it. - Content: `text(s, props)`, `paragraph`, `caption`, `heading(title, subtitle)`, `stat(label, value)`, `badge(text, role)`, `pill`, `chip`, `status(text, role)`, `meter(label, 0..1)`, `sparkline([numbers])`, `alert(title, body, role)`, `keyValues({ k: v })`, `image('photo.png', { fit: 'cover', height: 150, alt })` (PNG only), `divider()`, `spacer()`. - Inputs keep their value in state under their key: `input(key, placeholder)`, `checkbox(key, label)`, `toggle(key, label)`, `slider(key, min, max, step)`. - `button(label, () => { ...change state... }, { tone })`. - From timers or network code: `myApp.update((s) => { s.temp = 21; })`. - Check your work without a window: run `ASTER_SHOT=look.png node app.js` (Windows PowerShell: `$env:ASTER_SHOT='look.png'; node app.js`). It saves a picture and prints an outline of the screen instead of opening the window; `ASTER_CLICK='Water now|Clear'` clicks first. Ask the person to send you `look.png` so you can see what you built. ## C# (.NET 8+) Setup once: `dotnet new console -n MyApp && cd MyApp && dotnet add package Aster`. Run: `dotnet run`. ```csharp using Aster; using static Aster.Ui; int watered = 0; var app = new AsterApp(new() { Title = "Plant log", Width = 720, Height = 480 }); app.View(() => Col( Header("Plant log", "kitchen window", Badge("OK", "success")), Col( Grid(2, Card(Stat("Watered", $"{watered} times")), Card(Meter("Soil moisture", 0.42, "info"))).Gap(4), Input("note", "Write a note"), // app.Values["note"] Row(Button("Water now", () => watered++), Button("Clear", () => watered = 0).Tone("danger")).Gap(2)) .Gap(4).Pad(4))); app.Run(); ``` Also `Image("photo.png", "cover")`. Run with `ASTER_SHOT=look.png dotnet run` to get a screenshot instead of a window. Modifiers on any node: `.Gap(n) .Pad(n) .Grow() .Width(px) .Height(px) .Center() .Fill(role) .Color(role) .Style(s) .Bold() .Muted() .Radius(r) .Tone(role) .Key(k)`. Headless: `app.Screenshot("look.png")`, `app.Tree()`, `app.Click("label")`. ## Bigger apps (Aster Runtime 0.2+) Real apps need more than buttons: text editors, charts, tables, dialogs, menus, shortcuts. All of it is built in; `llms-full.md` lists every element. The patterns that matter: ```js const { app, col, row, textarea, markdown, table, lineChart, dialog, toast, commandPalette, select, button, text } = require('@barnyardgreens/aster'); const notes = app({ title: 'Notes', width: 1200, height: 800, state: { doc: '# Hello', confirm: false, palette: false, toast: false } }); notes.onChange((s) => { /* runs on every keystroke, switch or tab change; s.doc is the editor text */ }); notes.view((s) => col({ gap: 3, pad: 4, grow: 1, shortcuts: { 'ctrl+s': save, 'ctrl+k': (st) => { st.palette = true; } } }, row({ gap: 3, grow: 1, align: 'start' }, col({ grow: 1, basis: 0 }, textarea('doc', { rows: 30 })), // basis 0 + grow 1 = equal halves col({ grow: 1, basis: 0 }, markdown({ bind: 'doc' }))), // live preview, no round trip toast('toast'), dialog('confirm', 'Delete this note?', [text('This cannot be undone.')], [button('Delete', (st) => { st.confirm = false; }, { tone: 'danger' }), button('Cancel', (st) => { st.confirm = false; }, { ghost: true })]), commandPalette('palette', [{ id: 'save', title: 'Save', hint: 'Ctrl+S', action: save }]))); function save() { /* write the file */ notes.notify('toast', 'Saved'); } notes.run(); ``` - **Dialogs, toasts and the palette** are open while their bool state is true: `st.confirm = true` opens one. - **Charts** take `series: [{ name, values, role }]` plus `labels`; every series needs the same number of values. - **Tables** take `columns` and `rows` (arrays of strings) and handle sorting, search and paging themselves; give them every row, even thousands. - **Live data**: change your variables in a `setInterval` and call `app.update()`. - Headless typing for checks: `app.click('doc').type('hello')`. - C#: the same elements exist as `TextArea`, `MarkdownOf("doc")`, `Table`, `LineChart(Series(...))`, `Dialog`, `Toast`, `Menu`, `CommandPalette`, plus `app.OnChange`, `app.Notify`, `app.SetTheme`, `.Shortcut("ctrl+s", Save)`. Complete examples to copy from: Markdown Studio (an editor with tabs, file tree, outline, find/replace, preview), Ops Center (live dashboard with five pages), Kanban (board with an editor dialog) and Money (finance tracker). ## Shared vocabulary - **gap / pad** are spacing steps 0..64 (4 is comfortable). **grow** takes the remaining space. - **align** places children across a row/column (`start`, `center`, `end`, `stretch`); **justify** along it (`start`, `center`, `end`, `space_between`). `center: true` centres both ways. Side-by-side panels look best with `align: 'start'`. - **roles** (colours from the theme): `accent`, `success`, `warning`, `danger`, `info`, `secondary`, `surface`, `text`, `text_muted`. - **style**: `caption`, `body`, `label`, `title`, `headline`, `display`. - **themes**: `dark` (default), `light`, `paper_dark`, `paper_light`, `mission_light`, `high_contrast_dark`, `high_contrast_light`. - State keys must not contain `.`. ## When something goes wrong - "The Aster Runtime is not installed": the person installs it from https://barnyardgreens.farm/aster/install. - A red `[aster: unknown type "x"]` on screen: you used an element that does not exist; use only the ones above. - Every error ends with `[aster error : https://barnyardgreens.farm/aster/errors/]`; that page explains the fix. - Two controls with the same key: give each input/button its own `key`. - Nothing happens on click: the handler must change state that the view function reads. ## Links - [Install the Aster Runtime](https://barnyardgreens.farm/aster/install): Windows, Linux; the Mac status. - [Starter prompts](https://barnyardgreens.farm/aster#prompts): one block per kind of app, with these notes inlined. - [Templates](https://barnyardgreens.farm/aster#templates): working apps with their source, to remix. - [Error help](https://barnyardgreens.farm/aster/errors): what each Aster error means and how to fix it. - [Full notes](https://barnyardgreens.farm/aster/llms-full.txt)