Class: EnhanceSwarm::TaskIntegration
- Inherits:
-
Object
- Object
- EnhanceSwarm::TaskIntegration
- Defined in:
- lib/enhance_swarm/task_integration.rb
Instance Method Summary collapse
- #create_task(title, description = nil, priority = 'medium') ⇒ Object
- #get_active_tasks ⇒ Object
- #get_kanban_data ⇒ Object
- #get_task_folders ⇒ Object
-
#initialize ⇒ TaskIntegration
constructor
A new instance of TaskIntegration.
- #list_tasks ⇒ Object
- #move_task(task_id, status) ⇒ Object
- #setup_task_management ⇒ Object
- #swarm_tasks_available? ⇒ Boolean
Constructor Details
#initialize ⇒ TaskIntegration
7 8 9 |
# File 'lib/enhance_swarm/task_integration.rb', line 7 def initialize @tasks_available = check_swarm_tasks_availability end |
Instance Method Details
#create_task(title, description = nil, priority = 'medium') ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/enhance_swarm/task_integration.rb', line 46 def create_task(title, description = nil, priority = 'medium') return false unless @tasks_available begin cmd = "bundle exec swarm-tasks create \"#{title}\"" cmd += " --description=\"#{description}\"" if description cmd += " --priority=#{priority}" cmd += " 2>/dev/null" result = `#{cmd}` $?.success? rescue StandardError => e Logger.error("Failed to create task: #{e.message}") false end end |
#get_active_tasks ⇒ Object
29 30 31 32 |
# File 'lib/enhance_swarm/task_integration.rb', line 29 def get_active_tasks tasks = list_tasks tasks.select { |task| task['status'] == 'active' || task['status'] == 'in_progress' } end |
#get_kanban_data ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/enhance_swarm/task_integration.rb', line 93 def get_kanban_data { swarm_tasks_available: @tasks_available, tasks: list_tasks, folders: get_task_folders, active_tasks: get_active_tasks } end |
#get_task_folders ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/enhance_swarm/task_integration.rb', line 63 def get_task_folders return [] unless @tasks_available begin # Look for tasks directory structure tasks_dir = File.join(Dir.pwd, 'tasks') return [] unless Dir.exist?(tasks_dir) folders = [] Dir.glob(File.join(tasks_dir, '*')).each do |path| next unless File.directory?(path) folder_name = File.basename(path) task_files = Dir.glob(File.join(path, '*.md')).length folders << { name: folder_name, path: path, task_count: task_files, status: folder_name # todo, in_progress, done, etc. } end folders rescue StandardError => e Logger.warn("Failed to analyze task folders: #{e.message}") [] end end |
#list_tasks ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/enhance_swarm/task_integration.rb', line 15 def list_tasks return [] unless @tasks_available begin output = `bundle exec swarm-tasks list --format=json 2>/dev/null` return [] if output.empty? JSON.parse(output) rescue JSON::ParserError, StandardError => e Logger.warn("Failed to parse swarm-tasks output: #{e.message}") [] end end |
#move_task(task_id, status) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/enhance_swarm/task_integration.rb', line 34 def move_task(task_id, status) return false unless @tasks_available begin result = `bundle exec swarm-tasks move #{task_id} #{status} 2>/dev/null` $?.success? rescue StandardError => e Logger.error("Failed to move task #{task_id} to #{status}: #{e.message}") false end end |
#setup_task_management ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/enhance_swarm/task_integration.rb', line 102 def setup_task_management return false unless @tasks_available begin # Initialize swarm-tasks if not already done unless Dir.exist?(File.join(Dir.pwd, 'tasks')) Logger.info("Initializing swarm-tasks for project") `bundle exec swarm-tasks init 2>/dev/null` end # Create default task categories if they don't exist default_folders = ['todo', 'in_progress', 'review', 'done'] tasks_dir = File.join(Dir.pwd, 'tasks') default_folders.each do |folder| folder_path = File.join(tasks_dir, folder) unless Dir.exist?(folder_path) FileUtils.mkdir_p(folder_path) Logger.info("Created task folder: #{folder}") end end true rescue StandardError => e Logger.error("Failed to setup task management: #{e.message}") false end end |
#swarm_tasks_available? ⇒ Boolean
11 12 13 |
# File 'lib/enhance_swarm/task_integration.rb', line 11 def swarm_tasks_available? @tasks_available end |