Class: RailsAiContext::Tools::GetAutoload

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/rails_ai_context/tools/get_autoload.rb

Constant Summary collapse

MAX_PATHS_SHOWN =

Framework path lists run long; enough rows to cover an app's own paths plus the Rails defaults under them.

40

Constants inherited from BaseTool

BaseTool::DEFAULT_SESSION, BaseTool::MAX_SESSIONS, BaseTool::MAX_SESSION_ID_LENGTH, BaseTool::SESSION_CONTEXT, BaseTool::SHARED_CACHE

Class Method Summary collapse

Methods inherited from BaseTool

abstract!, abstract?, api_only_app?, api_only_note, cache_key, cached_context, config, current_session, #dedupe_put_patch_routes, detail_param?, error_response, evict_oldest_sessions, extract_method_source_from_file, extract_method_source_from_string, find_closest_match, fuzzy_find_key, guide_row, inherited, introspection_warnings_note, invalid_detail_note, normalize_detail, not_found_response, paginate, rails_app, rails_env_name, registered_tools, reset_all_caches!, reset_cache!, session_from, session_params, session_queries, session_record, session_reset!, static_tier_banner, static_tier_refusal, text_response, touch_session, unavailable_note, with_session, with_session_for

Methods included from SectionFetch

#fetch_section, usable?

Class Method Details

.call(server_context: nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rails_ai_context/tools/get_autoload.rb', line 24

def self.call(server_context: nil)
  fetch_section(:autoload, subject: "Autoload introspection") do |autoload|
    lines = [ "# Autoloading" ]
    lines << ""
    lines << "- **Mode:** #{autoload[:mode]}"
    lines << "- **Eager load (this env):** #{autoload[:eager_load]}"

    loaders = autoload[:autoloaders] || []
    if loaders.any?
      lines << "" << "## Autoloaders"
      loaders.each do |l|
        lines << "- **#{l[:name]}**#{l[:tag] ? " (tag: #{l[:tag]})" : ""}"
        lines << "  - [error: #{l[:error]}]" if l[:error]
        lines << "  - collapsed: #{l[:collapsed].join(', ')}" if l[:collapsed]&.any?
        lines << "  - ignored: #{l[:ignored].join(', ')}" if l[:ignored]&.any?
      end
    end

    render_paths(lines, "Autoload paths", autoload[:autoload_paths])
    render_paths(lines, "Autoload-once paths", autoload[:autoload_once_paths])
    render_paths(lines, "Eager-load paths", autoload[:eager_load_paths])

    inflections = autoload[:custom_inflections] || []
    if inflections.any?
      lines << "" << "## Custom Inflections"
      inflections.each { |i| lines << "- `#{i[:rule]}` (#{i[:file]})" }
    end

    text_response(lines.join("\n"))
  end
end