Class: RailsAiContext::Tools::GetContext
- Defined in:
- lib/rails_ai_context/tools/get_context.rb
Constant Summary collapse
- INCLUDE_MAP =
{ "stimulus" => -> { GetStimulus.call(detail: "standard") }, "turbo" => -> { GetTurboMap.call(detail: "standard") }, "services" => -> { GetServicePattern.call(detail: "standard") }, "jobs" => -> { GetJobPattern.call(detail: "standard") }, "conventions" => -> { GetConventions.call }, "helpers" => -> { GetHelperMethods.call(detail: "standard") }, "env" => -> { GetEnv.call(detail: "summary") }, "callbacks" => -> { GetCallbacks.call(detail: "standard") }, "tests" => -> { GetTestInfo.call(detail: "full") }, "config" => -> { GetConfig.call }, "gems" => -> { GetGems.call }, "security" => -> { SecurityScan.call(detail: "summary") } }.freeze
Constants inherited from BaseTool
BaseTool::SESSION_CONTEXT, BaseTool::SHARED_CACHE
Class Method Summary collapse
Methods inherited from BaseTool
abstract!, abstract?, cache_key, cached_context, config, extract_method_source_from_file, extract_method_source_from_string, find_closest_match, fuzzy_find_key, inherited, not_found_response, paginate, rails_app, registered_tools, reset_all_caches!, reset_cache!, session_queries, session_record, session_reset!, set_call_params, text_response
Class Method Details
.call(controller: nil, action: nil, model: nil, feature: nil, include: nil, server_context: nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rails_ai_context/tools/get_context.rb', line 39 def self.call(controller: nil, action: nil, model: nil, feature: nil, include: nil, server_context: nil) set_call_params(controller: controller, action: action, model: model, feature: feature) result = if controller && action controller_action_context(controller, action) elsif controller controller_context(controller) elsif model model_context(model) elsif feature feature_context(feature) else return text_response("Provide at least one of: controller, model, or feature.") end # Append additional context sections if include: is specified if include.is_a?(Array) && include.any? base_text = result.content.first[:text] extra = append_includes(include) return text_response(base_text + extra) end result end |