@framingui/mcp-server 0.6.19 → 0.6.21

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.
Files changed (44) hide show
  1. package/README.md +79 -990
  2. package/dist/cli/agent-md-templates.d.ts +0 -12
  3. package/dist/cli/agent-md-templates.d.ts.map +1 -1
  4. package/dist/cli/agent-md-templates.js +73 -255
  5. package/dist/cli/agent-md-templates.js.map +1 -1
  6. package/dist/cli/guide-template.d.ts +0 -7
  7. package/dist/cli/guide-template.d.ts.map +1 -1
  8. package/dist/cli/guide-template.js +58 -157
  9. package/dist/cli/guide-template.js.map +1 -1
  10. package/dist/cli/index.d.ts +1 -1
  11. package/dist/cli/index.js +3 -47
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/cli/init.d.ts +18 -2
  14. package/dist/cli/init.d.ts.map +1 -1
  15. package/dist/cli/init.js +278 -108
  16. package/dist/cli/init.js.map +1 -1
  17. package/dist/index.js +39 -35
  18. package/dist/index.js.map +1 -1
  19. package/dist/prompts/getting-started.d.ts.map +1 -1
  20. package/dist/prompts/getting-started.js +6 -29
  21. package/dist/prompts/getting-started.js.map +1 -1
  22. package/dist/prompts/screen-workflow.d.ts +1 -4
  23. package/dist/prompts/screen-workflow.d.ts.map +1 -1
  24. package/dist/prompts/screen-workflow.js +84 -234
  25. package/dist/prompts/screen-workflow.js.map +1 -1
  26. package/dist/schemas/mcp-schemas.d.ts +212 -449
  27. package/dist/schemas/mcp-schemas.d.ts.map +1 -1
  28. package/dist/schemas/mcp-schemas.js +15 -69
  29. package/dist/schemas/mcp-schemas.js.map +1 -1
  30. package/dist/tools/get-screen-generation-context.d.ts.map +1 -1
  31. package/dist/tools/get-screen-generation-context.js +74 -117
  32. package/dist/tools/get-screen-generation-context.js.map +1 -1
  33. package/dist/tools/preview-component.js +1 -1
  34. package/dist/tools/preview-component.js.map +1 -1
  35. package/dist/tools/preview-screen-template.d.ts.map +1 -1
  36. package/dist/tools/preview-screen-template.js +0 -1
  37. package/dist/tools/preview-screen-template.js.map +1 -1
  38. package/dist/tools/validate-environment.d.ts.map +1 -1
  39. package/dist/tools/validate-environment.js +1 -84
  40. package/dist/tools/validate-environment.js.map +1 -1
  41. package/dist/tools/validate-screen-definition.d.ts.map +1 -1
  42. package/dist/tools/validate-screen-definition.js +0 -6
  43. package/dist/tools/validate-screen-definition.js.map +1 -1
  44. package/package.json +4 -4
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * MCP Prompts: Screen Generation Workflow
3
- * Step-by-step guide for the production screen generation process
4
- */
5
- /**
6
- * Screen Workflow prompt with guarded direct-write process
3
+ * Current production workflow for guarded direct-write screen generation
7
4
  */
