aktion-runtime 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -114
- package/dist/aktion.iife.js +106 -460
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +5530 -5076
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +106 -460
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/devtools.js +1367 -0
- package/dist/devtools.js.map +1 -0
- package/dist/{node/index-8OvnOYPI.js → language.js} +13669 -12428
- package/dist/language.js.map +1 -0
- package/dist/plugin.cjs +2650 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +2650 -0
- package/dist/plugin.js.map +1 -0
- package/dist/system_prompt.txt +164 -447
- package/dist/system_prompt_chat.txt +33 -84
- package/dist/{node/index-DBgA3bHQ.cjs → testing.js} +28116 -12689
- package/dist/testing.js.map +1 -0
- package/dist/types/aktion-modules.d.ts +6 -10
- package/dist/types/compiler/index.d.ts +9 -11
- package/dist/types/compiler/linker.d.ts +11 -11
- package/dist/types/compiler/project.d.ts +45 -0
- package/dist/types/compiler/runtime.d.ts +22 -26
- package/dist/types/devtools/hook.d.ts +88 -0
- package/dist/types/devtools/index.d.ts +35 -0
- package/dist/types/devtools/panel.d.ts +109 -0
- package/dist/types/devtools/protocol.d.ts +130 -0
- package/dist/types/devtools/styles.d.ts +7 -0
- package/dist/types/element.d.ts +56 -24
- package/dist/types/index.d.ts +1 -1
- package/dist/types/language-api.d.ts +8 -8
- package/dist/types/parser/types.d.ts +8 -8
- package/dist/types/plugin/index.d.ts +13 -6
- package/dist/types/renderer/renderer.d.ts +28 -0
- package/dist/types/runtime/builtins.d.ts +5 -11
- package/dist/types/runtime/effects.d.ts +15 -0
- package/dist/types/runtime/http.d.ts +0 -1
- package/dist/types/testing/index.d.ts +201 -0
- package/dist/types/theme/index.d.ts +3 -3
- package/dist/types/theme/styles.d.ts +1 -1
- package/dist/types/tooling/formatter.d.ts +7 -1
- package/dist/types/tooling/index.d.ts +0 -3
- package/package.json +21 -19
- package/dist/node/compile-BUw0GAvN.cjs +0 -491
- package/dist/node/compile-BUw0GAvN.cjs.map +0 -1
- package/dist/node/compile-DxttTzo8.js +0 -492
- package/dist/node/compile-DxttTzo8.js.map +0 -1
- package/dist/node/compiler.cjs +0 -11
- package/dist/node/compiler.cjs.map +0 -1
- package/dist/node/compiler.js +0 -11
- package/dist/node/compiler.js.map +0 -1
- package/dist/node/index-8OvnOYPI.js.map +0 -1
- package/dist/node/index-DBgA3bHQ.cjs.map +0 -1
- package/dist/node/language.cjs +0 -1244
- package/dist/node/language.cjs.map +0 -1
- package/dist/node/language.js +0 -1244
- package/dist/node/language.js.map +0 -1
- package/dist/node/vite.cjs +0 -65
- package/dist/node/vite.cjs.map +0 -1
- package/dist/node/vite.js +0 -65
- package/dist/node/vite.js.map +0 -1
- package/dist/types/compiler/compile.d.ts +0 -54
- package/dist/types/compiler/emit.d.ts +0 -15
- package/dist/types/compiler/sourcemap.d.ts +0 -40
- package/dist/types/library/components/theme.d.ts +0 -2
- package/dist/types/plugin/vite.d.ts +0 -21
- package/dist/types/tooling/codemod.d.ts +0 -36
|
@@ -1,50 +1,28 @@
|
|
|
1
|
-
You
|
|
1
|
+
You respond in Aktion — a declarative language that is a strict subset of JavaScript. The host renders your reply as a rich, read-only UI. Output ONLY Aktion: no markdown, prose, or JSON.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Register the UI root with `$app(...)` on the first line (typically `$app(Column([...]))`). This is read-only display mode — use only the layout, content, data, chart, and feedback components listed below. Do NOT emit state writes, actions, effects, HTTP, routing, form controls, or clickable buttons. The single exception is `FollowUpBlock`, which the host renders as suggested follow-up prompts.
|
|
4
4
|
|
|
5
5
|
## Syntax (read-only subset)
|
|
6
6
|
|
|
7
|
-
A program is a flat list of `name = expression` statements
|
|
7
|
+
A program is a flat list of `name = expression` statements in standard JavaScript. `$app(...)` registers the entry point (always first); every other binding hoists, so order is free — emit `$app(...)`, then containers, then leaf data last for a smooth streaming reveal.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
- Numbers, booleans, `null`, arrays `[1, 2, 3]`, objects `{ key: value }`.
|
|
12
|
-
- Operators: `+ - * / %`, `== != > < >= <=`, `&& || !`, ternary `cond ? a : b`, nullish `a ?? b`, spread `[...a, ...b]`, member access `obj.field`, optional chaining `obj?.field`.
|
|
9
|
+
- Strings, numbers, booleans, `null`, arrays, objects; template literals `Found ${rows.length}` over `+` concatenation.
|
|
10
|
+
- Operators `+ - * / %`, comparisons, `&& || !`, ternary `cond ? a : b`, nullish `a ?? b`, spread, member `obj.field`, optional chaining `obj?.field`.
|
|
13
11
|
|
|
14
|
-
### Component calls
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
### Component calls
|
|
13
|
+
- **Case doesn't matter** — `Card` and `card` are equivalent.
|
|
14
|
+
- **Always invoke with parentheses** — `Column([Header(), Body()])`, never `Column([Header, Body])`; write `Hero()` even with no args.
|
|
15
|
+
- **One positional arg, the rest in a trailing object** — `Callout("info", { title: "Heads up", icon: "circle-info" })`, `Badge("Live", { tone: "success" })`.
|
|
17
16
|
|
|
18
|
-
###
|
|
19
|
-
`
|
|
17
|
+
### Build UI from data — JS is fully supported
|
|
18
|
+
`.map` / `.filter` arrays into nodes (`rows.map(r => ListItem(r.title))`), ternaries for branching, and the array-pluck shortcut `rows.title` → `[each row.title]` to feed columns (`Col("Title", rows.title)`) and chart series (`PieChart(rows.label, rows.value)`). `if` / `for` are statements — not usable on the right of `=`.
|
|
20
19
|
|
|
21
20
|
```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Building UI from data — JS is fully supported
|
|
28
|
-
- `.map(...)` / `.filter().map()` to render arrays into nodes (same as React).
|
|
29
|
-
- Ternary for branching: `tone = status == "ok" ? "success" : "warning"`.
|
|
30
|
-
- Array pluck: `rows.title` returns `[row.title for each row]` — feed columns (`Col("Title", rows.title)`) and chart series (`PieChart(rows.label, rows.value)`).
|
|
31
|
-
- `rows.length`, `rows.first`, `rows.last` shortcuts.
|
|
32
|
-
|
|
33
|
-
`if` / `switch` / `for` are statement-only — they cannot appear on the right-hand side of an assignment in chat mode.
|
|
34
|
-
|
|
35
|
-
### Streaming order
|
|
36
|
-
Always declare `aktion` FIRST. Then container/composition statements. Then leaf data arrays last.
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
aktion = Column([heroCard, statsRow, table, follow])
|
|
40
|
-
|
|
41
|
-
heroCard = Card([CardHeader("Q4 results", { subtitle: "Across all teams" })])
|
|
42
|
-
statsRow = Stats(stats)
|
|
43
|
-
table = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, { format: "currency" })])
|
|
44
|
-
follow = FollowUpBlock(["Break down by region", "Compare to Q3"])
|
|
45
|
-
|
|
46
|
-
stats = [{ label: "MRR", value: "$48.2k", hint: "+12% vs Q3" }]
|
|
47
|
-
rows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]
|
|
21
|
+
$app(Column([title, table, follow]))
|
|
22
|
+
title = Text("Q4 results", { variant: "large-heavy" })
|
|
23
|
+
table = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, { format: "currency" })])
|
|
24
|
+
follow = FollowUpBlock(["Break down by region", "Compare to Q3"])
|
|
25
|
+
rows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]
|
|
48
26
|
```
|
|
49
27
|
|
|
50
28
|
## Component library (read-only)
|
|
@@ -116,10 +94,10 @@ Use only these components. Each signature lists props in declaration order; opti
|
|
|
116
94
|
- Series(name: string, values: number[]) — Named data series for charts. Used inside BarChart, LineChart, PieChart.
|
|
117
95
|
|
|
118
96
|
### Feedback & Media
|
|
119
|
-
- Avatar(name: string, src?: string, size?: "sm"|"md"|"lg"|"xl", status?: "online"|"offline"|"busy"|"away", fallback?: "initials"|"dicebear") — User avatar. Shows the image at `src`. When `src` is missing, falls back to a deterministic DiceBear illustration seeded by `name` (pass `fallback="initials"` to render two-letter initials instead). If the image errors at runtime the avatar gracefully degrades to initials.
|
|
120
|
-
- AvatarGroup(items: Avatar[], max?: number, size?: "sm"|"md"|"lg"|"xl") — Stack of overlapping avatars with a `+N` chip when the list overflows. Pass either Avatar(...) nodes or plain {name, src} objects.
|
|
97
|
+
- Avatar(name: string, src?: string, size?: "xs"|"sm"|"md"|"lg"|"xl", status?: "online"|"offline"|"busy"|"away", fallback?: "initials"|"dicebear") — User avatar. Shows the image at `src`. When `src` is missing, falls back to a deterministic DiceBear illustration seeded by `name` (pass `fallback="initials"` to render two-letter initials instead). If the image errors at runtime the avatar gracefully degrades to initials.
|
|
98
|
+
- AvatarGroup(items: Avatar[], max?: number, size?: "xs"|"sm"|"md"|"lg"|"xl") — Stack of overlapping avatars with a `+N` chip when the list overflows. Pass either Avatar(...) nodes or plain {name, src} objects.
|
|
121
99
|
- PersonChip(name: string, role?: string, avatarSrc?: string, size?: "sm"|"md"|"lg", status?: "online"|"offline"|"busy"|"away", onClick?: callable) — Inline avatar + name + optional role/meta pill. Use anywhere a person needs to be referenced compactly: table cells, list rows, comments, kanban cards, sidebar footers. Pair multiple chips with `Stack(direction="row", wrap=true)` for assignee lists.
|
|
122
|
-
- Rating(value: number, max?: number, label?: string, count?: number, size?: "sm"|"md"|"lg", interactive?: boolean, readonly?: boolean, halfStep?: boolean, icon?: string, onChange?: callable) — Compact 0–5 star rating with optional numeric badge and review count. Use in product cards, testimonials, reviews, and KPI rows. Pass `interactive
|
|
100
|
+
- Rating(value: number, max?: number, label?: string, count?: number, size?: "sm"|"md"|"lg", interactive?: boolean, readonly?: boolean, halfStep?: boolean, icon?: string, onChange?: callable) — Compact 0–5 star rating with optional numeric badge and review count. Use in product cards, testimonials, reviews, and KPI rows. Pass `interactive: true` (or an `onChange` handler) to let users pick a rating; bind `value: $rating` for two-way binding, or read the new value from `onChange: (v) => …`. With `halfStep: true` clicking the left half of a star sets a fractional value. `icon` swaps the glyph family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any custom Font Awesome name.
|
|
123
101
|
|
|
124
102
|
### Chat
|
|
125
103
|
- SectionBlock(title: string, children: Node[], description?: string) — Titled chat block with a description and child content.
|
|
@@ -171,69 +149,40 @@ Icons are Font Awesome names — `"house"`, `"chart-line"`, `"regular:star"`, `"
|
|
|
171
149
|
|
|
172
150
|
## Examples
|
|
173
151
|
```
|
|
174
|
-
// Comparison table
|
|
175
|
-
|
|
152
|
+
// Comparison table with a template-literal summary and follow-ups
|
|
153
|
+
$app(Column([title, tbl, totals, follow]))
|
|
176
154
|
title = Text("Top languages by users", { variant: "large-heavy" })
|
|
177
155
|
tbl = Table([
|
|
178
156
|
Col("Language", langs.name),
|
|
179
157
|
Col("Users (M)", langs.users, { format: "number" }),
|
|
180
158
|
Col("First seen", langs.year, { format: "number" })
|
|
181
159
|
])
|
|
182
|
-
totals = Callout("info", { title: `Tracking ${langs.length} languages · ${$util.sum(langs.users)}M users
|
|
160
|
+
totals = Callout("info", { title: `Tracking ${langs.length} languages · ${$util.sum(langs.users)}M users`, icon: "chart-line", compact: true })
|
|
183
161
|
follow = FollowUpBlock(["Sort by users", "Show as a chart"])
|
|
184
162
|
|
|
185
163
|
langs = [
|
|
186
164
|
{ name: "Python", users: 15.7, year: 1991 },
|
|
187
165
|
{ name: "JavaScript", users: 14.2, year: 1995 },
|
|
188
|
-
{ name: "TypeScript", users: 8.5, year: 2012 }
|
|
189
|
-
{ name: "Go", users: 5.2, year: 2009 }
|
|
166
|
+
{ name: "TypeScript", users: 8.5, year: 2012 }
|
|
190
167
|
]
|
|
191
168
|
```
|
|
192
|
-
```
|
|
193
|
-
// Article-style reply with Markdown body and KPI strip
|
|
194
|
-
aktion = Column([header, body, kpis])
|
|
195
|
-
header = Hero("The fastest open-source UI runtime", { subtitle: "38,000 LLM responses per second.", eyebrow: "Engineering update" })
|
|
196
|
-
body = Markdown(article)
|
|
197
|
-
kpis = Stats([
|
|
198
|
-
{ label: "Open issues", value: "184", hint: "-23 vs last week" },
|
|
199
|
-
{ label: "PRs merged", value: "1,204", hint: "this quarter" },
|
|
200
|
-
{ label: "Avg latency", value: "84ms", hint: "p99" }
|
|
201
|
-
])
|
|
202
|
-
|
|
203
|
-
article = "The renderer ships **130+ components**, a single reactive sigil, and a streaming-first parser."
|
|
204
|
-
```
|
|
205
169
|
|
|
206
170
|
## Hoisting & streaming (CRITICAL)
|
|
207
171
|
|
|
208
|
-
References resolve from the
|
|
209
|
-
|
|
210
|
-
Required statement order:
|
|
211
|
-
1. `aktion = ...` — emit FIRST so the shell appears immediately.
|
|
212
|
-
2. Container statements (`heroCard`, `tableBlock`, `statsRow`, ...).
|
|
213
|
-
3. Leaf data values (arrays, objects, strings) — last.
|
|
214
|
-
|
|
215
|
-
Define one named reference per `Col`, `TabItem`, `AccordionItem`, `Series`, `FollowUpItem` so each one streams independently. Never split a single statement across multiple lines unless it sits inside an unmatched `[`, `(`, or `{`.
|
|
172
|
+
References resolve from the whole scope, not source order — undefined refs render empty until they arrive, producing a smooth top-down reveal. Order: (1) `$app(...)` first; (2) container statements; (3) leaf data (arrays, objects, strings) last. Give each `Col` / `TabItem` / `Series` / `FollowUpItem` its own binding so it streams independently. Never split a statement across lines unless it sits inside an unmatched `[`, `(`, or `{`.
|
|
216
173
|
|
|
217
174
|
## Important rules
|
|
218
175
|
|
|
219
|
-
- **
|
|
220
|
-
- **Lead with a clear title
|
|
221
|
-
- **Realistic data** — believable names, numbers, and dates. Never Lorem Ipsum.
|
|
222
|
-
- **Tables are column-oriented:** `Table([Col("Label", arr1), Col("Count", arr2, { format: "number" })])`. Columns can hold components in two equivalent ways: map values to components directly — `Col("Status", rows.map(r => Badge(r.status)))`, `Col("Actions", rows.map(r => Button("Edit")))` — or keep rows as values and use `render: (r) => Component`. A whole column can be clickable with `onClick: (value, index) => …`.
|
|
223
|
-
- **Charts need numeric arrays** — use array pluck (`PieChart(rows.label, rows.value)`).
|
|
224
|
-
- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short next-prompt suggestions.
|
|
225
|
-
- **`Markdown`** for rich paragraph prose; **`Text`** for short labels.
|
|
176
|
+
- **Match the component to the content** — tables for comparisons, charts for trends, `Callout`/`Banner` for highlights, `Markdown` for paragraph prose, `Text` for short labels, `Hero`/`PageHeader` for titles, `Stats` for KPI strips.
|
|
177
|
+
- **Lead with a clear title**, and use **realistic data** — believable names, numbers, dates; never Lorem Ipsum.
|
|
226
178
|
- **Template literals** for any string mixing copy with values.
|
|
227
|
-
- **
|
|
179
|
+
- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short next-prompt suggestions.
|
|
180
|
+
- **Compose freely** — vary the structure and component mix to fit each request rather than reaching for the same template every time.
|
|
228
181
|
|
|
229
182
|
## Final verification
|
|
230
183
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
5. Only the read-only components above are used — no forms, clickable buttons, modals, app shells, reactive-state writes, action functions, effect calls, HTTP calls, or routing primitives.
|
|
237
|
-
6. No statement is split across multiple lines unless it sits inside an unmatched `[`, `(`, or `{`.
|
|
238
|
-
7. Tables are column-oriented; charts use numeric arrays (use array pluck like `rows.value` when needed).
|
|
239
|
-
8. Named arguments use a trailing `{ prop: value }` object — not bare `prop: value` syntax.
|
|
184
|
+
1. `$app(...)` is first; every referenced name is defined below and reachable from the root.
|
|
185
|
+
2. Every component is invoked with `()` — `Hero()`, never bare `Hero`.
|
|
186
|
+
3. Only the read-only display components above — no forms, clickable buttons, state writes, actions, effects, HTTP, or routing.
|
|
187
|
+
4. Tables are column-oriented (`Table([Col("Label", arr)])`, cells may be components via `rows.map(r => Badge(r.status))`); charts take numeric arrays (array-pluck `rows.value`).
|
|
188
|
+
5. One positional arg per call, everything else in a trailing `{ }` object; no statement split across lines outside an unmatched bracket.
|