stimulus_plumbers_mcp 0.4.5 → 0.4.9
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.
- checksums.yaml +4 -4
- data/README.md +46 -25
- data/lib/stimulus_plumbers/mcp/loaders/aria_loader.rb +31 -0
- data/lib/stimulus_plumbers/mcp/loaders/component_docs_loader.rb +38 -0
- data/lib/stimulus_plumbers/mcp/loaders/component_manifest_loader.rb +46 -0
- data/lib/stimulus_plumbers/mcp/loaders/component_requirements.rb +41 -0
- data/lib/stimulus_plumbers/mcp/loaders/component_schema_loader.rb +49 -0
- data/lib/stimulus_plumbers/mcp/loaders/component_theme_loader.rb +41 -0
- data/lib/stimulus_plumbers/mcp/loaders/controller_docs_loader.rb +31 -0
- data/lib/stimulus_plumbers/mcp/loaders/controller_schema_loader.rb +53 -0
- data/lib/stimulus_plumbers/mcp/loaders/guide.md +48 -0
- data/lib/stimulus_plumbers/mcp/loaders/guide_loader.rb +40 -4
- data/lib/stimulus_plumbers/mcp/loaders/icons_loader.rb +34 -0
- data/lib/stimulus_plumbers/mcp/loaders/support/docs_table_parser.rb +112 -0
- data/lib/stimulus_plumbers/mcp/loaders/support/gem_vendor_path.rb +18 -0
- data/lib/stimulus_plumbers/mcp/loaders/tailwind_loader.rb +35 -0
- data/lib/stimulus_plumbers/mcp/loaders/versions_loader.rb +110 -0
- data/lib/stimulus_plumbers/mcp/plugins/aria.rb +34 -0
- data/lib/stimulus_plumbers/mcp/plugins/base.rb +40 -31
- data/lib/stimulus_plumbers/mcp/plugins/component_docs.rb +96 -0
- data/lib/stimulus_plumbers/mcp/plugins/component_schema.rb +133 -0
- data/lib/stimulus_plumbers/mcp/plugins/component_theme.rb +90 -0
- data/lib/stimulus_plumbers/mcp/plugins/controller_docs.rb +91 -0
- data/lib/stimulus_plumbers/mcp/plugins/controller_schema.rb +81 -0
- data/lib/stimulus_plumbers/mcp/plugins/guide.rb +70 -16
- data/lib/stimulus_plumbers/mcp/plugins/icons.rb +42 -0
- data/lib/stimulus_plumbers/mcp/plugins/tailwind.rb +69 -45
- data/lib/stimulus_plumbers/mcp/plugins/versions.rb +44 -0
- data/lib/stimulus_plumbers/mcp/server.rb +26 -9
- data/lib/stimulus_plumbers/mcp/version.rb +1 -1
- data/lib/stimulus_plumbers_mcp.rb +32 -11
- metadata +23 -12
- data/lib/stimulus_plumbers/mcp/loaders/component_controller_map.rb +0 -38
- data/lib/stimulus_plumbers/mcp/loaders/docs_loader.rb +0 -129
- data/lib/stimulus_plumbers/mcp/loaders/guide/overview.md +0 -48
- data/lib/stimulus_plumbers/mcp/loaders/schema_loader.rb +0 -45
- data/lib/stimulus_plumbers/mcp/loaders/stimulus_manifest.rb +0 -47
- data/lib/stimulus_plumbers/mcp/loaders/tailwind_theme_loader.rb +0 -29
- data/lib/stimulus_plumbers/mcp/loaders/theme_loader.rb +0 -97
- data/lib/stimulus_plumbers/mcp/plugins/docs.rb +0 -82
- data/lib/stimulus_plumbers/mcp/plugins/schema.rb +0 -110
- data/lib/stimulus_plumbers/mcp/plugins/stimulus.rb +0 -66
- data/lib/stimulus_plumbers/mcp/plugins/theme.rb +0 -66
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d89f95c23f003c323773ab4dc24b1b21ca2fd891fdc388c77e65987942cb581
|
|
4
|
+
data.tar.gz: 5c32a25cf7e0cf97f11d0bf6f209dc4d3ff33068d1fd4fa10d83ccb2578e3474
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d8f30f1f03e404e8996f0e12012f624e2df37dab801accf2f194f5d5a758c6e56369e74525a0ffa91537d56a04f03273e9b0de546c78d4e9a6f1d27f2a8c558
|
|
7
|
+
data.tar.gz: e8feda10a77d64456f63ccb8bc88dc20061aa9a6145d0bff8e15adc18fea0b8491f0a1017d54186302a96079598789e7376d058e9cafac56571f00e37dda28b1
|
data/README.md
CHANGED
|
@@ -18,34 +18,48 @@ gem install stimulus_plumbers_mcp
|
|
|
18
18
|
| URI | Content |
|
|
19
19
|
|-----|---------|
|
|
20
20
|
| `guide://overview` | **Start here** — map of the form/view/stimulus API with pointers to every tool/resource |
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `theme
|
|
30
|
-
| `theme
|
|
31
|
-
| `theme
|
|
32
|
-
| `tailwind
|
|
33
|
-
| `
|
|
21
|
+
| `guide://{name}` | Per-package usage guide: `component` (Rails forms/views), `controller` (plain-JS/non-Rails setup), `tailwind` (Tailwind install/theming), `theme` (custom theme integration contract) |
|
|
22
|
+
| `aria://reference` | WCAG 2.1 AA criteria, keyboard navigation patterns, and per-component ARIA patterns |
|
|
23
|
+
| `component://index` | Index of all component theme keys |
|
|
24
|
+
| `component://icons` | All available icon names |
|
|
25
|
+
| `component://integration` | Map from component key → required Stimulus controller identifiers |
|
|
26
|
+
| `component://{name}/schema` | Params, valid values, defaults + required controllers |
|
|
27
|
+
| `component://{name}/docs` | Full markdown doc with ERB examples |
|
|
28
|
+
| `component://{name}/helper` | Full `sp_` helper surface: keyword options + defaults (grouped by helper signature) + slot methods |
|
|
29
|
+
| `component://theme` | Index of theme-implementable component keys |
|
|
30
|
+
| `component://{name}/theme` | Method name, param signature, return contract |
|
|
31
|
+
| `component://theme/base` | Custom theme authoring guide |
|
|
32
|
+
| `component://tailwind` | Index of Tailwind theme component keys |
|
|
33
|
+
| `component://{name}/tailwind` | Tailwind CSS classes per variant |
|
|
34
|
+
| `controller://index` | Index of Stimulus controller identifiers |
|
|
35
|
+
| `controller://{name}/schema` | Targets, values, outlets, classes for a controller |
|
|
36
|
+
| `controller://docs` | Index of JS controller narrative docs, grouped by controller family |
|
|
37
|
+
| `controller://docs/{name}` | Narrative usage doc for a controller family (plain-JS/Hotwire, no Rails helpers) |
|
|
38
|
+
| `versions://sources` | Resolved version (and resolution path) of each source gem/package |
|
|
34
39
|
|
|
35
40
|
## Tools
|
|
36
41
|
|
|
37
42
|
| Tool | Input | Output |
|
|
38
43
|
|------|-------|--------|
|
|
39
44
|
| `list_components` | — | All component theme keys |
|
|
40
|
-
| `
|
|
41
|
-
| `get_component_schema` | `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
+
| `list_component_docs` | — | Components with markdown docs + helper signatures (the `component://{name}/docs`+`/helper` set) |
|
|
46
|
+
| `get_component_schema` | `name` | Themed params (type/variant/size) + defaults + required controllers |
|
|
47
|
+
| `get_component_helper` | `name` | Full `sp_` helper surface — keyword options grouped by helper signature (incl. `icon_leading`) + slot methods |
|
|
48
|
+
| `get_component_examples` | `name` | ERB code fences from docs |
|
|
49
|
+
| `get_field_as_values` | `builder_method` (`field`/`collection_field`/`choice`) | Valid `as:` values |
|
|
50
|
+
| `get_field_as_controller` | `as` | Stimulus controller identifier backing a controller-backed `as:` value |
|
|
51
|
+
| `list_component_themes` | — | Component keys implementable in a custom theme |
|
|
52
|
+
| `get_component_theme` | `name` | Method signature + return contract for custom theme |
|
|
53
|
+
| `list_component_tailwind` | — | Component keys implemented by the Tailwind theme |
|
|
54
|
+
| `get_component_tailwind` | `name` | Tailwind CSS utility classes per variant |
|
|
55
|
+
| `list_icons` | — | All available icon names bundled with the Tailwind theme |
|
|
45
56
|
| `list_controllers` | — | All Stimulus controller identifiers |
|
|
46
|
-
| `get_controller_schema` | `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
57
|
+
| `get_controller_schema` | `name` | Targets, values, outlets, classes |
|
|
58
|
+
| `list_controller_docs` | — | Controller doc families available at `controller://docs/{name}` |
|
|
59
|
+
| `get_controller_docs` | `name` | Narrative usage doc for a controller family |
|
|
60
|
+
| `get_source_versions` | — | Resolved version (and resolution path) of each source |
|
|
61
|
+
| `list_guides` | — | Available per-package guide names (`component`/`controller`/`tailwind`/`theme`) |
|
|
62
|
+
| `get_guide` | `name` | Per-package usage guide content |
|
|
49
63
|
|
|
50
64
|
## IDE Setup
|
|
51
65
|
|
|
@@ -60,11 +74,11 @@ gem install stimulus_plumbers_mcp
|
|
|
60
74
|
}
|
|
61
75
|
```
|
|
62
76
|
|
|
63
|
-
Requires Ruby >= 3.3. No `cwd` required. Pin a specific version by adding it to your `Gemfile` and running `bundle exec gem exec stimulus-plumbers-mcp`.
|
|
77
|
+
Requires Ruby >= 3.3 for the `gem exec` subcommand (the gem itself supports Ruby >= 3.0). No `cwd` required. Pin a specific version by adding it to your `Gemfile` and running `bundle exec gem exec stimulus-plumbers-mcp`.
|
|
64
78
|
|
|
65
79
|
## Stimulus Manifest
|
|
66
80
|
|
|
67
|
-
`
|
|
81
|
+
`controller://` resources require the controller manifest. The server resolves it in order:
|
|
68
82
|
|
|
69
83
|
1. `node_modules/@stimulus-plumbers/controllers/dist/controllers.manifest.json` — npm/yarn/bun projects
|
|
70
84
|
2. `vendor/controllers.manifest.json` inside the installed `stimulus_plumbers` gem — importmaps fallback
|
|
@@ -72,6 +86,10 @@ Requires Ruby >= 3.3. No `cwd` required. Pin a specific version by adding it to
|
|
|
72
86
|
|
|
73
87
|
No extra steps needed for setups 1 or 2.
|
|
74
88
|
|
|
89
|
+
Each controller's schema also includes a `wiring` field (which methods/events/targets/values the
|
|
90
|
+
`stimulus_plumbers` gem's Ruby helpers reference for it), sourced from that gem's own
|
|
91
|
+
`vendor/component/manifest.json`, built by `rake build:manifest`.
|
|
92
|
+
|
|
75
93
|
## Development
|
|
76
94
|
|
|
77
95
|
```bash
|
|
@@ -82,6 +100,9 @@ bundle install
|
|
|
82
100
|
# Build the Stimulus controller manifest (pure Node, no toolchain install needed)
|
|
83
101
|
cd ../stimulus-plumbers && node --run build:manifest && cd -
|
|
84
102
|
|
|
103
|
+
# Build the Ruby wiring manifest (needs the controller manifest above)
|
|
104
|
+
cd ../stimulus-plumbers-rails && bundle exec rake build:manifest && cd -
|
|
105
|
+
|
|
85
106
|
# Start the server
|
|
86
107
|
bundle exec ruby bin/server
|
|
87
108
|
```
|
|
@@ -94,9 +115,9 @@ bundle exec ruby bin/server
|
|
|
94
115
|
bundle exec ruby bin/mcp-query tools # list tools
|
|
95
116
|
bundle exec ruby bin/mcp-query resources # list resources
|
|
96
117
|
bundle exec ruby bin/mcp-query tool list_components # call a tool (no args)
|
|
97
|
-
bundle exec ruby bin/mcp-query tool get_component_schema '{"
|
|
118
|
+
bundle exec ruby bin/mcp-query tool get_component_schema '{"name":"button"}'
|
|
98
119
|
bundle exec ruby bin/mcp-query read guide://overview
|
|
99
|
-
bundle exec ruby bin/mcp-query read
|
|
120
|
+
bundle exec ruby bin/mcp-query read component://form/docs
|
|
100
121
|
```
|
|
101
122
|
|
|
102
123
|
```bash
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class AriaLoader
|
|
6
|
+
FILENAME = "ARIA.md"
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def call
|
|
10
|
+
path = resolved_path
|
|
11
|
+
path ? File.read(path) : ""
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def resolved_path
|
|
17
|
+
aria_paths.find { |p| File.exist?(p) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def aria_paths
|
|
21
|
+
[
|
|
22
|
+
# 1. Monorepo dev checkout — the root file is the freshest copy while working locally.
|
|
23
|
+
File.expand_path(File.join(__dir__, "../../../../..", FILENAME)),
|
|
24
|
+
# 2. gem exec — vendored into the rails gem at release time (bin/release).
|
|
25
|
+
GemVendorPath.resolve(FILENAME)
|
|
26
|
+
].compact
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class ComponentDocsLoader
|
|
6
|
+
class << self
|
|
7
|
+
def docs_dir
|
|
8
|
+
@docs_dir ||= resolve_docs_dir
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
Dir[File.join(docs_dir, "*.md")].each_with_object({}) do |path, result|
|
|
13
|
+
name = File.basename(path, ".md").to_sym
|
|
14
|
+
content = File.read(path)
|
|
15
|
+
result[name] = {
|
|
16
|
+
content: content,
|
|
17
|
+
examples: extract_erb_examples(content),
|
|
18
|
+
signature: DocsTableParser.call(content)
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def resolve_docs_dir
|
|
26
|
+
gem_dir = Gem::Specification.find_by_name("stimulus_plumbers").gem_dir
|
|
27
|
+
File.join(gem_dir, "docs/component")
|
|
28
|
+
rescue Gem::MissingSpecError
|
|
29
|
+
File.expand_path("../../../../../stimulus-plumbers-rails/docs/component", __dir__)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def extract_erb_examples(content)
|
|
33
|
+
content.scan(%r{```erb\n(.*?)```}m).map(&:first).map(&:strip)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
# Reads the stimulus_plumbers gem's own generated wiring manifest (vendor/component/manifest.json).
|
|
6
|
+
# Unlike ControllerSchemaLoader, this never crosses ecosystems — stimulus_plumbers is always
|
|
7
|
+
# installed alongside this gem (hard runtime dependency), so there's no node_modules-style path.
|
|
8
|
+
class ComponentManifestLoader
|
|
9
|
+
MANIFEST_FILENAME = "manifest.json"
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
def call
|
|
13
|
+
path = resolved_path
|
|
14
|
+
|
|
15
|
+
unless path
|
|
16
|
+
StimulusPlumbers::Logger.warn(
|
|
17
|
+
"component manifest not found. Tried:\n" \
|
|
18
|
+
"#{manifest_paths.map { |p| " - #{p}" }.join("\n")}\n" \
|
|
19
|
+
"Run `bundle exec rake build:manifest` in stimulus-plumbers-rails/ to generate it."
|
|
20
|
+
)
|
|
21
|
+
return {}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
JSON.parse(File.read(path))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def resolved_path
|
|
28
|
+
manifest_paths.find { |p| File.exist?(p) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def manifest_paths
|
|
34
|
+
[
|
|
35
|
+
# 1. gem exec / installed gem — vendored at release time
|
|
36
|
+
GemVendorPath.resolve("component", MANIFEST_FILENAME),
|
|
37
|
+
# 2. Monorepo dev fallback
|
|
38
|
+
File.expand_path(
|
|
39
|
+
File.join(__dir__, "../../../../..", "stimulus-plumbers-rails", "vendor", "component", MANIFEST_FILENAME)
|
|
40
|
+
)
|
|
41
|
+
].compact
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class ComponentRequirements
|
|
6
|
+
class << self
|
|
7
|
+
def call
|
|
8
|
+
Components.constants
|
|
9
|
+
.map { |c| Components.const_get(c) }
|
|
10
|
+
.grep(Class)
|
|
11
|
+
.to_h { |klass| [component_key(klass), controllers_for(klass).uniq] }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# Controllers from a component class plus its nested sub-components (e.g. Combobox::Date),
|
|
17
|
+
# keyed to the top-level component. Skips references to sibling components.
|
|
18
|
+
def controllers_for(mod)
|
|
19
|
+
mod.constants(false).flat_map do |const|
|
|
20
|
+
value = mod.const_get(const)
|
|
21
|
+
if const.to_s.end_with?("CONTROLLER")
|
|
22
|
+
Array(value).grep(String).flat_map(&:split)
|
|
23
|
+
elsif nested?(mod, value)
|
|
24
|
+
controllers_for(value)
|
|
25
|
+
else
|
|
26
|
+
[]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def nested?(mod, value)
|
|
32
|
+
value.is_a?(Module) && !value.name.nil? && value.name.start_with?("#{mod.name}::")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def component_key(klass)
|
|
36
|
+
klass.name.demodulize.underscore.to_sym
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class ComponentSchemaLoader
|
|
6
|
+
# Not derivable from Form::Fields::Renderer's method names (`search:` renders via
|
|
7
|
+
# `render_combobox_typeahead`, but wires up "combobox-dropdown", not
|
|
8
|
+
# "combobox-typeahead") — hand-maintained; keep in sync with form.md's "backed by" notes.
|
|
9
|
+
FIELD_AS_CONTROLLERS = {
|
|
10
|
+
date: "combobox-date",
|
|
11
|
+
time: "combobox-time",
|
|
12
|
+
select: "combobox-dropdown",
|
|
13
|
+
search: "combobox-dropdown",
|
|
14
|
+
collection_select: "combobox-dropdown",
|
|
15
|
+
grouped_collection_select: "combobox-dropdown"
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
18
|
+
class << self
|
|
19
|
+
def call
|
|
20
|
+
{
|
|
21
|
+
components: extract_schema,
|
|
22
|
+
field_as: extract_field_as,
|
|
23
|
+
field_as_controllers: FIELD_AS_CONTROLLERS,
|
|
24
|
+
controllers: ComponentRequirements.call
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def extract_schema
|
|
31
|
+
Themes::Base::SCHEMA.transform_values do |param_schema|
|
|
32
|
+
param_schema.transform_values do |meta|
|
|
33
|
+
v = meta[:validate]
|
|
34
|
+
{ default: meta[:default], valid: v.respond_to?(:to_a) ? v.to_a : v.inspect }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def extract_field_as
|
|
40
|
+
{
|
|
41
|
+
field: Form::Fields::Renderer::FIELD.keys,
|
|
42
|
+
collection_field: Form::Fields::Renderer::COLLECTION.keys,
|
|
43
|
+
choice: Form::Fields::Renderer::CHOICE.keys
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class ComponentThemeLoader
|
|
6
|
+
class << self
|
|
7
|
+
def call
|
|
8
|
+
{
|
|
9
|
+
base_doc: base_doc,
|
|
10
|
+
components: extract_interface
|
|
11
|
+
}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
# Same file ComponentDocsLoader already serves at component://theme/docs — avoids a duplicate heredoc.
|
|
17
|
+
def base_doc
|
|
18
|
+
path = File.join(ComponentDocsLoader.docs_dir, "theme.md")
|
|
19
|
+
File.exist?(path) ? File.read(path) : ""
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def extract_interface
|
|
23
|
+
Themes::Base::SCHEMA.each_with_object({}) do |(key, params), result|
|
|
24
|
+
result[key] = {
|
|
25
|
+
method: "#{key}_classes",
|
|
26
|
+
params: params.transform_values { |meta| format_param(meta) },
|
|
27
|
+
returns: "{ classes: String }"
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def format_param(meta)
|
|
33
|
+
valid = meta[:validate]
|
|
34
|
+
entry = { default: meta[:default] }
|
|
35
|
+
entry[:valid] = valid.to_a if valid.respond_to?(:to_a)
|
|
36
|
+
entry
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class ControllerDocsLoader
|
|
6
|
+
class << self
|
|
7
|
+
def docs_dir
|
|
8
|
+
@docs_dir ||= resolve_docs_dir
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
Dir[File.join(docs_dir, "*.md")].to_h do |path|
|
|
13
|
+
[File.basename(path, ".md").to_sym, File.read(path)]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def resolve_docs_dir
|
|
20
|
+
# 1. Monorepo dev checkout — the JS package's own docs are freshest while working locally.
|
|
21
|
+
dev_path = File.expand_path(File.join(__dir__, "../../../../..", "stimulus-plumbers", "docs", "component"))
|
|
22
|
+
return dev_path if Dir.exist?(dev_path)
|
|
23
|
+
|
|
24
|
+
# 2. gem exec — vendored into the rails gem at release time, under vendor/controller/docs/
|
|
25
|
+
# (mirrors the MCP server's controller:// resource namespace).
|
|
26
|
+
GemVendorPath.resolve("controller", "docs") || dev_path
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class ControllerSchemaLoader
|
|
6
|
+
MANIFEST_FILENAME = "controllers.manifest.json"
|
|
7
|
+
# Vendored as manifest.json — the "controllers" prefix is redundant once nested
|
|
8
|
+
# under vendor/controller/ (mirrors the MCP server's controller:// namespace).
|
|
9
|
+
VENDOR_FILENAME = "manifest.json"
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
def call
|
|
13
|
+
path = resolved_path
|
|
14
|
+
|
|
15
|
+
unless path
|
|
16
|
+
StimulusPlumbers::Logger.warn(
|
|
17
|
+
"controller manifest not found. Tried:\n" \
|
|
18
|
+
"#{manifest_paths.map { |p| " - #{p}" }.join("\n")}\n" \
|
|
19
|
+
"Run `node --run build:manifest` in stimulus-plumbers/ to generate it."
|
|
20
|
+
)
|
|
21
|
+
return {}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
controllers = JSON.parse(File.read(path))
|
|
25
|
+
wiring = ComponentManifestLoader.call
|
|
26
|
+
default_wiring = { "actions" => [], "listens" => [], "targets" => [], "values" => [] }
|
|
27
|
+
|
|
28
|
+
controllers.transform_values { |data| data.merge("wiring" => wiring[data["identifier"]] || default_wiring) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Reused by VersionsLoader to report which fallback location resolved.
|
|
32
|
+
def resolved_path
|
|
33
|
+
manifest_paths.find { |p| File.exist?(p) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def manifest_paths
|
|
39
|
+
[
|
|
40
|
+
# 1. npm/yarn/bun project — version matches project lockfile
|
|
41
|
+
File.join(Dir.pwd, "node_modules/@stimulus-plumbers/controllers/dist", MANIFEST_FILENAME),
|
|
42
|
+
# 2. importmaps users — vendored in Rails gem at release time
|
|
43
|
+
GemVendorPath.resolve("controller", VENDOR_FILENAME),
|
|
44
|
+
# 3. Monorepo dev fallback
|
|
45
|
+
File.expand_path(
|
|
46
|
+
File.join(__dir__, "../../../../..", "stimulus-plumbers", "dist", MANIFEST_FILENAME)
|
|
47
|
+
)
|
|
48
|
+
].compact
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# stimulus-plumbers — overview
|
|
2
|
+
|
|
3
|
+
Accessible Rails view components plus a themed form builder, backed by Stimulus controllers.
|
|
4
|
+
Start here, then drill into the per-package guides and per-component resources/tools below.
|
|
5
|
+
|
|
6
|
+
## Per-package guides
|
|
7
|
+
- `guide://component` — building forms (`f.field`/`f.collection_field`/`f.choice`) and views
|
|
8
|
+
(`sp_*` helpers) with the Rails gem
|
|
9
|
+
- `guide://controller` — plain-JS / non-Rails setup for `@stimulus-plumbers/controllers`
|
|
10
|
+
- `guide://tailwind` — Tailwind theme install + icons
|
|
11
|
+
- `guide://theme` — implementing a custom theme (subclassing `Themes::Base`)
|
|
12
|
+
|
|
13
|
+
Tools: `list_guides`, `get_guide(name:)`.
|
|
14
|
+
|
|
15
|
+
## Building forms and views
|
|
16
|
+
Valid `as:` values: `get_field_as_values(builder_method:)`. Combobox-backed `as:` values' controller
|
|
17
|
+
identifier: `get_field_as_controller(as:)` — `component://{name}/schema` keys are renderer-level, not
|
|
18
|
+
`as:` values. Component helper surface: `get_component_helper(name)`; themed params:
|
|
19
|
+
`get_component_schema(name)`; ERB examples: `get_component_examples(name)`. List everything with
|
|
20
|
+
`list_components`; `list_component_docs` shows which components have full docs
|
|
21
|
+
(`component://{name}/docs`) and helper signatures (`component://{name}/helper`). Icon options take a
|
|
22
|
+
name from `component://icons` (or `list_icons`). All schema components are queryable via
|
|
23
|
+
`get_component_schema`; only a subset have full docs and ERB examples — use `list_component_docs` to
|
|
24
|
+
see what's covered. Full form builder reference: `component://form/docs`.
|
|
25
|
+
|
|
26
|
+
## Stimulus integration
|
|
27
|
+
Most display components are pure markup; interactive ones (combobox, popover, calendar) emit their
|
|
28
|
+
`data-controller` attributes automatically. Component → required controllers: `component://integration`.
|
|
29
|
+
Controller identifiers and details (targets/values/outlets/classes): `controller://index`,
|
|
30
|
+
`get_controller_schema(id)` / `list_controllers`.
|
|
31
|
+
Narrative docs by controller family: `get_controller_docs(name)` / `controller://docs/{name}`.
|
|
32
|
+
|
|
33
|
+
## How this server is organized
|
|
34
|
+
- **Resources** live under entity namespaces — `component://` (Rails `sp_*` helper surface: schema,
|
|
35
|
+
docs, helper, theme, tailwind, icons facets), `controller://` (plain-JS Stimulus surface: schema,
|
|
36
|
+
docs facets), `guide://` (per-package usage guides) — plus `aria://reference` and `versions://sources`.
|
|
37
|
+
**Tools** (`get_*`, `list_*`) expose the same data for targeted lookups. Use whichever your client prefers.
|
|
38
|
+
- `aria://reference` — WCAG 2.1 AA criteria and component ARIA patterns. For generic ARIA/WCAG reference,
|
|
39
|
+
connect the MDN MCP server too: `claude mcp add --transport http mdn https://mcp.mdn.mozilla.net/`
|
|
40
|
+
- Each source (schema, docs, theme, tailwind, icons, stimulus, stimulus_docs, guide) is read from an
|
|
41
|
+
independently-versioned gem/npm package — `versions://sources` / `get_source_versions` reports what's
|
|
42
|
+
actually resolved, useful if data looks stale or inconsistent with the app code you're generating for.
|
|
43
|
+
`icons` versions with the Tailwind theme gem, not the schema gem, since the bundled icon set is
|
|
44
|
+
Tailwind-specific.
|
|
45
|
+
- **View generation** uses the form builder + `sp_` helper tools/resources above. The `component://theme`
|
|
46
|
+
and `component://tailwind` facets are for *theme authors* implementing a custom theme — skip them when
|
|
47
|
+
generating views.
|
|
48
|
+
- **Errors are uniform:** a not-found tool/resource returns `{ "error": "..." }` (tools also set `isError`).
|
|
@@ -3,12 +3,48 @@
|
|
|
3
3
|
module StimulusPlumbers
|
|
4
4
|
module MCP
|
|
5
5
|
class GuideLoader
|
|
6
|
-
OVERVIEW_PATH = File.expand_path("guide
|
|
6
|
+
OVERVIEW_PATH = File.expand_path("guide.md", __dir__).freeze
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
class << self
|
|
9
|
+
def call
|
|
10
|
+
{
|
|
11
|
+
overview: read_file(OVERVIEW_PATH),
|
|
12
|
+
component: read_file(component_guide_path),
|
|
13
|
+
controller: read_file(controller_guide_path),
|
|
14
|
+
tailwind: read_file(tailwind_guide_path),
|
|
15
|
+
theme: read_file(File.join(ComponentDocsLoader.docs_dir, "theme.md"))
|
|
16
|
+
}
|
|
17
|
+
end
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
# Reused by VersionsLoader to report which fallback location resolved.
|
|
20
|
+
def controller_guide_path
|
|
21
|
+
# 1. Monorepo dev checkout — the JS package's own docs are freshest while working locally.
|
|
22
|
+
dev_path = File.expand_path(File.join(__dir__, "../../../../..", "stimulus-plumbers", "docs", "guide.md"))
|
|
23
|
+
return dev_path if File.exist?(dev_path)
|
|
24
|
+
|
|
25
|
+
# 2. gem exec — vendored into the rails gem at release time, under vendor/controller/guide.md.
|
|
26
|
+
GemVendorPath.resolve("controller", "guide.md")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def read_file(path)
|
|
32
|
+
path && File.exist?(path) ? File.read(path) : ""
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def component_guide_path
|
|
36
|
+
gem_dir = Gem::Specification.find_by_name("stimulus_plumbers").gem_dir
|
|
37
|
+
File.join(gem_dir, "docs/guide.md")
|
|
38
|
+
rescue Gem::MissingSpecError
|
|
39
|
+
File.expand_path("../../../../../stimulus-plumbers-rails/docs/guide.md", __dir__)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def tailwind_guide_path
|
|
43
|
+
gem_dir = Gem::Specification.find_by_name("stimulus_plumbers_tailwind").gem_dir
|
|
44
|
+
File.join(gem_dir, "docs/guide.md")
|
|
45
|
+
rescue Gem::MissingSpecError
|
|
46
|
+
File.expand_path("../../../../../stimulus-plumbers-tailwind/docs/guide.md", __dir__)
|
|
47
|
+
end
|
|
12
48
|
end
|
|
13
49
|
end
|
|
14
50
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusPlumbers
|
|
4
|
+
module MCP
|
|
5
|
+
class IconsLoader
|
|
6
|
+
class << self
|
|
7
|
+
def call
|
|
8
|
+
heroicon_dir = Themes::Tailwind::Icons::Heroicon.send(:svg_dir)
|
|
9
|
+
custom_dir = Themes::Tailwind::Icons::Custom.send(:svg_dir)
|
|
10
|
+
|
|
11
|
+
(outline_names(heroicon_dir) + solid_names(heroicon_dir) + custom_names(custom_dir) + alias_names).uniq.sort
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def outline_names(heroicon_dir)
|
|
17
|
+
Dir[File.join(heroicon_dir, "outline", "*.svg")].map { |f| File.basename(f, ".svg") }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def solid_names(heroicon_dir)
|
|
21
|
+
Dir[File.join(heroicon_dir, "solid", "*.svg")].map { |f| "#{File.basename(f, ".svg")}/solid" }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def custom_names(custom_dir)
|
|
25
|
+
Dir[File.join(custom_dir, "*.svg")].map { |f| File.basename(f, ".svg") }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def alias_names
|
|
29
|
+
Themes::Tailwind::Icon::ALIASES.keys
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|