Class: SkillBench::Execution::SourcePathResolver
- Inherits:
-
Object
- Object
- SkillBench::Execution::SourcePathResolver
- Defined in:
- lib/skill_bench/execution/source_path_resolver.rb
Overview
Resolves the source skill or workflow path for a given evaluation target.
Class Method Summary collapse
-
.call(eval_folder_path:, skill_path: nil, skill_sources: {}) ⇒ String?
Resolves the source path using either an explicit override or the eval directory convention.
-
.extract_skill_name(segments) ⇒ String?
Extracts the skill name from the eval path segments.
-
.find_skill_in_source(source_path, skill_name) ⇒ String?
Finds a skill directory within a source path by name.
Class Method Details
.call(eval_folder_path:, skill_path: nil, skill_sources: {}) ⇒ String?
Resolves the source path using either an explicit override or the eval directory convention.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/skill_bench/execution/source_path_resolver.rb', line 26 def self.call(eval_folder_path:, skill_path: nil, skill_sources: {}) return skill_path if skill_path && !skill_path.empty? segments = Pathname.new(eval_folder_path.to_s).each_filename.to_a local = resolve_skills_path(segments) || resolve_workflows_path(segments) unless local.nil? || skill_sources.empty? skill_name = extract_skill_name(segments) return local unless skill_name return local if skill_exists_at?(local) skill_sources.each_value do |source_path| candidate = find_skill_in_source(source_path, skill_name) return candidate if candidate end end local end |
.extract_skill_name(segments) ⇒ String?
Extracts the skill name from the eval path segments.
51 52 53 54 55 56 57 58 59 |
# File 'lib/skill_bench/execution/source_path_resolver.rb', line 51 def self.extract_skill_name(segments) index = segments.rindex('skills') return nil unless index remaining = segments[(index + 1)..] return nil if remaining.empty? remaining[0] end |
.find_skill_in_source(source_path, skill_name) ⇒ String?
Finds a skill directory within a source path by name.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/skill_bench/execution/source_path_resolver.rb', line 66 def self.find_skill_in_source(source_path, skill_name) return nil unless source_path && Dir.exist?(source_path) Dir.glob(File.join(source_path, '*')).each do |entry| next unless Dir.exist?(entry) candidate = File.join(entry, skill_name) return candidate if Dir.exist?(candidate) && File.exist?(File.join(candidate, 'SKILL.md')) end nil end |