@unabridged/midwest 0.22.0 → 0.22.1

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 (2) hide show
  1. package/README.md +63 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -109,6 +109,69 @@ bin/rails midwest:generate:component YourComponent
109
109
 
110
110
  The syntax follows [ViewComponent's generator](https://viewcomponent.org/guide/generators.html).
111
111
 
112
+ ### MCP Server
113
+
114
+ Midwest ships an [MCP](https://modelcontextprotocol.io) server that gives AI agents live access to the component API. To connect, add to `.mcp.json`:
115
+
116
+ ```json
117
+ {
118
+ "mcpServers": {
119
+ "midwest": {
120
+ "command": "bundle",
121
+ "args": ["exec", "midwest_mcp"]
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ The server exposes 8 tools: `list_components`, `get_component_api`, `search_components`, `get_component_examples`, `get_helper_methods`, `get_form_builder_info`, `get_component_relationships`, and `validate_component_usage`.
128
+
129
+ ### Component Guidance
130
+
131
+ The MCP server includes a guidance system that helps agents avoid common composition mistakes. Guidance is stored in `lib/midwest/mcp/data/component_guidance.yml` and surfaced through MCP tools automatically.
132
+
133
+ Two data sources feed into guidance:
134
+
135
+ - **Auto-detected**: Template scanning discovers which components internally render other components (e.g., `StatComponent` renders a `CardComponent`). This powers redundant nesting warnings.
136
+ - **Curated**: Anti-patterns and best practices added to the YAML file from real agent mistakes observed in the field.
137
+
138
+ Use `bin/guidance` to manage guidance data:
139
+
140
+ ```bash
141
+ bin/guidance # List components with guidance and auto-detected internal renders
142
+ bin/guidance show stat # Show full guidance for a component
143
+ bin/guidance add # Describe a pattern in plain text; Claude formats and appends it
144
+ bin/guidance scan # Display the internally-renders graph for all components
145
+ bin/guidance check # Validate YAML keys against the component index
146
+ ```
147
+
148
+ The `add` command opens your `$EDITOR` for you to describe an anti-pattern or best practice in plain English. When you save and close, the Claude CLI processes your description into properly formatted YAML and appends it to the guidance file. This is the fastest way to capture a mistake you spotted an agent making in the field.
149
+
150
+ You can also edit `lib/midwest/mcp/data/component_guidance.yml` directly:
151
+
152
+ ```yaml
153
+ stat_component:
154
+ anti_patterns:
155
+ - title: "Wrapping stat in a card"
156
+ description: "StatComponent already renders a CardComponent internally."
157
+ bad: |
158
+ <%= midwest_card do %>
159
+ <%= midwest_stat value: "1,234", label: "Users" %>
160
+ <% end %>
161
+ good: |
162
+ <%= midwest_stat value: "1,234", label: "Users" %>
163
+ best_practices:
164
+ - title: "Group stats in a grid"
165
+ description: "Use midwest_grid to lay out multiple stats."
166
+ example: |
167
+ <%= midwest_grid columns: 3 do %>
168
+ <%= midwest_stat value: "1,234", label: "Users" %>
169
+ <%= midwest_stat value: "567", label: "Orders" %>
170
+ <% end %>
171
+ ```
172
+
173
+ Run `bin/guidance check` after editing to verify all component keys are valid.
174
+
112
175
  ### Deploying your application
113
176
 
114
177
  In order to deploy your application the deploy server will need access to the private repo. One way to accomplish that is to add the deploy key on this repo to the deploy server. You should be able to create the key from the values in the Shared 1Password vault entry "GitHub - Midwest"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unabridged/midwest",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "ViewComponents for Midwest Design System",
5
5
  "main": "dist/javascript/midwest.js",
6
6
  "style": "dist/css/midwest.css",