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'
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
32 33 34 35 |
# File 'lib/skill_bench/execution/context_hydrator.rb', line 32 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.
23 24 25 |
# File 'lib/skill_bench/execution/context_hydrator.rb', line 23 def self.call(params) new(**params).call end |
Instance Method Details
#call ⇒ Hash
Performs the hydration process.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/skill_bench/execution/context_hydrator.rb', line 40 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) return missing_path_result unless validate_total_size?(context_files) 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 |