Class: Ace::Task::CLI::Commands::Plan

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/task/cli/commands/plan.rb

Overview

ace-support-cli Command class for ace-task plan

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.generator_classObject

Returns the value of attribute generator_class.



43
44
45
# File 'lib/ace/task/cli/commands/plan.rb', line 43

def generator_class
  @generator_class
end

Instance Method Details

#call(ref:, **options) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ace/task/cli/commands/plan.rb', line 46

def call(ref:, **options)
  task = resolve_task(ref)
  cache = Molecules::TaskPlanCache.new(task_id: task.id)
  config = Molecules::TaskConfigLoader.load

  plan_path = cache.resolve_latest_plan
  refresh = options[:refresh]

  unless refresh
    if plan_path && cache.fresh?(plan_path, task_file: task.file_path)
      output_plan(plan_path, options)
      return
    end
  end

  context_files = capture_context_files(task)
  model = options[:model] || default_model(config)
  generator = plan_generator(model, timeout: options[:timeout])
  content = generator.generate(
    task: task,
    context_files: context_files,
    cache_dir: cache.cache_dir
  )
  plan_path = cache.write_plan(
    content: content,
    model: model,
    task_file: task.file_path,
    context_files: context_files,
    prompt_files: generator.prompt_paths
  )

  output_plan(plan_path, options)
end