Class: SkillBench::Execution::ContextHydrator
- Inherits:
-
Object
- Object
- SkillBench::Execution::ContextHydrator
- Defined in:
- lib/skill_bench/execution/context_hydrator.rb
Overview
Responsible for loading source context files from a given path and wrapping them in XML tags for injection into the LLM system prompt.
Constant Summary collapse
- HYDRATION_FAILED =
Error message returned when context hydration fails.
'Failed to hydrate context from source path'- TEXT_EXTENSIONS =
File extensions considered for context hydration.
%w[.md .rb .json .yml .yaml .txt].freeze
- MAX_FILE_SIZE =
Maximum file size (in bytes) for files included in context hydration.
50_000
Class Method Summary collapse
-
.call(params) ⇒ Hash
Loads and formats source context files.
Instance Method Summary collapse
-
#call ⇒ Hash
Performs the hydration process.
- #initialize(source_path: nil, skill_path: nil, base_path: nil) ⇒ void constructor
Constructor Details
#initialize(source_path: nil, skill_path: nil, base_path: nil) ⇒ void
35 36 37 38 |
# File 'lib/skill_bench/execution/context_hydrator.rb', line 35 def initialize(source_path: nil, skill_path: nil, base_path: nil) @source_path = source_path || skill_path @base_path = base_path || Pathname.new(Dir.pwd) end |
Class Method Details
.call(params) ⇒ Hash
Loads and formats source context files.
26 27 28 |
# File 'lib/skill_bench/execution/context_hydrator.rb', line 26 def self.call(params) new(**params).call end |
Instance Method Details
#call ⇒ Hash
Performs the hydration process.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/skill_bench/execution/context_hydrator.rb', line 43 def call return missing_path_result unless @source_path full_path = @base_path.join(@source_path). = @base_path. return missing_path_result unless full_path.to_path.start_with?(.to_path) return missing_path_result unless full_path.exist? && full_path.directory? context_files = collect_context_files(full_path) xml_context = build_xml(context_files) { success: true, response: { context: xml_context } } rescue StandardError => e SkillBench::ErrorLogger.log_error(e, 'Hydration Error') { success: false, response: { error: { message: e. } } } end |