Class: RailsAiContext::Tools::GetEnvConfig
- Defined in:
- lib/rails_ai_context/tools/get_env_config.rb
Constant Summary
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
Class Method Details
.call(environment: nil, offset: 0, limit: nil, server_context: nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rails_ai_context/tools/get_env_config.rb', line 38 def self.call(environment: nil, offset: 0, limit: nil, server_context: nil) fetch_section(:env_config, subject: "Environment config introspection") do |envs| list = envs[:environments] || [] if environment names = list.map { |e| e[:name] } match = find_closest_match(environment, names) return not_found_response("Environment", environment, names, recovery_tool: "omit `environment` for all environments") unless match list = list.select { |e| e[:name] == match } end lines = [ "# Environments" ] lines << "" lines << "_Current: **#{envs[:current]}** - #{count_phrase(envs[:count], "environment file")} under config/environments/_" if list.any? list.each { |entry| render_environment(lines, entry, offset: offset, limit: limit) } else # A named environment that misses returns not_found_response above, # so reaching here always means the app has no environment files at # all - never a filter that matched nothing. lines << "" << "_No environment files found._" end text_response(lines.join("\n")) end end |