@wireweave/agent-prompts 0.2.0-beta.1 → 0.2.0-beta.3

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/dist/index.cjs CHANGED
@@ -78,17 +78,15 @@ Renderer modes (the host picks one; you only need to emit valid pages):
78
78
  - renderCanvas(doc) \u2014 composes all pages into one bounded canvas.
79
79
  - renderPage(page) \u2014 single-page export primitive (1 page = 1 file).
80
80
 
81
- # SHARED PAGE LAYOUTS
82
- When several pages share a shell, define it once as a top-level layout and put
83
- the varying page content at its slot. Layout definitions and pages are siblings;
84
- a layout is not a screen by itself.
81
+ # REUSE \u2014 DEFINE THE SHELL ONCE
82
+ Screens in one .wf file share a shell (header, sidebar, footer). Restating it on every page is the single biggest source of bloat, so declare it once and reference it.
85
83
 
86
- - layout NAME { ... slot ... } \u2014 a named page shell. NAME is a bare identifier.
87
- - slot \u2014 a bare positional marker inside a layout. It takes no name and no braces.
88
- - page "Title" uses=NAME { ... } \u2014 draw the page inside layout NAME; the page body
89
- contains only the content unique to that screen.
90
-
91
- Example:
84
+ - layout NAME { \u2026 slot \u2026 } \u2014 a named page shell. The name is a bare identifier, NOT a quoted string.
85
+ - slot \u2014 a bare positional marker inside a layout, marking where a referencing page's own content goes. It takes no name and no braces.
86
+ - component NAME { \u2026 } \u2014 a named fragment defined once and referenced by name instead of restated.
87
+ - component NAME(param: string, other: number) { \u2026 } \u2014 declare typed parameters so one fragment serves several call sites. Types are string, number, boolean.
88
+ - use NAME(arg="value") { \u2026 } \u2014 draw a component defined above. Arguments are parenthesized name=value pairs; the optional braces fill the component's slots.
89
+ - page "Title" uses=NAME { \u2026 } \u2014 draw this page inside layout NAME. The page body holds only what is unique to that screen.
92
90
 
