Class: Ace::PromptPrep::Atoms::TaskPathResolver
- Inherits:
-
Object
- Object
- Ace::PromptPrep::Atoms::TaskPathResolver
- Defined in:
- lib/ace/prompt_prep/atoms/task_path_resolver.rb
Overview
Resolves task directory path from task ID and extracts task IDs from branch names Delegates to ace-task for task resolution to avoid duplicating logic
Pure functions only - git I/O is handled by Molecules::GitBranchReader
Class Method Summary collapse
-
.extract_from_branch(branch_name, patterns: nil) ⇒ String|nil
Extract task ID from branch name using configurable patterns Default pattern matches: 117-feature → “117” 121.01-archive → “121.01” Does not match: main → nil feature-123 → nil (number not at start).
-
.resolve(task_id) ⇒ Hash
Find task directory by ID using ace-task API.
Class Method Details
.extract_from_branch(branch_name, patterns: nil) ⇒ String|nil
Extract task ID from branch name using configurable patterns Default pattern matches:
117-feature → "117"
121.01-archive → "121.01"
Does not match:
main → nil
feature-123 → nil (number not at start)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ace/prompt_prep/atoms/task_path_resolver.rb', line 61 def self.extract_from_branch(branch_name, patterns: nil) return nil if branch_name.nil? || branch_name.empty? # Get patterns from config or use default patterns ||= Ace::PromptPrep.config.dig("task", "branch_patterns") patterns ||= ['^(\d+(?:\.\d+)?)-'] patterns.each do |pattern| match = branch_name.match(Regexp.new(pattern)) return match[1] if match && match[1] end nil end |
.resolve(task_id) ⇒ Hash
Find task directory by ID using ace-task API
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ace/prompt_prep/atoms/task_path_resolver.rb', line 17 def self.resolve(task_id) # Use ace-task's TaskManager to resolve task manager = Ace::Task::Organisms::TaskManager.new task = manager.show(task_id) unless task return { path: nil, prompts_path: nil, found: false, error: "Task not found: #{task_id}" } end # Extract task directory from task file path task_dir = task.path prompts_dir = File.join(task_dir, "prompts") { path: task_dir, prompts_path: prompts_dir, found: true, error: nil } rescue => e { path: nil, prompts_path: nil, found: false, error: "Error resolving task path: #{e.}" } end |