Class: StimulusPlumbers::MCP::ControllerSchemaLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_plumbers/mcp/loaders/controller_schema_loader.rb

Constant Summary collapse

MANIFEST_FILENAME =
"controllers.manifest.json"
VENDOR_FILENAME =

Vendored as manifest.json — the "controllers" prefix is redundant once nested under vendor/controller/ (mirrors the MCP server's controller:// namespace).

"manifest.json"

Class Method Summary collapse

Class Method Details

.callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/stimulus_plumbers/mcp/loaders/controller_schema_loader.rb', line 12

def call
  path = resolved_path

  unless path
    StimulusPlumbers::Logger.warn(
      "controller manifest not found. Tried:\n" \
      "#{manifest_paths.map { |p| "  - #{p}" }.join("\n")}\n" \
      "Run `node --run build:manifest` in stimulus-plumbers/ to generate it."
    )
    return {}
  end

  controllers = JSON.parse(File.read(path))
  wiring = ComponentManifestLoader.call
  default_wiring = { "actions" => [], "listens" => [], "targets" => [], "values" => [] }

  controllers.transform_values { |data| data.merge("wiring" => wiring[data["identifier"]] || default_wiring) }
end

.resolved_pathObject

Reused by VersionsLoader to report which fallback location resolved.



32
33
34
# File 'lib/stimulus_plumbers/mcp/loaders/controller_schema_loader.rb', line 32

def resolved_path
  manifest_paths.find { |p| File.exist?(p) }
end