code wiki / _hdl_build / nx_uigen_l2.nx
nx_uigen_l2.nx source
↩ module page · 178 lines · 11537 B
1// nx_uigen_l2.nx -- ROADMAP RUNG L2: INTENT -> MAPPING. A brief (words describing what's wanted) is mapped BY
2// RULE to design decisions: page-KIND (landing / dashboard / doc / form) -> which components + layout to compose,
3// and TOPIC -> a seed hue for L1's palette generation. This is the rung that starts to resemble v0/GLM: you
4// describe intent, the system produces an APPROPRIATE structure (a form brief yields a form, a metrics brief a
5// dashboard). Honest scope: RULE-BASED (heuristic) mapping + templated copy -- learned generation from free text
6// is L4. Attacks census GAPs intent-to-ui / component-selection. Pure emit. license_tier: ORIGINAL
7import "nx_uigen_l1.nx"
8
9func l2_isalpha(c: u8) -> i64 { let v: i64 = c as i64; if v >= 97 { if v <= 122 { return 1 } } return 0 }
10
11// does brief contain kw at a WORD START? (boundary before, any char after -> stem match). Word-start matching is
12// load-bearing: it lets "financ" match "financial" and "metric" match "metrics", while stopping "sign" (signup)
13// from matching inside "de-sign" -- a real false-positive the L2 gate caught.
14func l2_has(s: *u8, kw: *u8) -> i64 {
15 var kl: i64 = 0
16 while kw[kl] != (0 as u8) { kl = kl + 1 }
17 if kl == 0 { return 0 }
18 var i: i64 = 0
19 while s[i] != (0 as u8) {
20 var boundary: i64 = 0
21 if i == 0 { boundary = 1 } else { if l2_isalpha(s[i - 1]) == 0 { boundary = 1 } }
22 if boundary == 1 {
23 var j: i64 = 0
24 var ok: i64 = 1
25 while j < kl { if s[i + j] != kw[j] { ok = 0; j = kl } else { j = j + 1 } }
26 if ok == 1 { return 1 }
27 }
28 i = i + 1
29 }
30 return 0
31}
32
33// map brief -> page KIND. 0 landing, 1 dashboard, 2 doc, 3 form. Rule order: form/dashboard/landing specific,
34// else doc (safe generic). Keywords are the intent surface.
35func l2_kind(brief: *u8) -> i64 {
36 if l2_has(brief, "form" as *u8) == 1 { return 3 }
37 if l2_has(brief, "sign" as *u8) == 1 { return 3 }
38 if l2_has(brief, "signup" as *u8) == 1 { return 3 }
39 if l2_has(brief, "setting" as *u8) == 1 { return 3 }
40 if l2_has(brief, "contact" as *u8) == 1 { return 3 }
41 if l2_has(brief, "register" as *u8) == 1 { return 3 }
42 if l2_has(brief, "login" as *u8) == 1 { return 3 }
43 if l2_has(brief, "apply" as *u8) == 1 { return 3 }
44 if l2_has(brief, "dashboard" as *u8) == 1 { return 1 }
45 if l2_has(brief, "metric" as *u8) == 1 { return 1 }
46 if l2_has(brief, "analytic" as *u8) == 1 { return 1 }
47 if l2_has(brief, "stats" as *u8) == 1 { return 1 }
48 if l2_has(brief, "monitor" as *u8) == 1 { return 1 }
49 if l2_has(brief, "report" as *u8) == 1 { return 1 }
50 if l2_has(brief, "kpi" as *u8) == 1 { return 1 }
51 if l2_has(brief, "landing" as *u8) == 1 { return 0 }
52 if l2_has(brief, "product" as *u8) == 1 { return 0 }
53 if l2_has(brief, "marketing" as *u8) == 1 { return 0 }
54 if l2_has(brief, "launch" as *u8) == 1 { return 0 }
55 if l2_has(brief, "startup" as *u8) == 1 { return 0 }
56 if l2_has(brief, "promote" as *u8) == 1 { return 0 }
57 return 2
58}
59
60// map brief -> seed hue by TOPIC (color psychology, rule-based). default 210 (blue).
61func l2_hue(brief: *u8) -> i64 {
62 if l2_has(brief, "financ" as *u8) == 1 { return 212 }
63 if l2_has(brief, "bank" as *u8) == 1 { return 212 }
64 if l2_has(brief, "invest" as *u8) == 1 { return 212 }
65 if l2_has(brief, "trade" as *u8) == 1 { return 212 }
66 if l2_has(brief, "pay" as *u8) == 1 { return 212 }
67 if l2_has(brief, "health" as *u8) == 1 { return 150 }
68 if l2_has(brief, "care" as *u8) == 1 { return 150 }
69 if l2_has(brief, "medic" as *u8) == 1 { return 150 }
70 if l2_has(brief, "clinic" as *u8) == 1 { return 150 }
71 if l2_has(brief, "fitness" as *u8) == 1 { return 150 }
72 if l2_has(brief, "food" as *u8) == 1 { return 30 }
73 if l2_has(brief, "restaurant" as *u8) == 1 { return 30 }
74 if l2_has(brief, "energy" as *u8) == 1 { return 30 }
75 if l2_has(brief, "coffee" as *u8) == 1 { return 30 }
76 if l2_has(brief, "craft" as *u8) == 1 { return 30 }
77 if l2_has(brief, "creativ" as *u8) == 1 { return 275 }
78 if l2_has(brief, "art" as *u8) == 1 { return 275 }
79 if l2_has(brief, "design" as *u8) == 1 { return 275 }
80 if l2_has(brief, "studio" as *u8) == 1 { return 275 }
81 if l2_has(brief, "music" as *u8) == 1 { return 275 }
82 if l2_has(brief, "eco" as *u8) == 1 { return 108 }
83 if l2_has(brief, "nature" as *u8) == 1 { return 108 }
84 if l2_has(brief, "garden" as *u8) == 1 { return 108 }
85 if l2_has(brief, "farm" as *u8) == 1 { return 108 }
86 if l2_has(brief, "legal" as *u8) == 1 { return 232 }
87 if l2_has(brief, "law" as *u8) == 1 { return 232 }
88 if l2_has(brief, "secur" as *u8) == 1 { return 232 }
89 return 210
90}
91
92// ---- per-kind sub-emitters (each composes the RIGHT shell + components for the intent) ----
93func l2_landing(buf: *u8, off: i64, hue: i64, title: *u8, brand: *u8) -> i64 {
94 var o: i64 = sk_open_site(buf, off, title, brand, 1, "/" as *u8)
95 o = sk_nav_item(buf, o, "Home" as *u8, "#top" as *u8)
96 o = sk_nav_item(buf, o, "Get started" as *u8, "#cta" as *u8)
97 o = sk_header_close(buf, o)
98 o = l1_palette_style(buf, o, hue)
99 o = sk_hero(buf, o, "Introducing" as *u8, title, "done right" as *u8, "A product page whose structure — hero, feature grid, and a closing call to action — was chosen by the system because your brief reads like a landing page." as *u8, "Get started" as *u8, "#cta" as *u8, "See features" as *u8, "#feat" as *u8, "No sign-up needed to look around." as *u8)
100 o = sk_section_open(buf, o, "feat" as *u8, "Why it fits" as *u8, "Built for the job" as *u8, "Three things the brief implied you care about." as *u8)
101 o = sk_card(buf, o, "<svg viewBox=\"0 0 24 24\" width=\"22\" height=\"22\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M13 3L4 14h7l-1 7 9-11h-7z\"/></svg>" as *u8, "Fast" as *u8, "Structure picked to match intent, not a one-size template." as *u8)
102 o = sk_card(buf, o, "<svg viewBox=\"0 0 24 24\" width=\"22\" height=\"22\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M5 12l4 4 10-10\"/></svg>" as *u8, "Accessible" as *u8, "Palette generated so contrast passes WCAG in both themes." as *u8)
103 o = sk_card(buf, o, "<svg viewBox=\"0 0 24 24\" width=\"22\" height=\"22\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 7v10M7 12h10\"/></svg>" as *u8, "Coherent" as *u8, "One seed hue drives every color, on-brief." as *u8)
104 o = sk_section_close(buf, o)
105 o = sk_cta(buf, o, "Ready" as *u8, "Start in a minute" as *u8, "This whole page came from a one-line brief." as *u8, "Get started" as *u8, "#cta" as *u8, "Read the docs" as *u8, "#feat" as *u8)
106 o = sk_close(buf, o, "Landing" as *u8, brand)
107 return o
108}
109func l2_dashboard(buf: *u8, off: i64, hue: i64, title: *u8, brand: *u8) -> i64 {
110 var o: i64 = sk_doc_open(buf, off, title, brand, "/" as *u8)
111 o = sk_nav_item(buf, o, "Home" as *u8, "/" as *u8)
112 o = sk_header_close(buf, o)
113 o = l1_palette_style(buf, o, hue)
114 o = l1_layout_style(buf, o, 1)
115 o = sk_doc_main(buf, o)
116 o = sk_doc_h1(buf, o, title, "Your brief reads like a metrics view, so the system led with a scorecard and a status table." as *u8)
117 o = sk_score_open(buf, o, "99.9" as *u8, "% uptime" as *u8)
118 o = sk_stat(buf, o, "1,284" as *u8, "requests / min" as *u8)
119 o = sk_stat(buf, o, "42 ms" as *u8, "p50 latency" as *u8)
120 o = sk_stat(buf, o, "0" as *u8, "open incidents" as *u8)
121 o = sk_score_close(buf, o)
122 o = sk_h2(buf, o, "Services" as *u8)
123 o = sk_dtable_open(buf, o, "Service" as *u8, "Status" as *u8, "Note" as *u8)
124 o = sk_drow(buf, o, "api-gateway" as *u8, "have" as *u8, "healthy" as *u8, "all regions green" as *u8)
125 o = sk_drow(buf, o, "worker-mesh" as *u8, "have" as *u8, "healthy" as *u8, "autoscaled to 6 nodes" as *u8)
126 o = sk_drow(buf, o, "batch-jobs" as *u8, "partial" as *u8, "degraded" as *u8, "retrying 2 of 40" as *u8)
127 o = sk_dtable_close(buf, o)
128 o = sk_doc_close(buf, o, "Structure selected by nx_uigen_l2 for a dashboard brief." as *u8, brand)
129 return o
130}
131func l2_doc(buf: *u8, off: i64, hue: i64, title: *u8, brand: *u8) -> i64 {
132 var o: i64 = sk_doc_open(buf, off, title, brand, "/" as *u8)
133 o = sk_nav_item(buf, o, "Home" as *u8, "/" as *u8)
134 o = sk_header_close(buf, o)
135 o = l1_palette_style(buf, o, hue)
136 o = l1_layout_style(buf, o, 0)
137 o = sk_doc_main(buf, o)
138 o = sk_doc_h1(buf, o, title, "Your brief reads like a reference document, so the system chose a readable single column with sectioned headings." as *u8)
139 o = sk_h2(buf, o, "Overview" as *u8)
140 o = sk_lede(buf, o, "This structure — title, lede, and a sequence of h2 sections with a callout — is what the system maps a doc/guide/reference brief to." as *u8)
141 o = sk_h2(buf, o, "How it works" as *u8)
142 o = sk_lede(buf, o, "The page-kind was inferred from the words in the brief; the palette from its topic." as *u8)
143 o = sk_callout(buf, o, "<strong>Note:</strong> the copy here is templated — L2 selects the right STRUCTURE and palette from intent. Generating the prose itself is L4." as *u8)
144 o = sk_h2(buf, o, "Details" as *u8)
145 o = sk_lede(buf, o, "Everything you see re-themes from one seed hue and stays accessible in both light and dark." as *u8)
146 o = sk_doc_close(buf, o, "Structure selected by nx_uigen_l2 for a doc brief." as *u8, brand)
147 return o
148}
149func l2_form(buf: *u8, off: i64, hue: i64, title: *u8, brand: *u8) -> i64 {
150 var o: i64 = sk_doc_open(buf, off, title, brand, "/" as *u8)
151 o = sk_nav_item(buf, o, "Home" as *u8, "/" as *u8)
152 o = sk_header_close(buf, o)
153 o = l1_palette_style(buf, o, hue)
154 o = l1_layout_style(buf, o, 0)
155 o = sk_doc_main(buf, o)
156 o = sk_doc_h1(buf, o, title, "Your brief reads like a form, so the system composed labelled, accessible fields." as *u8)
157 // R0a (debt 1785934272): no handler exists, so the demo form must be UNMISTAKABLY a demo --
158 // fieldset disabled + an inert button + a callout. A submit that goes nowhere is a placeholder
159 // that reads as a real claim.
160 o = he_puts(buf, o, "<form class=\"nform\"><fieldset disabled style=\"border:0;padding:0;margin:0;display:contents\">" as *u8)
161 o = sk_field(buf, o, "name" as *u8, "Full name" as *u8, "text" as *u8, "Jane Doe" as *u8)
162 o = sk_field(buf, o, "email" as *u8, "Email" as *u8, "email" as *u8, "jane@example.com" as *u8)
163 o = sk_field_area(buf, o, "message" as *u8, "Message" as *u8, "How can we help?" as *u8)
164 o = he_puts(buf, o, "<button class=\"btnp\" type=\"button\" disabled>Submit (structural demo)</button></fieldset></form>" as *u8)
165 o = sk_callout(buf, o, "<strong>Structural demo:</strong> L2 selects structure from intent; this form is not wired to a handler, so it is shown disabled." as *u8)
166 o = sk_doc_close(buf, o, "Structure selected by nx_uigen_l2 for a form brief." as *u8, brand)
167 return o
168}
169
170// L2 front door: brief -> the appropriate page (shell + components + palette all chosen by rule).
171func l2_generate(buf: *u8, off: i64, brief: *u8, title: *u8, brand: *u8) -> i64 {
172 let kind: i64 = l2_kind(brief)
173 let hue: i64 = l2_hue(brief)
174 if kind == 0 { return l2_landing(buf, off, hue, title, brand) }
175 if kind == 1 { return l2_dashboard(buf, off, hue, title, brand) }
176 if kind == 3 { return l2_form(buf, off, hue, title, brand) }
177 return l2_doc(buf, off, hue, title, brand)
178}