@wireweave/agent-prompts 0.1.1 → 0.2.0-beta.0
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 +17 -18
- package/dist/index.cjs +67 -16
- package/dist/index.js +67 -16
- package/package.json +22 -22
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# @wireweave/agent-prompts
|
|
2
2
|
|
|
3
|
-
Canonical grammar prompts
|
|
3
|
+
Canonical grammar-guide prompts that teach an LLM to generate Wireweave DSL.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
Exports the Wireweave DSL grammar guide as ready-to-inject prompt strings. Each function returns a single Markdown-flavoured string that you drop verbatim into an LLM system message so the model emits valid `.wf` wireframes — including the multi-page canvas model (multiple top-level `page` declarations, `at(x, y)` positioning, `viewport="WxH"`).
|
|
8
|
+
|
|
9
|
+
It is the single source of truth for the grammar guide; downstream consumers (`agent-harness`, `api-server`, future plugins) import it so they stay in sync with `@wireweave/core`. The package has no runtime dependencies.
|
|
4
10
|
|
|
5
11
|
## Install
|
|
6
12
|
|
|
@@ -8,36 +14,29 @@ Canonical grammar prompts for LLM agents that generate Wireweave DSL. The packag
|
|
|
8
14
|
pnpm add @wireweave/agent-prompts
|
|
9
15
|
```
|
|
10
16
|
|
|
11
|
-
##
|
|
17
|
+
## Usage
|
|
12
18
|
|
|
13
19
|
```ts
|
|
14
20
|
import { buildGrammarPrompt, buildCompactGrammarPrompt } from '@wireweave/agent-prompts'
|
|
15
21
|
|
|
16
|
-
// Full
|
|
22
|
+
// Full guide (~180 lines) — generation phase.
|
|
17
23
|
const system = buildGrammarPrompt()
|
|
18
24
|
|
|
19
|
-
// Compact
|
|
25
|
+
// Compact guide (~60 lines) — analyze / plan phases, fewer tokens.
|
|
20
26
|
const compact = buildCompactGrammarPrompt()
|
|
21
27
|
```
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
### `buildGrammarPrompt(): string`
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
The full grammar guide for the generation phase. Covers syntax structure, the multi-page canvas model, the renderer surface (`render` / `renderCanvas` / `renderPage`), the layout / content / form / nav / data / feedback / overlay / utility component contracts, and how to map common UI concepts to DSL components.
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
- **Multi-page canvas** — multiple top-level `page` declarations, `at(x, y)` positioning, `viewport="WxH"`.
|
|
29
|
-
- Renderer surface from `@wireweave/core`: `render(doc)` / `renderCanvas(doc)` / `renderPage(page)`.
|
|
30
|
-
- Layout / content / form / nav / data / feedback / overlay / utility component contracts.
|
|
31
|
-
- Mapping common UI concepts to DSL components.
|
|
35
|
+
### `buildCompactGrammarPrompt(): string`
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
A condensed grammar guide for the analyze / plan phases, where the full guide is more than needed.
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
`api-server/src/services/guide.ts`, `api-server/src/agent/prompts.ts`, and
|
|
37
|
-
`agent-harness/wireweave/src/guide.ts`. The agent-harness copy drifted to a
|
|
38
|
-
pre-3.0 single-page-only definition, which silently broke multi-screen
|
|
39
|
-
wireframe generation. Pulling the guide into its own package gives a single
|
|
40
|
-
versioned export every downstream consumer can pin.
|
|
39
|
+
Part of the [Wireweave monorepo](https://github.com/wireweave/wireweave).
|
|
41
40
|
|
|
42
41
|
## License
|
|
43
42
|
|
package/dist/index.cjs
CHANGED
|
@@ -91,26 +91,26 @@ stack: Layered container. Attrs: gap.
|
|
|
91
91
|
relative: Positioned container.
|
|
92
92
|
|
|
93
93
|
# CONTENT CONTAINERS
|
|
94
|
-
card: Bordered box. String arg for title. Attrs: p (0-8), w, h, shadow (none/sm/md/lg), border.
|
|
95
|
-
modal: Dialog. String arg for title. Attrs: w, h.
|
|
96
|
-
drawer: Slide panel. String arg for title. Attrs: w, position.
|
|
94
|
+
card: Bordered box. String arg for title. Attrs: p (0-8), w, h, shadow (none/sm/md/lg), border, navigate, opens, toggles, action.
|
|
95
|
+
modal: Dialog. String arg for title. Attrs: w, h, id (opens/toggles target).
|
|
96
|
+
drawer: Slide panel. String arg for title. Attrs: w, position, id (opens/toggles target).
|
|
97
97
|
accordion: Expandable section. String arg for title.
|
|
98
98
|
section: Grouped content. String arg for title.
|
|
99
99
|
|
|
100
100
|
# TEXT COMPONENTS
|
|
101
101
|
text: Inline text. String arg required. Attrs: size (xs/sm/base/md/lg/xl), weight (normal/medium/semibold/bold), muted, align.
|
|
102
102
|
title: Heading. String arg required. Attrs: level (1-6), size, align, mb, mt.
|
|
103
|
-
link: Hyperlink. String arg required. Attrs: href, external, ml, mr.
|
|
103
|
+
link: Hyperlink. String arg required. Attrs: href, external, ml, mr, navigate, opens, toggles, action.
|
|
104
104
|
|
|
105
105
|
# VISUAL COMPONENTS
|
|
106
|
-
icon: Lucide icon. String arg is icon name. Attrs: size (xs/sm/md/lg/xl), muted.
|
|
107
|
-
avatar: User avatar. String arg is name (shows initials). Attrs: size, src.
|
|
108
|
-
badge: Label tag. String arg required. Attrs: variant (default/primary/success/warning/danger), size, pill.
|
|
109
|
-
image: Image element. String arg is src. Attrs: w, h, alt.
|
|
106
|
+
icon: Lucide icon. String arg is icon name \u2014 must be a valid Lucide name in kebab-case (e.g. the overflow/kebab menu is "ellipsis-vertical", horizontal is "ellipsis"; not "more-vertical"). Unknown names render as a "?" placeholder. Attrs: size (xs/sm/md/lg/xl), muted, navigate, opens, toggles, action.
|
|
107
|
+
avatar: User avatar. String arg is name (shows initials). Attrs: size, src, navigate, opens, toggles, action.
|
|
108
|
+
badge: Label tag. String arg required. Attrs: variant (default/primary/success/warning/danger), size, pill, navigate, opens, toggles, action.
|
|
109
|
+
image: Image element. String arg is src. Attrs: w, h, alt, navigate, opens, toggles, action.
|
|
110
110
|
placeholder: Dashed box for images/media. String arg is label. Attrs: h, w.
|
|
111
111
|
|
|
112
112
|
# FORM COMPONENTS
|
|
113
|
-
button: Clickable button. String arg is label (empty "" for icon-only). Attrs: primary/secondary/outline/ghost/danger (boolean variants), icon, size (xs/sm/md/lg), disabled, w.
|
|
113
|
+
button: Clickable button. String arg is label (empty "" for icon-only). Attrs: primary/secondary/outline/ghost/danger (boolean variants), icon, size (xs/sm/md/lg), disabled, w, aria (accessible name for icon-only buttons \u2192 renders aria-label), title (tooltip), navigate, opens, toggles, action.
|
|
114
114
|
input: Text input. String arg is label. Attrs: placeholder, inputType (text/email/password/number/tel/url/search/date), icon, w, size, required, disabled.
|
|
115
115
|
select: Dropdown. String arg is label. Array arg for options. Attrs: placeholder, value.
|
|
116
116
|
checkbox: Checkbox. String arg is label. Attrs: checked, disabled.
|
|
@@ -123,7 +123,7 @@ textarea: Multiline input. String arg is label. Attrs: rows, placeholder.
|
|
|
123
123
|
nav: Menu. Array arg for simple items OR block with item children.
|
|
124
124
|
- Array syntax: nav ["Home", "About", "Contact"]
|
|
125
125
|
- Block syntax: nav { item "Label" icon="name" active }
|
|
126
|
-
item: Nav item (inside nav/dropdown block). String arg is label. Attrs: icon, active, disabled, href.
|
|
126
|
+
item: Nav item (inside nav/dropdown block). String arg is label. Attrs: icon, active, disabled, href, navigate, opens, toggles, action.
|
|
127
127
|
tabs: Tab bar. Array arg for labels. Attrs: active (0-based index).
|
|
128
128
|
- Block syntax: tabs { tab "Label" { children } }
|
|
129
129
|
breadcrumb: Path trail. Array arg for items.
|
|
@@ -184,9 +184,10 @@ col: syntax: col [gap=N] [flex=N] [span=N] [scroll] { children }
|
|
|
184
184
|
stack: syntax: stack [gap=N] { children }
|
|
185
185
|
- Unlike col, stack only takes content height (does not flex to fill space).
|
|
186
186
|
|
|
187
|
-
button: syntax: button "label" [variant] [size=SIZE] [icon="name"]
|
|
187
|
+
button: syntax: button "label" [variant] [size=SIZE] [icon="name"] [aria="Accessible name"]
|
|
188
188
|
- Variants are boolean attrs: primary, secondary, outline, ghost, danger.
|
|
189
|
-
- Icon-only: button "" icon="name" ghost (empty string required).
|
|
189
|
+
- Icon-only: button "" icon="name" aria="Action" ghost (empty string required).
|
|
190
|
+
- ALWAYS give an icon-only button an accessible name via aria="\u2026" (renders aria-label) so screen readers can describe it. title="\u2026" is a fallback.
|
|
190
191
|
- NOT: button icon="name" (missing string arg causes parse error).
|
|
191
192
|
|
|
192
193
|
input: syntax: input ["label"] [inputType=TYPE] [placeholder="text"]
|
|
@@ -198,15 +199,53 @@ nav: syntax: nav ["item1","item2"] [vertical] [active=N] OR nav { item "Label" i
|
|
|
198
199
|
- active: 0-based index of active item.
|
|
199
200
|
- Both array and block syntax are valid.
|
|
200
201
|
|
|
202
|
+
# INTERACTION WIRING
|
|
203
|
+
Every clickable element (button, link, card, icon, avatar, badge, image, nav/dropdown item) declares exactly ONE interaction attr:
|
|
204
|
+
- navigate="Page Title or URL": page transition. A value exactly matching another top-level page title links the screens; anything else is treated as a URL.
|
|
205
|
+
- opens="id": opens the modal/drawer with that id (same page).
|
|
206
|
+
- toggles="id": shows/hides the modal/drawer with that id (same page).
|
|
207
|
+
- action="name": named in-screen behavior (e.g. "submit", "logout", "delete"). action="none" marks a deliberately inert element.
|
|
208
|
+
modal/drawer need id="\u2026" to be reachable by opens/toggles.
|
|
209
|
+
|
|
210
|
+
\`\`\`
|
|
211
|
+
button "Sign in" primary action="submit"
|
|
212
|
+
button "Delete account" danger opens="confirm-delete"
|
|
213
|
+
modal "Confirm delete" id="confirm-delete" { text "Are you sure?" }
|
|
214
|
+
button "" icon="bell" aria="Notifications" ghost toggles="notif-drawer"
|
|
215
|
+
drawer "Notifications" id="notif-drawer" position=right { list ["No new notifications"] }
|
|
216
|
+
card "Order #1042" navigate="Order Detail" { text "2 items" }
|
|
217
|
+
link "Docs" navigate="https://docs.example.com"
|
|
218
|
+
nav vertical {
|
|
219
|
+
item "Dashboard" icon="home" navigate="Dashboard" active
|
|
220
|
+
item "Help" icon="info" opens="help-modal"
|
|
221
|
+
}
|
|
222
|
+
modal "Help" id="help-modal" { text "FAQ" }
|
|
223
|
+
dropdown {
|
|
224
|
+
item "Settings" navigate="Settings"
|
|
225
|
+
item "Logout" action="logout"
|
|
226
|
+
}
|
|
227
|
+
\`\`\`
|
|
228
|
+
|
|
229
|
+
# LAYOUT GUIDANCE
|
|
230
|
+
Wireframes are judged on layout quality, not just valid syntax. Follow these composition rules:
|
|
231
|
+
|
|
232
|
+
- ADAPTIVE TARGET-N GRID: When showing N peer items (cards, tiles, stat boxes, product thumbnails), lay them out as an even grid whose column count fits N \u2014 do NOT stack everything in one column. Use a row with equal-width children: row gap=4 { col flex=1 { \u2026 } col flex=1 { \u2026 } col flex=1 { \u2026 } } gives 3 equal columns. For many items, add wrap so they reflow into rows of equal columns: row gap=4 wrap { /* each item a fixed-width or flex card */ }. Keep every column the same width (flex=1, or span out of 12) and one consistent gap.
|
|
233
|
+
- SYMMETRIC MARGINS & SPACING: Use consistent, symmetric padding and gaps. Give header/main/footer the same horizontal padding (e.g. p=4) so content edges line up. Use ONE gap value within a group rather than ad-hoc per-item margins. Left and right insets should match; avoid lopsided spacing.
|
|
234
|
+
- CHAT-REGION COMPOSITION: A chat / conversation / messaging screen is three stacked regions: (1) header with the contact/title, (2) main scroll holding the message list (alternate alignment \u2014 incoming left, outgoing right), and (3) a bottom input bar as a row pinned below main: row gap=2 { input "" placeholder="Message" flex=1 button "" icon="send" aria="Send" primary }. The composer is its OWN row outside the scroll area, never inside the message list.
|
|
235
|
+
- INPUT SIZING: Inputs, selects and textareas in a form should fill their container \u2014 w="full" when stacked in a col, or flex=1 when sharing a row with a button. Keep a consistent size across one form. A search field uses input with icon="search".
|
|
236
|
+
- ACCESSIBLE ICON BUTTONS: Every icon-only button needs an accessible name: button "" icon="x" aria="Close" ghost.
|
|
237
|
+
|
|
201
238
|
# CONSTRAINTS
|
|
202
|
-
DO: Emit multiple top-level page declarations when the user asks for multiple screens. Use viewport="WxH" or at(x, y) to position them. Use semantic layout (header, main, sidebar, footer). Use row/col for flex layouts. Quote all strings with double quotes. Write booleans without =true. Use inputType NOT type. Use w/h on components (width/height only on page).
|
|
239
|
+
DO: Emit multiple top-level page declarations when the user asks for multiple screens. Use viewport="WxH" or at(x, y) to position them. Use semantic layout (header, main, sidebar, footer). Use row/col for flex layouts. Quote all strings with double quotes. Write booleans without =true. Use inputType NOT type. Use w/h on components (width/height only on page). Wire every clickable element with exactly one interaction attr (navigate/opens/toggles/action).
|
|
203
240
|
DO NOT: Use components not in the spec. Quote numeric values. Quote enum values (start, center, between etc). Write boolean=true. Nest page inside page. Use HTML / CSS / JSX syntax. Collapse multi-view apps into one page with a sidebar tab switcher (use separate top-level pages instead).
|
|
204
241
|
|
|
205
242
|
# MAPPING UI TO COMPONENTS
|
|
206
243
|
- Photos / images / thumbnails -> placeholder with h and w
|
|
207
244
|
- Maps / charts / graphs -> placeholder
|
|
208
245
|
- Filter chips / tags -> badge
|
|
209
|
-
- Icon buttons -> button "" icon="name" ghost
|
|
246
|
+
- Icon buttons -> button "" icon="name" aria="Action" ghost (always give an accessible name)
|
|
247
|
+
- Grid of N peer items -> row [wrap] with equal col flex=1 children (column count fits N)
|
|
248
|
+
- Chat / messaging screen -> header + main scroll (message list) + bottom row { input flex=1 button "" icon="send" aria="Send" }
|
|
210
249
|
- Search box -> input with icon="search"
|
|
211
250
|
- Logo area -> icon or placeholder
|
|
212
251
|
- Multiple distinct screens -> multiple top-level page declarations (one per screen)`;
|
|
@@ -228,7 +267,7 @@ function buildCompactGrammarPrompt() {
|
|
|
228
267
|
- Multi-view apps default to separate top-level pages (not sidebar collapse).
|
|
229
268
|
|
|
230
269
|
# LAYOUT: page(at, viewport, width, height, device, centered), header(h, border), main(p, scroll), footer(h, border), sidebar(w, border, position), section, row(gap, justify, align, wrap), col(gap, flex, span), stack, relative
|
|
231
|
-
# CONTAINERS: card(p, shadow), modal(w), drawer(w, position), accordion
|
|
270
|
+
# CONTAINERS: card(p, shadow), modal(w, id), drawer(w, position, id), accordion
|
|
232
271
|
# TEXT: text(size, weight, muted), title(level), link(href)
|
|
233
272
|
# VISUAL: icon(Lucide name), avatar(size), badge(variant), image, placeholder(h, w)
|
|
234
273
|
# FORM: button(primary/danger/outline/ghost, icon, size), input(inputType, placeholder), select, checkbox, radio, switch, slider, textarea
|
|
@@ -237,11 +276,23 @@ function buildCompactGrammarPrompt() {
|
|
|
237
276
|
# FEEDBACK: alert(variant), toast, progress(value), spinner
|
|
238
277
|
# UTILITY: divider
|
|
239
278
|
|
|
279
|
+
# INTERACTIONS
|
|
280
|
+
- Every clickable element (button, link, card, icon, avatar, badge, image, nav/dropdown item) declares exactly ONE of: navigate="Page Title or URL" | opens="modal/drawer id" | toggles="modal/drawer id" | action="name" ("none" = deliberately inert).
|
|
281
|
+
- modal/drawer take id="\u2026" as the opens/toggles target.
|
|
282
|
+
- nav { item "Home" navigate="Home" } dropdown { item "Logout" action="logout" }
|
|
283
|
+
|
|
284
|
+
# LAYOUT GUIDANCE
|
|
285
|
+
- Grid of N peer items: row [wrap] with equal col flex=1 children (column count fits N) \u2014 don't stack peers in one column.
|
|
286
|
+
- Symmetric spacing: same horizontal padding on header/main/footer; one consistent gap per group; match left/right insets.
|
|
287
|
+
- Chat screen: header + main scroll (message list, incoming left / outgoing right) + bottom composer row { input flex=1 button "" icon="send" aria="Send" } OUTSIDE the scroll area.
|
|
288
|
+
- Input sizing: inputs/selects fill their container (w="full" stacked, flex=1 in a row); consistent size per form.
|
|
289
|
+
|
|
240
290
|
# KEY RULES
|
|
241
291
|
- sidebar: direct child of row, w=240, border.
|
|
242
292
|
- nav in sidebar: must have vertical.
|
|
243
293
|
- cards in row: flex=1 for equal width.
|
|
244
|
-
- icon-only button: button "" icon="name" ghost.
|
|
294
|
+
- icon-only button: button "" icon="name" aria="Action" ghost (aria = accessible name).
|
|
295
|
+
- every clickable element: exactly one of navigate/opens/toggles/action.
|
|
245
296
|
- inputType (not type) for inputs.
|
|
246
297
|
- viewport (not width/height) when emitting multi-page canvas.
|
|
247
298
|
- Multiple screens \u2192 multiple top-level pages, not nested pages.
|
package/dist/index.js
CHANGED
|
@@ -64,26 +64,26 @@ stack: Layered container. Attrs: gap.
|
|
|
64
64
|
relative: Positioned container.
|
|
65
65
|
|
|
66
66
|
# CONTENT CONTAINERS
|
|
67
|
-
card: Bordered box. String arg for title. Attrs: p (0-8), w, h, shadow (none/sm/md/lg), border.
|
|
68
|
-
modal: Dialog. String arg for title. Attrs: w, h.
|
|
69
|
-
drawer: Slide panel. String arg for title. Attrs: w, position.
|
|
67
|
+
card: Bordered box. String arg for title. Attrs: p (0-8), w, h, shadow (none/sm/md/lg), border, navigate, opens, toggles, action.
|
|
68
|
+
modal: Dialog. String arg for title. Attrs: w, h, id (opens/toggles target).
|
|
69
|
+
drawer: Slide panel. String arg for title. Attrs: w, position, id (opens/toggles target).
|
|
70
70
|
accordion: Expandable section. String arg for title.
|
|
71
71
|
section: Grouped content. String arg for title.
|
|
72
72
|
|
|
73
73
|
# TEXT COMPONENTS
|
|
74
74
|
text: Inline text. String arg required. Attrs: size (xs/sm/base/md/lg/xl), weight (normal/medium/semibold/bold), muted, align.
|
|
75
75
|
title: Heading. String arg required. Attrs: level (1-6), size, align, mb, mt.
|
|
76
|
-
link: Hyperlink. String arg required. Attrs: href, external, ml, mr.
|
|
76
|
+
link: Hyperlink. String arg required. Attrs: href, external, ml, mr, navigate, opens, toggles, action.
|
|
77
77
|
|
|
78
78
|
# VISUAL COMPONENTS
|
|
79
|
-
icon: Lucide icon. String arg is icon name. Attrs: size (xs/sm/md/lg/xl), muted.
|
|
80
|
-
avatar: User avatar. String arg is name (shows initials). Attrs: size, src.
|
|
81
|
-
badge: Label tag. String arg required. Attrs: variant (default/primary/success/warning/danger), size, pill.
|
|
82
|
-
image: Image element. String arg is src. Attrs: w, h, alt.
|
|
79
|
+
icon: Lucide icon. String arg is icon name \u2014 must be a valid Lucide name in kebab-case (e.g. the overflow/kebab menu is "ellipsis-vertical", horizontal is "ellipsis"; not "more-vertical"). Unknown names render as a "?" placeholder. Attrs: size (xs/sm/md/lg/xl), muted, navigate, opens, toggles, action.
|
|
80
|
+
avatar: User avatar. String arg is name (shows initials). Attrs: size, src, navigate, opens, toggles, action.
|
|
81
|
+
badge: Label tag. String arg required. Attrs: variant (default/primary/success/warning/danger), size, pill, navigate, opens, toggles, action.
|
|
82
|
+
image: Image element. String arg is src. Attrs: w, h, alt, navigate, opens, toggles, action.
|
|
83
83
|
placeholder: Dashed box for images/media. String arg is label. Attrs: h, w.
|
|
84
84
|
|
|
85
85
|
# FORM COMPONENTS
|
|
86
|
-
button: Clickable button. String arg is label (empty "" for icon-only). Attrs: primary/secondary/outline/ghost/danger (boolean variants), icon, size (xs/sm/md/lg), disabled, w.
|
|
86
|
+
button: Clickable button. String arg is label (empty "" for icon-only). Attrs: primary/secondary/outline/ghost/danger (boolean variants), icon, size (xs/sm/md/lg), disabled, w, aria (accessible name for icon-only buttons \u2192 renders aria-label), title (tooltip), navigate, opens, toggles, action.
|
|
87
87
|
input: Text input. String arg is label. Attrs: placeholder, inputType (text/email/password/number/tel/url/search/date), icon, w, size, required, disabled.
|
|
88
88
|
select: Dropdown. String arg is label. Array arg for options. Attrs: placeholder, value.
|
|
89
89
|
checkbox: Checkbox. String arg is label. Attrs: checked, disabled.
|
|
@@ -96,7 +96,7 @@ textarea: Multiline input. String arg is label. Attrs: rows, placeholder.
|
|
|
96
96
|
nav: Menu. Array arg for simple items OR block with item children.
|
|
97
97
|
- Array syntax: nav ["Home", "About", "Contact"]
|
|
98
98
|
- Block syntax: nav { item "Label" icon="name" active }
|
|
99
|
-
item: Nav item (inside nav/dropdown block). String arg is label. Attrs: icon, active, disabled, href.
|
|
99
|
+
item: Nav item (inside nav/dropdown block). String arg is label. Attrs: icon, active, disabled, href, navigate, opens, toggles, action.
|
|
100
100
|
tabs: Tab bar. Array arg for labels. Attrs: active (0-based index).
|
|
101
101
|
- Block syntax: tabs { tab "Label" { children } }
|
|
102
102
|
breadcrumb: Path trail. Array arg for items.
|
|
@@ -157,9 +157,10 @@ col: syntax: col [gap=N] [flex=N] [span=N] [scroll] { children }
|
|
|
157
157
|
stack: syntax: stack [gap=N] { children }
|
|
158
158
|
- Unlike col, stack only takes content height (does not flex to fill space).
|
|
159
159
|
|
|
160
|
-
button: syntax: button "label" [variant] [size=SIZE] [icon="name"]
|
|
160
|
+
button: syntax: button "label" [variant] [size=SIZE] [icon="name"] [aria="Accessible name"]
|
|
161
161
|
- Variants are boolean attrs: primary, secondary, outline, ghost, danger.
|
|
162
|
-
- Icon-only: button "" icon="name" ghost (empty string required).
|
|
162
|
+
- Icon-only: button "" icon="name" aria="Action" ghost (empty string required).
|
|
163
|
+
- ALWAYS give an icon-only button an accessible name via aria="\u2026" (renders aria-label) so screen readers can describe it. title="\u2026" is a fallback.
|
|
163
164
|
- NOT: button icon="name" (missing string arg causes parse error).
|
|
164
165
|
|
|
165
166
|
input: syntax: input ["label"] [inputType=TYPE] [placeholder="text"]
|
|
@@ -171,15 +172,53 @@ nav: syntax: nav ["item1","item2"] [vertical] [active=N] OR nav { item "Label" i
|
|
|
171
172
|
- active: 0-based index of active item.
|
|
172
173
|
- Both array and block syntax are valid.
|
|
173
174
|
|
|
175
|
+
# INTERACTION WIRING
|
|
176
|
+
Every clickable element (button, link, card, icon, avatar, badge, image, nav/dropdown item) declares exactly ONE interaction attr:
|
|
177
|
+
- navigate="Page Title or URL": page transition. A value exactly matching another top-level page title links the screens; anything else is treated as a URL.
|
|
178
|
+
- opens="id": opens the modal/drawer with that id (same page).
|
|
179
|
+
- toggles="id": shows/hides the modal/drawer with that id (same page).
|
|
180
|
+
- action="name": named in-screen behavior (e.g. "submit", "logout", "delete"). action="none" marks a deliberately inert element.
|
|
181
|
+
modal/drawer need id="\u2026" to be reachable by opens/toggles.
|
|
182
|
+
|
|
183
|
+
\`\`\`
|
|
184
|
+
button "Sign in" primary action="submit"
|
|
185
|
+
button "Delete account" danger opens="confirm-delete"
|
|
186
|
+
modal "Confirm delete" id="confirm-delete" { text "Are you sure?" }
|
|
187
|
+
button "" icon="bell" aria="Notifications" ghost toggles="notif-drawer"
|
|
188
|
+
drawer "Notifications" id="notif-drawer" position=right { list ["No new notifications"] }
|
|
189
|
+
card "Order #1042" navigate="Order Detail" { text "2 items" }
|
|
190
|
+
link "Docs" navigate="https://docs.example.com"
|
|
191
|
+
nav vertical {
|
|
192
|
+
item "Dashboard" icon="home" navigate="Dashboard" active
|
|
193
|
+
item "Help" icon="info" opens="help-modal"
|
|
194
|
+
}
|
|
195
|
+
modal "Help" id="help-modal" { text "FAQ" }
|
|
196
|
+
dropdown {
|
|
197
|
+
item "Settings" navigate="Settings"
|
|
198
|
+
item "Logout" action="logout"
|
|
199
|
+
}
|
|
200
|
+
\`\`\`
|
|
201
|
+
|
|
202
|
+
# LAYOUT GUIDANCE
|
|
203
|
+
Wireframes are judged on layout quality, not just valid syntax. Follow these composition rules:
|
|
204
|
+
|
|
205
|
+
- ADAPTIVE TARGET-N GRID: When showing N peer items (cards, tiles, stat boxes, product thumbnails), lay them out as an even grid whose column count fits N \u2014 do NOT stack everything in one column. Use a row with equal-width children: row gap=4 { col flex=1 { \u2026 } col flex=1 { \u2026 } col flex=1 { \u2026 } } gives 3 equal columns. For many items, add wrap so they reflow into rows of equal columns: row gap=4 wrap { /* each item a fixed-width or flex card */ }. Keep every column the same width (flex=1, or span out of 12) and one consistent gap.
|
|
206
|
+
- SYMMETRIC MARGINS & SPACING: Use consistent, symmetric padding and gaps. Give header/main/footer the same horizontal padding (e.g. p=4) so content edges line up. Use ONE gap value within a group rather than ad-hoc per-item margins. Left and right insets should match; avoid lopsided spacing.
|
|
207
|
+
- CHAT-REGION COMPOSITION: A chat / conversation / messaging screen is three stacked regions: (1) header with the contact/title, (2) main scroll holding the message list (alternate alignment \u2014 incoming left, outgoing right), and (3) a bottom input bar as a row pinned below main: row gap=2 { input "" placeholder="Message" flex=1 button "" icon="send" aria="Send" primary }. The composer is its OWN row outside the scroll area, never inside the message list.
|
|
208
|
+
- INPUT SIZING: Inputs, selects and textareas in a form should fill their container \u2014 w="full" when stacked in a col, or flex=1 when sharing a row with a button. Keep a consistent size across one form. A search field uses input with icon="search".
|
|
209
|
+
- ACCESSIBLE ICON BUTTONS: Every icon-only button needs an accessible name: button "" icon="x" aria="Close" ghost.
|
|
210
|
+
|
|
174
211
|
# CONSTRAINTS
|
|
175
|
-
DO: Emit multiple top-level page declarations when the user asks for multiple screens. Use viewport="WxH" or at(x, y) to position them. Use semantic layout (header, main, sidebar, footer). Use row/col for flex layouts. Quote all strings with double quotes. Write booleans without =true. Use inputType NOT type. Use w/h on components (width/height only on page).
|
|
212
|
+
DO: Emit multiple top-level page declarations when the user asks for multiple screens. Use viewport="WxH" or at(x, y) to position them. Use semantic layout (header, main, sidebar, footer). Use row/col for flex layouts. Quote all strings with double quotes. Write booleans without =true. Use inputType NOT type. Use w/h on components (width/height only on page). Wire every clickable element with exactly one interaction attr (navigate/opens/toggles/action).
|
|
176
213
|
DO NOT: Use components not in the spec. Quote numeric values. Quote enum values (start, center, between etc). Write boolean=true. Nest page inside page. Use HTML / CSS / JSX syntax. Collapse multi-view apps into one page with a sidebar tab switcher (use separate top-level pages instead).
|
|
177
214
|
|
|
178
215
|
# MAPPING UI TO COMPONENTS
|
|
179
216
|
- Photos / images / thumbnails -> placeholder with h and w
|
|
180
217
|
- Maps / charts / graphs -> placeholder
|
|
181
218
|
- Filter chips / tags -> badge
|
|
182
|
-
- Icon buttons -> button "" icon="name" ghost
|
|
219
|
+
- Icon buttons -> button "" icon="name" aria="Action" ghost (always give an accessible name)
|
|
220
|
+
- Grid of N peer items -> row [wrap] with equal col flex=1 children (column count fits N)
|
|
221
|
+
- Chat / messaging screen -> header + main scroll (message list) + bottom row { input flex=1 button "" icon="send" aria="Send" }
|
|
183
222
|
- Search box -> input with icon="search"
|
|
184
223
|
- Logo area -> icon or placeholder
|
|
185
224
|
- Multiple distinct screens -> multiple top-level page declarations (one per screen)`;
|
|
@@ -201,7 +240,7 @@ function buildCompactGrammarPrompt() {
|
|
|
201
240
|
- Multi-view apps default to separate top-level pages (not sidebar collapse).
|
|
202
241
|
|
|
203
242
|
# LAYOUT: page(at, viewport, width, height, device, centered), header(h, border), main(p, scroll), footer(h, border), sidebar(w, border, position), section, row(gap, justify, align, wrap), col(gap, flex, span), stack, relative
|
|
204
|
-
# CONTAINERS: card(p, shadow), modal(w), drawer(w, position), accordion
|
|
243
|
+
# CONTAINERS: card(p, shadow), modal(w, id), drawer(w, position, id), accordion
|
|
205
244
|
# TEXT: text(size, weight, muted), title(level), link(href)
|
|
206
245
|
# VISUAL: icon(Lucide name), avatar(size), badge(variant), image, placeholder(h, w)
|
|
207
246
|
# FORM: button(primary/danger/outline/ghost, icon, size), input(inputType, placeholder), select, checkbox, radio, switch, slider, textarea
|
|
@@ -210,11 +249,23 @@ function buildCompactGrammarPrompt() {
|
|
|
210
249
|
# FEEDBACK: alert(variant), toast, progress(value), spinner
|
|
211
250
|
# UTILITY: divider
|
|
212
251
|
|
|
252
|
+
# INTERACTIONS
|
|
253
|
+
- Every clickable element (button, link, card, icon, avatar, badge, image, nav/dropdown item) declares exactly ONE of: navigate="Page Title or URL" | opens="modal/drawer id" | toggles="modal/drawer id" | action="name" ("none" = deliberately inert).
|
|
254
|
+
- modal/drawer take id="\u2026" as the opens/toggles target.
|
|
255
|
+
- nav { item "Home" navigate="Home" } dropdown { item "Logout" action="logout" }
|
|
256
|
+
|
|
257
|
+
# LAYOUT GUIDANCE
|
|
258
|
+
- Grid of N peer items: row [wrap] with equal col flex=1 children (column count fits N) \u2014 don't stack peers in one column.
|
|
259
|
+
- Symmetric spacing: same horizontal padding on header/main/footer; one consistent gap per group; match left/right insets.
|
|
260
|
+
- Chat screen: header + main scroll (message list, incoming left / outgoing right) + bottom composer row { input flex=1 button "" icon="send" aria="Send" } OUTSIDE the scroll area.
|
|
261
|
+
- Input sizing: inputs/selects fill their container (w="full" stacked, flex=1 in a row); consistent size per form.
|
|
262
|
+
|
|
213
263
|
# KEY RULES
|
|
214
264
|
- sidebar: direct child of row, w=240, border.
|
|
215
265
|
- nav in sidebar: must have vertical.
|
|
216
266
|
- cards in row: flex=1 for equal width.
|
|
217
|
-
- icon-only button: button "" icon="name" ghost.
|
|
267
|
+
- icon-only button: button "" icon="name" aria="Action" ghost (aria = accessible name).
|
|
268
|
+
- every clickable element: exactly one of navigate/opens/toggles/action.
|
|
218
269
|
- inputType (not type) for inputs.
|
|
219
270
|
- viewport (not width/height) when emitting multi-page canvas.
|
|
220
271
|
- Multiple screens \u2192 multiple top-level pages, not nested pages.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wireweave/agent-prompts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
4
|
"description": "Canonical grammar prompts for LLM agents generating Wireweave DSL (multi-page aware)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,23 +22,6 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup",
|
|
27
|
-
"test": "vitest run",
|
|
28
|
-
"test:watch": "vitest",
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
30
|
-
"lint": "eslint .",
|
|
31
|
-
"lint:fix": "eslint . --fix",
|
|
32
|
-
"format": "prettier --write .",
|
|
33
|
-
"format:check": "prettier --check .",
|
|
34
|
-
"knip": "knip",
|
|
35
|
-
"publint": "publint",
|
|
36
|
-
"packlint": "packlint check",
|
|
37
|
-
"clean": "rm -rf dist",
|
|
38
|
-
"release": "release-it",
|
|
39
|
-
"release:beta": "release-it --preRelease=beta",
|
|
40
|
-
"prepare": "husky"
|
|
41
|
-
},
|
|
42
25
|
"lint-staged": {
|
|
43
26
|
"*.{ts,js,mjs,cjs}": [
|
|
44
27
|
"eslint --fix",
|
|
@@ -79,10 +62,27 @@
|
|
|
79
62
|
"license": "MIT",
|
|
80
63
|
"repository": {
|
|
81
64
|
"type": "git",
|
|
82
|
-
"url": "git+https://github.com/wireweave/
|
|
65
|
+
"url": "git+https://github.com/wireweave/wireweave.git",
|
|
66
|
+
"directory": "packages/agent-prompts"
|
|
83
67
|
},
|
|
84
68
|
"bugs": {
|
|
85
|
-
"url": "https://github.com/wireweave/
|
|
69
|
+
"url": "https://github.com/wireweave/wireweave/issues"
|
|
86
70
|
},
|
|
87
|
-
"homepage": "https://
|
|
88
|
-
|
|
71
|
+
"homepage": "https://docs.wireweave.org",
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsup",
|
|
74
|
+
"test": "vitest run",
|
|
75
|
+
"test:watch": "vitest",
|
|
76
|
+
"typecheck": "tsc --noEmit",
|
|
77
|
+
"lint": "eslint .",
|
|
78
|
+
"lint:fix": "eslint . --fix",
|
|
79
|
+
"format": "prettier --write .",
|
|
80
|
+
"format:check": "prettier --check .",
|
|
81
|
+
"knip": "knip",
|
|
82
|
+
"publint": "publint",
|
|
83
|
+
"packlint": "packlint check",
|
|
84
|
+
"clean": "rm -rf dist",
|
|
85
|
+
"release": "release-it",
|
|
86
|
+
"release:beta": "release-it --preRelease=beta"
|
|
87
|
+
}
|
|
88
|
+
}
|