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, #dedupe_put_patch_routes, error_response, extract_method_source_from_file, extract_method_source_from_string, find_closest_match, fuzzy_find_key, inherited, introspection_warnings_note, 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 62 63 |
# 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) base_text = 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 base_text += append_includes(include) if include.is_a?(Array) && include.any? ctx = begin cached_context rescue StandardError nil end text_response(base_text, suffix: introspection_warnings_note(ctx)) end |