Module: RailsAiContext::VFS

Defined in:
lib/rails_ai_context/vfs.rb

Overview

Virtual File System — pattern-matched URI routing for MCP resources. Each resolve call introspects fresh (zero stale data).

Constant Summary collapse

SCHEME =
"rails-ai-context"
PATTERNS =
[
  { pattern: %r{\Arails-ai-context://controllers/([^/]+)/([^/]+)\z}, handler: :resolve_controller_action },
  { pattern: %r{\Arails-ai-context://controllers/([^/]+)\z}, handler: :resolve_controller },
  { pattern: %r{\Arails-ai-context://models/(.+)\z}, handler: :resolve_model },
  { pattern: %r{\Arails-ai-context://views/(.+)\z}, handler: :resolve_view },
  { pattern: %r{\Arails-ai-context://routes/(.+)\z}, handler: :resolve_routes }
].freeze

Class Method Summary collapse

Class Method Details

.resolve(uri) ⇒ Object

Resolve a rails-ai-context:// URI to MCP resource content. Returns an array of content hashes: [mime_type:, text:]



22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_ai_context/vfs.rb', line 22

def resolve(uri)
  PATTERNS.each do |entry|
    match = uri.match(entry[:pattern])
    next unless match

    return send(entry[:handler], uri, *match.captures)
  end

  raise RailsAiContext::Error, "Unknown VFS URI: #{uri}"
end