@adia-ai/a2ui-compose 0.4.4 → 0.4.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/CHANGELOG.md CHANGED
@@ -12,6 +12,22 @@ generator graph.
12
12
 
13
13
  _No pending changes._
14
14
 
15
+ ## [0.4.5] - 2026-05-12
16
+
17
+ ### Changed — GenUI overhaul prompt-engineering (§56, v0.4.5)
18
+
19
+ - **`strategies/monolithic/_shared.js` — CORPUS CONTEXT block added to `buildSystemPrompt`** (~30 new lines between role/output-format and CARD-N content model). Surgical insertion explaining the §36-§51 retrieval-augmented pipeline:
20
+ - Pipeline searches PATTERNS / COMPOSITIONS first (full-canvas A2UI templates: login-form, pricing-tiers, dashboard-admin-page)
21
+ - Pipeline also searches ANNOTATED CHUNKS (real production HTML with `metadata.{domain, keywords, description}`)
22
+ - When matched, `MATCHED PATTERN` / `STRUCTURAL REFERENCE` blocks carry the actual reference
23
+ - Only AVAILABLE COMPONENTS are usable — anything else is a hallucination
24
+
25
+ Cost: ~150 tokens per request. Benefit: LLM understands what the pipeline around it IS instead of treating the matched-pattern block as anonymous instructions. Existing rules unchanged; no removed lines.
26
+
27
+ - **`strategies/monolithic/generate-pro.js` — STRUCTURAL REFERENCE prose enriched.** Prior copy: "a real production block from the codebase matched this intent." New copy: "this chunk was retrieved from the AdiaUI training corpus (annotated production HTML, harvested from real app pages). It matched your intent on keyword/domain ranking." Threads chunk `metadata.domain`, `metadata.description`, `metadata.keywords` into the prompt when present. Reframes "do not copy the HTML" as "the chunk represents the SHAPE the user wants; instantiate it with their content" — more actionable framing.
28
+
29
+ See root [CHANGELOG.md `[Unreleased]`](../../../CHANGELOG.md) for the v0.4.5 overhaul arc + apps/genui/CHANGELOG.md `[Unreleased]` for the per-§ rollup.
30
+
15
31
  ## [0.4.4] - 2026-05-12
16
32
 
17
33
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adia-ai/a2ui-compose",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "AdiaUI A2UI compose engine — framework-agnostic. Takes natural-language intents + a catalog and produces A2UI protocol messages. Pairs with `@adia-ai/a2ui-retrieval` (intent classification, catalog lookup) and `@adia-ai/a2ui-validator` (schema + semantic checks).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -51,6 +51,32 @@ Output format: [{ "type": "updateComponents", "surfaceId": "default", "component
51
51
  Each component: { "id": "<unique>", "component": "<Type>", "children": ["<childId>", ...], ...props }
52
52
  The root must have id "root". Use short, descriptive IDs (e.g., "hdr", "email-field", "submit-btn").`);
53
53
 
54
+ // ── Corpus context (§56, v0.4.5) ──
55
+ // Tells the LLM how the system surrounding it is wired so it doesn't
56
+ // hallucinate component names and so it understands what MATCHED PATTERN /
57
+ // STRUCTURAL REFERENCE blocks actually ARE. Keep this section tight — every
58
+ // token costs latency + money.
59
+ parts.push(`CORPUS CONTEXT (the system around you):
60
+
61
+ You are part of a retrieval-augmented pipeline. Before this prompt was built,
62
+ the pipeline searched two corpora for matches to the user's intent:
63
+
64
+ 1. PATTERNS / COMPOSITIONS — full-canvas A2UI templates curated for the
65
+ AdiaUI design system. Examples: login-form, pricing-tiers,
66
+ dashboard-admin-page. When a strong match exists, you'll see a
67
+ "MATCHED PATTERN" block below with the canonical template.
68
+
69
+ 2. ANNOTATED CHUNKS — real production HTML blocks harvested from the AdiaUI
70
+ apps (auth flows, dashboards, error pages, etc.) with metadata
71
+ (domain, keywords, description). When a strong chunk match exists,
72
+ you'll see a "STRUCTURAL REFERENCE" block with the production HTML.
73
+ Match its component palette + information density, but translate to
74
+ A2UI components — do not copy raw HTML.
75
+
76
+ Both corpora use ONLY components from the AVAILABLE COMPONENTS list further
77
+ down. If you would invent a component name not in that list, you're
78
+ hallucinating — use the closest canonical name instead.`);
79
+
54
80
  // ── Card-N content model (critical for quality) ──
55
81
  parts.push(`CARD-N CONTENT MODEL (mandatory for any card surface):
56
82
  - Card > Header: for title/description. Use Text children with heading variants (h3, h4).
@@ -221,10 +221,18 @@ export async function generatePro({ intent, executionId, storeId, llmAdapter, an
221
221
  // structural "look like this" hint that lets the LLM materialize the
222
222
  // real chunk shape (e.g. auth-signin-card-email) instead of
223
223
  // hallucinating a passable-but-wrong shape from the brief alone.
224
+ //
225
+ // §56 (v0.4.5): prompt language enriched with provenance + metadata so
226
+ // the LLM understands the chunk's domain/keywords context. Tested via
227
+ // factory-chat + gen-ui live submit; LLMs produce closer structural
228
+ // matches when told what the chunk is + where it came from.
224
229
  const chunkReferenceBlock = chunkRefHtml
225
- ? `\nSTRUCTURAL REFERENCE — a real production block from the codebase matched this intent. Match its component palette, information density, and Card / Header / Section / Footer anatomy. Do NOT copy the HTML verbatim into A2UI; translate its semantic structure into the equivalent A2UI components:
230
+ ? `\nSTRUCTURAL REFERENCE — this chunk was retrieved from the AdiaUI training corpus (annotated production HTML, harvested from real app pages). It matched your intent on keyword/domain ranking:
231
+
232
+ CHUNK: ${chunkMatch.name}
233
+ kind=${chunkMatch.kind}, primary=${chunkMatch.primary}, score=${chunkMatch.score}${chunkMatch.metadata?.domain ? `, domain=${chunkMatch.metadata.domain}` : ''}${chunkMatch.metadata?.description ? `\n description: ${chunkMatch.metadata.description}` : ''}${chunkMatch.metadata?.keywords ? `\n keywords: ${chunkMatch.metadata.keywords.join(', ')}` : ''}
226
234
 
227
- CHUNK: ${chunkMatch.name} (${chunkMatch.kind}, primary=${chunkMatch.primary}, score=${chunkMatch.score})
235
+ Match this chunk's component palette, information density, and Card/Header/Section/Footer anatomy. Do NOT copy the HTML verbatim into A2UI — translate its semantic structure into the equivalent A2UI components. The chunk represents the SHAPE the user wants; your job is to instantiate that shape with their content:
228
236
  ---
229
237
  ${chunkRefHtml}
230
238
  ---