Class: Agentic::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/agentic/cli.rb,
lib/agentic/cli/agent.rb,
lib/agentic/cli/config.rb,
lib/agentic/cli/capabilities.rb,
lib/agentic/cli/execution_observer.rb

Overview

Command Line Interface for Agentic

Defined Under Namespace

Classes: Agent, AgentCommands, Capabilities, Config, ConfigCommands, ExecutionObserver

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Global logging configuration based on options



20
21
22
23
# File 'lib/agentic/cli.rb', line 20

def initialize(*args)
  super
  configure_logging
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/agentic/cli.rb', line 15

def self.exit_on_failure?
  true
end

Instance Method Details

#executeObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/agentic/cli.rb', line 120

def execute
  check_api_token!

  # Load the plan
  plan_data = load_plan_data

  unless plan_data
    raise Thor::Error, "No plan provided. Use --plan FILE or --from-stdin"
  end

  # Initialize task instances from the plan
  tasks = initialize_tasks(plan_data)

  # Execute the tasks
  execute_tasks(tasks)
end

#plan(goal) ⇒ Object



61
62
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
92
93
94
95
96
# File 'lib/agentic/cli.rb', line 61

def plan(goal)
  check_api_token!

  say UI.colorize("Creating plan for goal: #{goal}", :green) unless options[:quiet]

  # Configure the LLM
  config = LlmConfig.new
  config.model = options[:model] if options[:model]

  # Create and run the task planner with spinner
  execution_plan = UI.with_spinner("Planning tasks for goal", quiet: options[:quiet]) do
    planner = TaskPlanner.new(goal, config)
    planner.plan
  end

  # Show the plan to the user
  unless options[:quiet]
    puts format_plan(execution_plan)
    puts
  end

  # Ask user if they want to adjust the plan
  if !options[:quiet] && !options[:no_interactive] && ask_user_for_plan_adjustment
    execution_plan = adjust_plan_with_user_input(execution_plan, config)
  end

  # Output the plan based on format option (only if saving to file or different format)
  if options[:save] || options[:output] != "text"
    output_plan(execution_plan, options)
  end

  # Ask user if they want to execute the plan
  if options[:execute] || (should_ask_for_execution? && ask_user_for_execution)
    execute_plan_immediately(execution_plan)
  end
end

#versionObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/agentic/cli.rb', line 26

def version
  version_box = UI.box(
    "Agentic",
    [
      "Version: #{UI.colorize(Agentic::VERSION, :green)}",
      "Ruby: #{UI.colorize(RUBY_VERSION, :blue)}",
      "Platform: #{UI.colorize(RUBY_PLATFORM, :yellow)}"
    ].join("\n"),
    padding: [1, 2, 1, 2],
    style: {border: {fg: :blue}}
  )
  puts version_box
end