@unabridged/midwest 0.21.1 → 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.
- package/README.md +63 -0
- package/app/assets/javascript/midwest/index.ts +8 -2
- package/app/assets/javascript/midwest.js +725 -20
- package/app/assets/javascript/midwest.js.map +1 -1
- package/app/assets/stylesheets/midwest.css +1 -1
- package/app/assets/stylesheets/midwest.tailwind.css +6 -1
- package/dist/css/midwest.css +1 -1
- package/dist/javascript/collection/app/assets/javascript/midwest/index.js +8 -2
- package/dist/javascript/collection/app/assets/javascript/midwest/index.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/code_block_component/code_block_component_controller.js +17 -0
- package/dist/javascript/collection/app/components/midwest/code_block_component/code_block_component_controller.js.map +1 -0
- package/dist/javascript/collection/app/components/midwest/dialog_component/dialog_component_controller.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/form/date_picker_component/date_picker_component_controller.js +243 -0
- package/dist/javascript/collection/app/components/midwest/form/date_picker_component/date_picker_component_controller.js.map +1 -0
- package/dist/javascript/collection/app/components/midwest/form/file_component/file_component_controller.js +35 -1
- package/dist/javascript/collection/app/components/midwest/form/file_component/file_component_controller.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/form/input_component/input_component_controller.js +72 -2
- package/dist/javascript/collection/app/components/midwest/form/input_component/input_component_controller.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/form/live_summary_component/live_summary_component_controller.js +12 -0
- package/dist/javascript/collection/app/components/midwest/form/live_summary_component/live_summary_component_controller.js.map +1 -1
- package/dist/javascript/collection/app/components/midwest/form/time_picker_component/time_picker_component_controller.js +164 -0
- package/dist/javascript/collection/app/components/midwest/form/time_picker_component/time_picker_component_controller.js.map +1 -0
- package/dist/javascript/collection/app/components/midwest/password_requirements_component/password_requirements_component_controller.js +194 -0
- package/dist/javascript/collection/app/components/midwest/password_requirements_component/password_requirements_component_controller.js.map +1 -0
- package/dist/javascript/midwest.js +725 -20
- package/dist/javascript/midwest.js.map +1 -1
- 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"
|
|
@@ -13,7 +13,6 @@ import Form from '../../../components/midwest/form/form_controller'
|
|
|
13
13
|
import CountdownTimer from '../../../components/midwest/countdown_timer_component/countdown_timer_component_controller'
|
|
14
14
|
import Badge from '../../../components/midwest/badge_component/badge_component_controller'
|
|
15
15
|
import Confirmation from '../../../components/midwest/confirmation_component/confirmation_component_controller'
|
|
16
|
-
import AvatarGroup from '../../../components/midwest/avatar_group_component/avatar_group_component_controller'
|
|
17
16
|
import Chart from '../../../components/midwest/chart_component/chart_component_controller'
|
|
18
17
|
import Range from '../../../components/midwest/form/range_component/range_component_controller'
|
|
19
18
|
import Rating from '../../../components/midwest/rating_component/rating_component_controller'
|
|
@@ -29,6 +28,10 @@ import ShowIf from '../../../components/midwest/show_if_component/show_if_compon
|
|
|
29
28
|
import TreeView from '../../../components/midwest/tree_view_component/tree_view_component_controller'
|
|
30
29
|
import CommandPalette from '../../../components/midwest/command_palette_component/command_palette_component_controller'
|
|
31
30
|
import Repeatable from '../../../components/midwest/form/repeatable_component/repeatable_component_controller'
|
|
31
|
+
import PasswordRequirements from '../../../components/midwest/password_requirements_component/password_requirements_component_controller'
|
|
32
|
+
import CodeBlock from '../../../components/midwest/code_block_component/code_block_component_controller'
|
|
33
|
+
import DatePicker from '../../../components/midwest/form/date_picker_component/date_picker_component_controller'
|
|
34
|
+
import TimePicker from '../../../components/midwest/form/time_picker_component/time_picker_component_controller'
|
|
32
35
|
/* IMPORTS */
|
|
33
36
|
|
|
34
37
|
export { Card, Banner, CountdownTimer, Chart }
|
|
@@ -49,7 +52,6 @@ export function registerMidwestControllers (application: any) {
|
|
|
49
52
|
application.register('midwest-form', Form)
|
|
50
53
|
application.register('midwest-badge', Badge)
|
|
51
54
|
application.register('midwest-confirmation', Confirmation)
|
|
52
|
-
application.register('midwest-avatar-group', AvatarGroup)
|
|
53
55
|
application.register('midwest-chart', Chart)
|
|
54
56
|
application.register('midwest-range', Range)
|
|
55
57
|
application.register('midwest-rating', Rating)
|
|
@@ -65,5 +67,9 @@ export function registerMidwestControllers (application: any) {
|
|
|
65
67
|
application.register('midwest-tree-view', TreeView)
|
|
66
68
|
application.register('midwest-command-palette', CommandPalette)
|
|
67
69
|
application.register('midwest-repeatable', Repeatable)
|
|
70
|
+
application.register('midwest-password-requirements', PasswordRequirements)
|
|
71
|
+
application.register('midwest-code-block', CodeBlock)
|
|
72
|
+
application.register('midwest-date-picker', DatePicker)
|
|
73
|
+
application.register('midwest-time-picker', TimePicker)
|
|
68
74
|
/* EXPORTS */
|
|
69
75
|
}
|