93
91
  \`\`\`
94
92
  layout app {
@@ -99,7 +97,37 @@ layout app {
99
97
 
100
98
  page "Home" uses=app { text "Welcome back" }
101
99
  page "Docs" uses=app { text "Getting started" }
100
+ page "About" uses=app { text "Who we are" }
101
+ \`\`\`
102
+
103
+ Parameters \u2014 ALWAYS QUOTE A $ REFERENCE:
104
+ Inside a component body, "$param" stands for the value the call site passed. The reference must be the whole quoted string.
105
+
102
106
  \`\`\`
107
+ component navcard(label: string, to: string) {
108
+ card {
109
+ title "$label"
110
+ button "Open" navigate="$to"
111
+ button "Go" on={event=click, effects=[{kind=navigate, target="$to"}]}
112
+ }
113
+ }
114
+
115
+ page "Home" {
116
+ use navcard(label="Reports", to="Reports")
117
+ use navcard(label="Settings", to="Settings")
118
+ }
119
+ \`\`\`
120
+
121
+ - WRITE target="$to" \u2014 quoted. A quoted reference works ANYWHERE a value goes, including nested places like an effect target.
122
+ - NEVER write target=$to \u2014 bare. An identifier cannot begin with $, so the file FAILS TO PARSE with a syntax error.
123
+ - "$to" substitutes only as an entire value. "go to $to" is literal text, not a reference.
124
+ - Every "$name" must match a declared parameter. An undeclared name is a validation error, so check the spelling against the component's parameter list.
125
+
126
+ Rules:
127
+ - layout and component are TOP-LEVEL only \u2014 siblings of page, never nested inside one.
128
+ - Define a layout as soon as two or more pages share a shell. Three pages that each repeat a header is a defect, not a style.
129
+ - A page with uses= must NOT restate the shell; put only its own content in the body.
130
+ - A layout has exactly the structure a page would have, with slot standing in for the varying part.
103
131
 
104
132
  # LAYOUT COMPONENTS
105
133
  page: Root container. Attrs: title (string arg), uses (layout name), at(x, y), viewport, width, height (pixels), device (mobile/tablet/desktop preset), centered (boolean).
@@ -289,15 +317,18 @@ function buildCompactGrammarPrompt() {
289
317
  - Use viewport="WxH" per page; omit at() to auto-flow, use at(x, y) to pin.
290
318
  - Multi-view apps default to separate top-level pages (not sidebar collapse).
291
319
 
292
- # SHARED PAGE LAYOUTS: layout NAME { \u2026 slot \u2026 } defines a top-level shell; slot is a bare marker with no name or braces; page "Title" uses=NAME { \u2026 } places that page inside the shell. Layouts and pages are top-level siblings.
320
+ # REUSE: layout NAME { \u2026 } defines a shared shell (name is a bare identifier, not a quoted string); slot marks where a referencing page's own content goes inside that shell (bare keyword, no name, no braces); component NAME { \u2026 } defines a reusable fragment; use NAME(arg="value") { \u2026 } draws that fragment, passing parenthesized arguments and optionally filling its slots; page "Title" uses=NAME draws that page inside the layout and states only its own content. layout/component are top-level siblings of page. Two or more pages sharing a shell \u2192 define a layout instead of repeating it.
321
+ # PARAMETERS: component NAME(label: string, to: string) { \u2026 } declares typed parameters (string/number/boolean); inside the body "$label" stands for the passed value. ALWAYS quote the reference \u2014 navigate="$to" and target="$to" work anywhere, including nested effect targets. NEVER write it bare (navigate=$to): an identifier cannot start with $, so the file fails to parse. A reference must be the whole value ("go to $to" is literal text), and every "$name" must match a declared parameter or validation fails.
293
322
  # LAYOUT: page(at, viewport, width, height, device, centered, uses), 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
294
323
  # CONTAINERS: card(p, shadow), modal(w, id), drawer(w, position, id), accordion
295
324
  # TEXT: text(size, weight, muted), title(level), link(href)
296
325
  # VISUAL: icon(Lucide name), avatar(size), badge(variant), image, placeholder(h, w)
297
326
  # FORM: button(primary/danger/outline/ghost, icon, size), input(inputType, placeholder), select, checkbox, radio, switch, slider, textarea
298
- # NAV: nav(vertical, active) with array ["Item1","Item2"], tabs(active), breadcrumb, dropdown
327
+ # NAV: nav(vertical, active) with array ["Item1","Item2"], item(icon, active, disabled, href) inside a nav/dropdown block, tabs(active) with tab children, breadcrumb, dropdown
299
328
  # DATA: table with 2D array, list with array
300
329
  # FEEDBACK: alert(variant), toast, progress(value), spinner
330
+ # OVERLAY: tooltip(position), popover(title)
331
+ # ANNOTATION: marker(number arg, anchor, color), annotations(title) { item N "Title" { text "\u2026" } }
301
332
  # UTILITY: divider
302
333
 
303
334
  # INTERACTIONS
package/dist/index.js CHANGED
@@ -51,17 +51,15 @@ Renderer modes (the host picks one; you only need to emit valid pages):
51
51
  - renderCanvas(doc) \u2014 composes all pages into one bounded canvas.
52
52
  - renderPage(page) \u2014 single-page export primitive (1 page = 1 file).
53
53
 
54
- # SHARED PAGE LAYOUTS
55
- When several pages share a shell, define it once as a top-level layout and put
56
- the varying page content at its slot. Layout definitions and pages are siblings;
57
- a layout is not a screen by itself.
54
+ # REUSE \u2014 DEFINE THE SHELL ONCE
55
+ Screens in one .wf file share a shell (header, sidebar, footer). Restating it on every page is the single biggest source of bloat, so declare it once and reference it.
58
56
 
59
- - layout NAME { ... slot ... } \u2014 a named page shell. NAME is a bare identifier.
60
- - slot \u2014 a bare positional marker inside a layout. It takes no name and no braces.
61
- - page "Title" uses=NAME { ... } \u2014 draw the page inside layout NAME; the page body
62
- contains only the content unique to that screen.
63
-
64
- Example:
57
+ - layout NAME { \u2026 slot \u2026 } \u2014 a named page shell. The name is a bare identifier, NOT a quoted string.
58
+ - slot \u2014 a bare positional marker inside a layout, marking where a referencing page's own content goes. It takes no name and no braces.
59
+ - component NAME { \u2026 } \u2014 a named fragment defined once and referenced by name instead of restated.
60
+ - component NAME(param: string, other: number) { \u2026 } \u2014 declare typed parameters so one fragment serves several call sites. Types are string, number, boolean.
61
+ - use NAME(arg="value") { \u2026 } \u2014 draw a component defined above. Arguments are parenthesized name=value pairs; the optional braces fill the component's slots.
62
+ - page "Title" uses=NAME { \u2026 } \u2014 draw this page inside layout NAME. The page body holds only what is unique to that screen.
65
63
 
66
64
  \`\`\`
67
65
  layout app {
@@ -72,8 +70,38 @@ layout app {
72
70
 
73
71
  page "Home" uses=app { text "Welcome back" }
74
72
  page "Docs" uses=app { text "Getting started" }
73
+ page "About" uses=app { text "Who we are" }
74
+ \`\`\`
75
+
76
+ Parameters \u2014 ALWAYS QUOTE A $ REFERENCE:
77
+ Inside a component body, "$param" stands for the value the call site passed. The reference must be the whole quoted string.
78
+
79
+ \`\`\`
80
+ component navcard(label: string, to: string) {
81
+ card {
82
+ title "$label"
83
+ button "Open" navigate="$to"
84
+ button "Go" on={event=click, effects=[{kind=navigate, target="$to"}]}
85
+ }
86
+ }
87
+
88
+ page "Home" {
89
+ use navcard(label="Reports", to="Reports")
90
+ use navcard(label="Settings", to="Settings")
91
+ }
75
92
  \`\`\`
76
93
 
94
+ - WRITE target="$to" \u2014 quoted. A quoted reference works ANYWHERE a value goes, including nested places like an effect target.
95
+ - NEVER write target=$to \u2014 bare. An identifier cannot begin with $, so the file FAILS TO PARSE with a syntax error.
96
+ - "$to" substitutes only as an entire value. "go to $to" is literal text, not a reference.
97
+ - Every "$name" must match a declared parameter. An undeclared name is a validation error, so check the spelling against the component's parameter list.
98
+
99
+ Rules:
100
+ - layout and component are TOP-LEVEL only \u2014 siblings of page, never nested inside one.
101
+ - Define a layout as soon as two or more pages share a shell. Three pages that each repeat a header is a defect, not a style.
102
+ - A page with uses= must NOT restate the shell; put only its own content in the body.
103
+ - A layout has exactly the structure a page would have, with slot standing in for the varying part.
104
+
77
105
  # LAYOUT COMPONENTS
78
106
  page: Root container. Attrs: title (string arg), uses (layout name), at(x, y), viewport, width, height (pixels), device (mobile/tablet/desktop preset), centered (boolean).
79
107
  header: Top section. Attrs: h (height), p (padding), border (boolean, default true).
@@ -262,15 +290,18 @@ function buildCompactGrammarPrompt() {
262
290
  - Use viewport="WxH" per page; omit at() to auto-flow, use at(x, y) to pin.
263
291
  - Multi-view apps default to separate top-level pages (not sidebar collapse).
264
292
 
265
- # SHARED PAGE LAYOUTS: layout NAME { \u2026 slot \u2026 } defines a top-level shell; slot is a bare marker with no name or braces; page "Title" uses=NAME { \u2026 } places that page inside the shell. Layouts and pages are top-level siblings.
293
+ # REUSE: layout NAME { \u2026 } defines a shared shell (name is a bare identifier, not a quoted string); slot marks where a referencing page's own content goes inside that shell (bare keyword, no name, no braces); component NAME { \u2026 } defines a reusable fragment; use NAME(arg="value") { \u2026 } draws that fragment, passing parenthesized arguments and optionally filling its slots; page "Title" uses=NAME draws that page inside the layout and states only its own content. layout/component are top-level siblings of page. Two or more pages sharing a shell \u2192 define a layout instead of repeating it.
294
+ # PARAMETERS: component NAME(label: string, to: string) { \u2026 } declares typed parameters (string/number/boolean); inside the body "$label" stands for the passed value. ALWAYS quote the reference \u2014 navigate="$to" and target="$to" work anywhere, including nested effect targets. NEVER write it bare (navigate=$to): an identifier cannot start with $, so the file fails to parse. A reference must be the whole value ("go to $to" is literal text), and every "$name" must match a declared parameter or validation fails.
266
295
  # LAYOUT: page(at, viewport, width, height, device, centered, uses), 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
267
296
  # CONTAINERS: card(p, shadow), modal(w, id), drawer(w, position, id), accordion
268
297
  # TEXT: text(size, weight, muted), title(level), link(href)
269
298
  # VISUAL: icon(Lucide name), avatar(size), badge(variant), image, placeholder(h, w)
270
299
  # FORM: button(primary/danger/outline/ghost, icon, size), input(inputType, placeholder), select, checkbox, radio, switch, slider, textarea
271
- # NAV: nav(vertical, active) with array ["Item1","Item2"], tabs(active), breadcrumb, dropdown
300
+ # NAV: nav(vertical, active) with array ["Item1","Item2"], item(icon, active, disabled, href) inside a nav/dropdown block, tabs(active) with tab children, breadcrumb, dropdown
272
301
  # DATA: table with 2D array, list with array
273
302
  # FEEDBACK: alert(variant), toast, progress(value), spinner
303
+ # OVERLAY: tooltip(position), popover(title)
304
+ # ANNOTATION: marker(number arg, anchor, color), annotations(title) { item N "Title" { text "\u2026" } }
274
305
  # UTILITY: divider
275
306
 
276
307
  # INTERACTIONS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireweave/agent-prompts",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.3",
4
4
  "description": "Canonical grammar prompts for LLM agents generating Wireweave DSL (multi-page aware)",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -22,6 +22,9 @@
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
+ "engines": {
26
+ "node": ">=22.13.0"
27
+ },
25
28
  "lint-staged": {
26
29
  "*.{ts,js,mjs,cjs}": [
27
30
  "eslint --fix",
@@ -48,7 +51,8 @@
48
51
  "tsup": "^8.3.5",
49
52
  "typescript": "^5.7.2",
50
53
  "typescript-eslint": "^8.60.0",
51
- "vitest": "^3.1.1"
54
+ "vitest": "^3.1.1",
55
+ "@wireweave/core": "3.1.0-beta.6"
52
56
  },
53
57
  "keywords": [
54
58
  "wireframe",
@@ -71,6 +75,7 @@
71
75
  "homepage": "https://docs.wireweave.org",
72
76
  "scripts": {
73
77
  "build": "tsup",
78
+ "postbuild": "node ../../scripts/dist-freshness-gate.mjs --write .",
74
79
  "test": "vitest run",
75
80
  "test:watch": "vitest",
76
81
  "typecheck": "tsc --noEmit",
@@ -79,7 +84,7 @@
79
84
  "format": "prettier --write .",
80
85
  "format:check": "prettier --check .",
81
86
  "knip": "knip",
82
- "publint": "publint",
87
+ "publint": "publint --strict",
83
88
  "packlint": "packlint check",
84
89
  "clean": "rm -rf dist",
85
90
  "release": "release-it",