@adia-ai/a2ui-mcp 0.5.18 → 0.5.20
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 +8 -0
- package/package.json +1 -1
- package/server.js +82 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@ zettel strategies.
|
|
|
10
10
|
|
|
11
11
|
_No pending changes._
|
|
12
12
|
|
|
13
|
+
## [0.5.20] - 2026-05-18
|
|
14
|
+
|
|
15
|
+
_Lockstep ride-along (no source change in this package; companion to web-components v0.5.20 — see root CHANGELOG)._
|
|
16
|
+
|
|
17
|
+
## [0.5.19] - 2026-05-17
|
|
18
|
+
|
|
19
|
+
_Lockstep ride-along (no source change in this package; companion to web-components v0.5.19 — see root CHANGELOG)._
|
|
20
|
+
|
|
13
21
|
## [0.5.18] - 2026-05-16
|
|
14
22
|
|
|
15
23
|
_Lockstep ride-along (no source change in this package; companion to web-components v0.5.18 — see root CHANGELOG)._
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -96,6 +96,76 @@ const server = new McpServer({
|
|
|
96
96
|
version: '0.1.0',
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
server.tool(
|
|
100
|
+
'plan_app_state',
|
|
101
|
+
`Analyze a natural language prompt and extract the top-level Generative UI Ontology structures (Intent, Domain, Tasks, Experience).
|
|
102
|
+
|
|
103
|
+
Use this tool BEFORE generating UI to ensure you have walked the Reasoning Ladder and properly modeled the nouns and verbs of the feature. This bounds hallucination and forces a focus on tasks over raw layouts.`,
|
|
104
|
+
{
|
|
105
|
+
prompt: z.string().describe('The natural language request (e.g., "Build a dashboard for incoming sales leads")'),
|
|
106
|
+
},
|
|
107
|
+
async ({ prompt }) => {
|
|
108
|
+
// We utilize the LLM directly here to act as the reasoning gate.
|
|
109
|
+
// This is a minimal, fast call designed to output structured JSON.
|
|
110
|
+
const { createAdapter } = await import('../../llm/llm-bridge.js');
|
|
111
|
+
const llm = await createAdapter();
|
|
112
|
+
|
|
113
|
+
const systemPrompt = `You are the A2UI Ontology Planner.
|
|
114
|
+
Given a user prompt, you must extract the Core App State using the 5-Gate Reasoning Ladder.
|
|
115
|
+
|
|
116
|
+
Output ONLY a JSON object matching this schema, nothing else:
|
|
117
|
+
{
|
|
118
|
+
"intent": {
|
|
119
|
+
"user_goal": "string",
|
|
120
|
+
"product_goal": "string"
|
|
121
|
+
},
|
|
122
|
+
"domain": {
|
|
123
|
+
"entities": ["string"],
|
|
124
|
+
"metrics": ["string"]
|
|
125
|
+
},
|
|
126
|
+
"tasks": {
|
|
127
|
+
"primary": ["string"],
|
|
128
|
+
"inspection": ["string"]
|
|
129
|
+
},
|
|
130
|
+
"experience": {
|
|
131
|
+
"mode": "workspace | dashboard | wizard | chat",
|
|
132
|
+
"shell": "admin-shell | chat-shell | a2ui-root"
|
|
133
|
+
}
|
|
134
|
+
}`;
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
const response = await llm.complete({
|
|
138
|
+
messages: [{ role: 'user', content: prompt }],
|
|
139
|
+
system: systemPrompt,
|
|
140
|
+
temperature: 0.2
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
let jsonMatch = response.text.match(/\{[\s\S]*\}/);
|
|
144
|
+
if (!jsonMatch) {
|
|
145
|
+
throw new Error("LLM failed to output valid JSON for the ontology plan.");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const plan = JSON.parse(jsonMatch[0]);
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
content: [
|
|
152
|
+
{
|
|
153
|
+
type: 'text',
|
|
154
|
+
text: JSON.stringify(plan, null, 2),
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
} catch (e) {
|
|
159
|
+
return {
|
|
160
|
+
content: [
|
|
161
|
+
{ type: 'text', text: `Failed to plan app state: ${e.message}` }
|
|
162
|
+
],
|
|
163
|
+
isError: true,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
|
|
99
169
|
server.tool(
|
|
100
170
|
'generate_ui',
|
|
101
171
|
`Generate A2UI components from a natural language description.
|
|
@@ -115,8 +185,18 @@ The generator knows 96+ UI patterns across 5 domains: forms, data, layout, agent
|
|
|
115
185
|
engine: z.enum(['monolithic', 'zettel']).optional().describe('Generation engine. "monolithic" (default) is pattern-match + adapt. "zettel" is fragment-graph composition.'),
|
|
116
186
|
mode: z.enum(['instant', 'pro', 'thinking']).optional().describe('Generation mode (monolithic). "pro" (default) uses LLM with pattern adaptation. "thinking" uses full LLM generation. "instant" uses fast pattern matching.'),
|
|
117
187
|
sessionId: z.string().optional().describe('Opaque session identifier for multi-turn iteration (zettel only). When provided, follow-up calls with the same sessionId modify the prior turn\'s canvas instead of regenerating from scratch. Omit for stateless generation.'),
|
|
188
|
+
context: z.object({
|
|
189
|
+
domain: z.object({
|
|
190
|
+
entities: z.array(z.string()).optional(),
|
|
191
|
+
metrics: z.array(z.string()).optional()
|
|
192
|
+
}).optional(),
|
|
193
|
+
tasks: z.object({
|
|
194
|
+
primary: z.array(z.string()).optional(),
|
|
195
|
+
inspection: z.array(z.string()).optional()
|
|
196
|
+
}).optional()
|
|
197
|
+
}).optional().describe('Ontology context parsed by plan_app_state. If provided, the generator uses these constraints to bound hallucinations and strictly align components with domain tasks.')
|
|
118
198
|
},
|
|
119
|
-
async ({ intent, engine, mode, sessionId }) => {
|
|
199
|
+
async ({ intent, engine, mode, sessionId, context }) => {
|
|
120
200
|
try {
|
|
121
201
|
const selectedEngine = engine || 'monolithic';
|
|
122
202
|
const effectiveMode = selectedEngine === 'zettel' ? 'instant' : (mode || 'pro');
|
|
@@ -125,6 +205,7 @@ The generator knows 96+ UI patterns across 5 domains: forms, data, layout, agent
|
|
|
125
205
|
engine: selectedEngine,
|
|
126
206
|
mode: effectiveMode,
|
|
127
207
|
sessionId,
|
|
208
|
+
context, // Pass the ontology context down to the composer
|
|
128
209
|
});
|
|
129
210
|
return {
|
|
130
211
|
content: [{
|