8
5
  export function getScreenWorkflowPrompt() {
9
6
  return {
@@ -12,124 +9,86 @@ export function getScreenWorkflowPrompt() {
12
9
  role: 'user',
13
10
  content: {
14
11
  type: 'text',
15
- text: `# Framingui Screen Generation Workflow
12
+ text: `# FramingUI Screen Generation Workflow
16
13
 
17
- This is the **recommended production workflow** for generating screens with Framingui.
14
+ This is the current production workflow for building screens with FramingUI.
18
15
 
19
16
  Prerequisite: authenticate with \`framingui-mcp login\` or provide \`FRAMINGUI_API_KEY\`.
20
- Optional: call \`whoami\` if you want to inspect the current session and licensed themes before starting.
17
+ Optional: call \`whoami\` to inspect licensed themes before starting.
21
18
 
22
19
  ## Overview
23
20
 
24
- The workflow ensures:
25
- - ✅ Correct component-first usage with inline props/variants
26
- - ✅ Validated screen structure with auto-fix patches
27
- - ✅ Theme recipes and component contracts are visible before code is written
28
- - ✅ All dependencies installed
29
- - ✅ Tailwind CSS properly configured
30
- - ✅ Style contract compatibility checked before relying on FramingUI component defaults
21
+ The production workflow is **guarded direct write**:
22
+ - ✅ Gather component contracts, theme context, layout hints, and starter structure
23
+ - ✅ Validate the Screen Definition before writing code
24
+ - ✅ Write React code directly using FramingUI components and props from context
25
+ - ✅ Verify dependencies, Tailwind setup, and raw HTML/style escapes before delivery
31
26
 
32
- ## Step 0: Detect Style Contract
27
+ This is **not** the old \`generate_screen\`-first workflow.
28
+ \`generate_screen\` may still be used as an optional helper, but the default production path is:
33
29
 
34
- Before generating or integrating a screen, determine which styling contract the target project already uses.
30
+ \`preview-theme\` \`get-screen-generation-context\` \`preview-component\` / \`list-icon-libraries\` when needed \`validate-screen-definition\` write code directly → \`validate-environment\`
35
31
 
36
- - \`framingui-native\`: project imports FramingUI styles or defines the full FramingUI variable contract
37
- - \`host-utility\`: project styles screens with direct Tailwind utilities and does not expose FramingUI variables
38
- - \`mixed\`: project defines only some FramingUI variables, which is the highest-risk state for broken component styling
32
+ ## Step 1/4: Gather Context
39
33
 
40
- **Rule:** do not silently mix a utility-first host page with FramingUI component default variants in the same screen. Either:
41
- - stay utility-first and use explicit classes, or
42
- - migrate the page to the FramingUI variable contract after confirming with the user
34
+ **Primary tool:** \`get-screen-generation-context\`
43
35
 
44
- **Mandatory decision:** choose one path before writing code:
45
- - \`host-utility\`: preserve the host utility stack and keep FramingUI usage explicit with reviewed utility classes
46
- - \`framingui-native\`: import \`@framingui/ui/styles\` from the global stylesheet and rely on FramingUI variables/variants
47
- - \`migrate\`: stop and ask for a migration decision before continuing
36
+ Use this at the start of every screen task.
48
37
 
49
- **Enforcement:** if \`projectPath\` is known, Step 0 preflight is required before \`/screen\` or \`/section\` generation.
50
- Use:
38
+ **Recommended input:**
51
39
  \`\`\`json
52
40
  {
53
- "projectPath": "/path/to/project",
54
- "requiredPackages": [],
55
- "checkTailwind": true,
56
- "checkStyles": true
41
+ "description": "Blog main page with square-minimalism theme, mobile optimized",
42
+ "themeId": "square-minimalism",
43
+ "includeExamples": false
57
44
  }
58
45
  \`\`\`
59
- Block generation when:
60
- - \`styles.styleContract === "mixed"\`
61
- - \`styles.styleContract === "host-utility"\` and the user did not explicitly choose \`--style-contract host-utility\`
62
-
63
- If \`styles.styleContract === "framingui-native"\` or the user explicitly chooses \`--style-contract framingui-native\`, verify that the app imports:
64
- \`\`\`css
65
- @import '@framingui/ui/styles';
66
- \`\`\`
67
- from a global stylesheet such as \`app/globals.css\` or \`styles/globals.css\`.
68
46
 
69
- ## Step 1/4: Get Screen Generation Context
47
+ Set \`includeExamples: false\` when you want a smaller response and do not need example screen definitions.
70
48
 
71
- **Tool:** \`get-screen-generation-context\`
49
+ **What to review from the response:**
50
+ - \`templateMatch\` as a layout hint only
51
+ - \`components\` as the source of truth for imports, props, and variants
52
+ - \`schema.screenDefinition\`
53
+ - \`themeRecipes\`
54
+ - \`hints\`
55
+ - \`workflow\`
72
56
 
73
- **Purpose:** Gather all context needed to create a Screen Definition
57
+ **Escalate to discovery tools when needed:**
58
+ - Call \`preview-theme\` if theme application is still unclear
59
+ - Call \`preview-component\` when a component contract is ambiguous
60
+ - Call \`list-icon-libraries\` if the screen needs icons and the icon set is still undecided
74
61
 
75
- **Input:**
76
- \`\`\`json
77
- {
78
- "description": "User dashboard with profile card and recent activity",
79
- "themeId": "minimal-workspace",
80
- "includeExamples": true
81
- }
82
- \`\`\`
62
+ ## Critical Handling Rule
83
63
 
84
- **Output:**
85
- - Template hints for inspiration
86
- - A component plan and section plan for guided drafting
87
- - Available components with **inline props and variants**
88
- - A definition starter object for the first draft
89
- - Screen Definition JSON schema
90
- - Example definitions
91
- - Theme recipes
92
- - Warnings when component metadata could not be loaded cleanly
64
+ Treat MCP tool responses as structured tool output, not as shell text.
93
65
 
94
- **When to use:**
95
- - Beginning of every screen generation
96
- - When you need component suggestions
97
- - When you want template inspiration without hard-coding the screen to a template
66
+ - Do **not** copy MCP transcript text into a file and run \`python\`, \`node\`, \`jq\`, or \`json.loads(...)\` against it
67
+ - Do **not** parse rendered transcript blocks such as \`⎿ { ... }\`, truncation markers, or console summaries
68
+ - Do **not** treat UI-expanded output or chat transcript text as canonical JSON
69
+ - Use the tool result directly in the agent context
98
70
 
99
- **Guardrail:** if the response includes \`warnings\`, do not guess missing props. Resolve the warning first with \`preview-component\` or by retrying the context fetch.
100
- **Guardrail:** treat \`templateHints\` as inspiration only. \`componentPlan\`, \`components\`, and the validated definition are the contract.
71
+ If you must persist data, write **only the raw JSON object** from the tool result, with no surrounding transcript text.
101
72
 
102
- ### Step 1A: Resolve Discovery Gaps Before Drafting
103
-
104
- Do not proceed from Step 1 directly into drafting if any of these are still ambiguous:
105
-
106
- - **Component ambiguity:** call \`preview-component\` for every component whose props, variants, or availability are uncertain
107
- - **Theme ambiguity:** call \`preview-theme\` whenever a theme is selected and visual recipes or variable-backed defaults matter
108
- - **Icon ambiguity:** call \`list-icon-libraries\` before introducing icons or icon-only actions
109
-
110
- **Hard rule:** do not claim that FramingUI lacks a component unless you inspected the catalog with \`list-components\` or \`preview-component\`.
111
- For example, form controls such as \`Input\` must not fall back to raw \`<input>\` without an explicit reason.
112
-
113
- ---
114
-
115
- ## Step 2/4: Validate Screen Definition
73
+ ## Step 2/4: Create and Validate a Screen Definition
116
74
 
117
75
  **Tool:** \`validate-screen-definition\`
118
76
 
119
- **Purpose:** Ensure your Screen Definition JSON is correct before generating code
77
+ Create a Screen Definition JSON object using the schema and starter guidance from Step 1, then validate it before writing React code.
120
78
 
121
- **Input:**
79
+ **Validation input:**
122
80
  \`\`\`json
123
81
  {
124
82
  "definition": {
125
- "id": "user-dashboard",
126
- "shell": "shell.web.dashboard",
127
- "page": "page.dashboard",
83
+ "id": "blog-home",
84
+ "shell": "shell.web.marketing",
85
+ "page": "page.blog",
86
+ "themeId": "square-minimalism",
128
87
  "sections": [
129
88
  {
130
- "id": "header",
89
+ "id": "hero",
131
90
  "pattern": "section.container",
132
- "components": [...]
91
+ "components": []
133
92
  }
134
93
  ]
135
94
  },
@@ -137,168 +96,59 @@ For example, form controls such as \`Input\` must not fall back to raw \`<input>
137
96
  }
138
97
  \`\`\`
139
98
 
140
- **Output:**
141
- - \`valid\`: true/false
142
- - \`errors\`: Array of validation errors with suggestions and **autoFix patches**
143
- - \`warnings\`: Potential issues
144
- - \`suggestions\`: Improvement recommendations with **autoFix patches**
145
- - \`autoFixPatches\`: Aggregated JSON Patch operations to fix all issues
146
-
147
- **When to use:**
148
- - Always before generating code (Step 3)
149
- - When fixing validation errors (apply autoFixPatches)
150
- - When exploring screen structure improvements
99
+ **Expect from validation:**
100
+ - \`valid\`
101
+ - \`errors\`
102
+ - \`warnings\`
103
+ - \`suggestions\`
104
+ - \`autoFixPatches\`
151
105
 
152
- ---
106
+ Always apply validation fixes before writing code.
153
107
 
154
108
  ## Step 3/4: Write React Code Directly
155
109
 
156
- **Purpose:** Write production-ready React code using the validated Screen Definition and the component contracts from Step 1.
157
-
158
- **Required constraints:**
159
- - Preserve the validated \`shell\`, \`page\`, \`section\`, and slot structure from Step 2
160
- - Use only components returned in Step 1 unless you explicitly inspect more with \`preview-component\`
161
- - Use documented props and variants; do not invent props
162
- - Prefer \`@framingui/ui\` components over raw HTML when an equivalent FramingUI primitive exists
163
- - Prefer tokens, theme recipes, and existing FramingUI primitives over raw design values
164
- - Semantic wrappers such as \`header\`, \`nav\`, \`section\`, and \`footer\` may stay as HTML, but interactive and form primitives must use FramingUI components when available
165
- - If a screen needs custom JSX beyond the contract, keep it local and explain why FramingUI primitives were insufficient
110
+ Write production React code directly after validation passes.
166
111
 
167
- **Style-contract constraints:**
168
- - If the chosen contract is \`framingui-native\`, ensure the project imports \`@framingui/ui/styles\` before relying on component default variants
169
- - If the chosen contract is \`host-utility\`, prefer reviewed token-aligned utility classes and theme recipes; avoid ad-hoc raw styling when a FramingUI component prop or recipe already covers the need
112
+ **Required rules:**
113
+ - Prefer FramingUI components from \`@framingui/ui\`
114
+ - Use the exact import statements, props, and variants provided in the Step 1 context
115
+ - Use semantic HTML wrappers like \`header\`, \`main\`, \`section\`, and \`footer\` only for document structure
116
+ - Do not replace available FramingUI interactive or form primitives with raw HTML
117
+ - Do not claim a component is unavailable unless the catalog or preview tools confirmed that
170
118
 
171
- **Optional helper:** \`generate_screen\` may still be used as a codegen assistant or reference output, but it is not the default production workflow.
119
+ **Styling rules:**
120
+ - Respect the detected style contract
121
+ - If the project is using FramingUI native styles, ensure \`@import '@framingui/ui/styles';\` is present in global CSS
122
+ - If the project is preserving host utilities, still prefer token-backed utilities and theme recipes over arbitrary raw values
123
+ - Avoid hardcoded design values when FramingUI tokens, variants, or recipes already exist
172
124
 
173
- ---
174
-
175
- ## Step 4/4: Validate Environment (Optional but Recommended)
125
+ ## Step 4/4: Validate the Target Environment and Output
176
126
 
177
127
  **Tool:** \`validate-environment\`
178
128
 
179
- **Purpose:** Verify project has required packages and Tailwind is configured correctly
180
-
181
- **Input:**
182
- \`\`\`json
183
- {
184
- "projectPath": "/path/to/package.json",
185
- "requiredPackages": ["@radix-ui/react-slot", "@radix-ui/react-avatar"],
186
- "sourceFiles": ["app/page.tsx"],
187
- "checkTailwind": true,
188
- "checkStyles": true
189
- }
190
- \`\`\`
191
-
192
- **Output:**
193
- - \`installed\`: Packages already in package.json
194
- - \`missing\`: Packages that need installation
195
- - \`installCommands\`: Commands for npm/yarn/pnpm/bun
196
- - \`tailwind\`: Tailwind config validation results
197
- - \`issues\`: Problems found
198
- - \`fixes\`: How to fix each issue
199
- - \`styles\`: Style contract validation results
200
- - \`styleContract\`: framingui-native, host-utility, mixed, or unknown
201
- - \`issues\`: CSS contract mismatch risks
202
- - \`fixes\`: Recommended next actions before integration
203
- - \`codegen\`: Optional scan of generated React source files for raw HTML primitives that should use \`@framingui/ui\`
204
-
205
- **Tailwind Validation Checks:**
206
- - ✅ tailwind.config.{ts,js,mjs,cjs} exists
207
- - ✅ @framingui/ui content paths included
208
- - ✅ tailwindcss-animate plugin configured
209
-
210
- **When to use:**
211
- - After writing code (Step 3), when user's package.json path is known
212
- - Before delivering code to user
213
- - When user reports missing styles or animations
214
-
215
- ---
216
-
217
- ## Complete Example
129
+ Run this after writing code when the target package path is known.
218
130
 
219
- \`\`\`
220
- User: "Create a login page with email/password fields"
131
+ Use it to verify:
132
+ - missing dependencies
133
+ - install commands
134
+ - Tailwind setup
135
+ - raw HTML primitives or styling escapes in generated source files
221
136
 
222
- 0. Call validate-environment({ projectPath: "...", requiredPackages: [], checkStyles: true })
223
- -> Classify style contract and decide host-utility vs framingui-native before generation
224
- -> If framingui-native, confirm global CSS imports @framingui/ui/styles
137
+ If the tool reports missing setup or raw primitive drift, fix the code before delivery.
225
138
 
226
- 1. Call get-screen-generation-context({ description: "login page..." })
227
- → Receive template hints, component plan, section plan, definition starter, and component contracts
228
- → If any form control, icon, or theme usage is ambiguous, call preview-component / list-icon-libraries / preview-theme before drafting
229
-
230
- 2. Generate Screen Definition JSON based on definitionStarter + componentPlan
231
- → Call validate-screen-definition({ definition: {...} })
232
- → Apply autoFixPatches if any, re-validate if needed
233
-
234
- 3. Write React code directly from the validated definition and Step 1 component contracts
235
- → Preserve the validated layout structure
236
- → Use documented props instead of guessing
237
-
238
- 4. Call validate-environment({ projectPath: "...", requiredPackages: [...], sourceFiles: ["app/page.tsx"] })
239
- → Show user missing packages and install commands
240
- → Warn about Tailwind config issues if any
241
- → Fail the handoff if codegen scan finds raw HTML primitives that should use FramingUI components
242
-
243
- 5. Deliver code to user with complete setup instructions
244
- \`\`\`
139
+ ## Best Practices
245
140
 
246
- ## Troubleshooting
247
-
248
- **Validation fails in Step 2:**
249
- - Read error messages carefully - they include suggestions and autoFix patches
250
- - Apply autoFixPatches to auto-correct common issues
251
- - Check token names match SPEC-LAYOUT-001
252
- - Verify component IDs exist (use list-components)
253
- - Prefer componentPlan before exploring optional alternatives
254
-
255
- **Code writing is blocked in Step 3:**
256
- - Ensure Screen Definition passed validation in Step 2
257
- - Resolve any Step 1 metadata warnings before guessing props
258
- - Use \`preview-component\` when a component contract is incomplete
259
- - Use \`preview-theme\` before relying on theme defaults you have not inspected
260
- - Use \`list-icon-libraries\` before adding icons that were not explicitly chosen
261
-
262
- **Missing dependencies:**
263
- - Always run Step 4 to verify environment
264
- - Show install commands to user
265
- - Check Tailwind config includes @framingui/ui paths
266
-
267
- **Components render without styles:**
268
- - Verify Tailwind content paths include @framingui/ui
269
- - Check tailwindcss-animate plugin is configured
270
- - Check whether the target project is \`host-utility\`, \`mixed\`, or \`framingui-native\`
271
- - If the project is \`framingui-native\`, verify the global stylesheet imports \`@framingui/ui/styles\`
272
- - If the project is utility-first, prefer explicit reviewed classes instead of relying on FramingUI component defaults
273
- - Run validate-environment to diagnose
274
-
275
- ---
141
+ 1. Start with \`get-screen-generation-context\`
142
+ 2. Use \`includeExamples: false\` unless examples are actually needed
143
+ 3. Treat \`templateMatch\` as a hint, not a hard constraint
144
+ 4. Treat \`components\` as the source of truth
145
+ 5. Validate the definition before writing JSX
146
+ 6. Never parse MCP transcript text with shell or Python JSON tooling
147
+ 7. Run \`validate-environment\` before handoff
276
148
 
277
- ## Best Practices
149
+ ## Optional Helper Path
278
150
 
279
- 1. Always run Step 0 preflight before generation when projectPath is known
280
- 2. ✅ Validate before writing code (Step 2)
281
- 3. ✅ Write code from the validated definition and component contracts (Step 3)
282
- 4. ✅ Use \`generate_screen\` only as an optional helper, not as a required workflow step
283
- 5. ✅ Check environment before delivering code (Step 4)
284
- 6. ✅ Use strict validation mode for production
285
- 7. ✅ Include theme recipes for visual consistency
286
- 8. ✅ Use inline props from context instead of guessing
287
- 9. ✅ Use template hints only as inspiration, not as structural constraints
288
- 10. ✅ Confirm the target style contract before relying on CSS variables or component defaults
289
- 11. ✅ Call \`preview-component\`, \`preview-theme\`, or \`list-icon-libraries\` whenever Step 1 leaves an ambiguity
290
- 12. ✅ Run post-generation \`validate-environment\` with \`sourceFiles\` to catch raw HTML primitives and style-contract drift
291
-
292
- ## Alternative Workflows
293
-
294
- **Legacy prototyping helper:**
295
- - \`generate-blueprint\` → \`export-screen\` remains available for backward compatibility, but new agent flows should prefer \`get-screen-generation-context\`
296
-
297
- **Production (recommended):**
298
- - Follow complete 4-step workflow above
299
-
300
- **Optional codegen assist:**
301
- - \`generate_screen\` can be used after validation when you want a reference implementation or a starting point`,
151
+ \`generate_screen\` remains available as an optional helper for reference code generation, but it is not the default production workflow and should not replace validation plus direct writing.`,
302
152
  },
303
153
  },
304
154
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"screen-workflow.js","sourceRoot":"","sources":["../../src/prompts/screen-workflow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gHA8RgG;iBACvG;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"screen-workflow.js","sourceRoot":"","sources":["../../src/prompts/screen-workflow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gMA2IgL;iBACvL;aACF;SACF;KACF,CAAC;AACJ,CAAC"}