Class: Clacky::Tools::ListTasks

Inherits:
Base
  • Object
show all
Defined in:
lib/clacky/tools/list_tasks.rb

Overview

Tool for listing task history (Time Machine feature)

Instance Method Summary collapse

Methods inherited from Base

#category, #description, #name, #parameters, #to_function_definition

Instance Method Details

#execute(agent:, limit: 10, **_args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/clacky/tools/list_tasks.rb', line 23

def execute(agent:, limit: 10, **_args)
  history = agent.get_task_history(limit: limit)
  
  if history.empty?
    return "No task history available."
  end

  lines = ["Task History:"]
  history.each do |task|
    indicator = case task[:status]
    when :current then ""
    when :past then " "
    when :future then ""
    end
    
    branch_indicator = task[:has_branches] ? "" : ""
    lines << "#{indicator}#{branch_indicator} Task #{task[:task_id]}: #{task[:summary]}"
  end

  lines.join("\n")
end

#format_call(limit: 10, **_args) ⇒ Object



45
46
47
# File 'lib/clacky/tools/list_tasks.rb', line 45

def format_call(limit: 10, **_args)
  "Listing task history (limit: #{limit})..."
end

#format_result(result) ⇒ Object



49
50
51
# File 'lib/clacky/tools/list_tasks.rb', line 49

def format_result(result)
  result
end