Class: Aidp::Providers::Gemini

Inherits:
Base
  • Object
show all
Includes:
DebugMixin
Defined in:
lib/aidp/providers/gemini.rb

Constant Summary

Constants included from DebugMixin

DebugMixin::DEBUG_BASIC, DebugMixin::DEBUG_OFF, DebugMixin::DEBUG_VERBOSE

Constants inherited from Base

Base::ACTIVITY_STATES, Base::DEFAULT_STUCK_TIMEOUT, Base::TIMEOUT_ARCHITECTURE_ANALYSIS, Base::TIMEOUT_DEFAULT, Base::TIMEOUT_DOCUMENTATION_ANALYSIS, Base::TIMEOUT_FUNCTIONALITY_ANALYSIS, Base::TIMEOUT_IMPLEMENTATION, Base::TIMEOUT_QUICK_MODE, Base::TIMEOUT_REFACTORING_RECOMMENDATIONS, Base::TIMEOUT_REPOSITORY_ANALYSIS, Base::TIMEOUT_STATIC_ANALYSIS, Base::TIMEOUT_TEST_ANALYSIS

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP

Instance Attribute Summary

Attributes inherited from Base

#activity_state, #last_activity_time, #start_time, #step_name, #stuck_timeout

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DebugMixin

#debug_basic?, #debug_command, #debug_enabled?, #debug_error, #debug_execute_command, #debug_level, #debug_log, #debug_logger, #debug_provider, #debug_step, #debug_timing, #debug_verbose?, included, shared_logger

Methods inherited from Base

#activity_summary, #available?, #execution_time, #fetch_mcp_servers, #harness_config, #harness_health_status, #harness_healthy?, #harness_metrics, #harness_mode?, #initialize, #mark_completed, #mark_failed, #record_activity, #record_harness_request, #send_with_harness, #set_harness_context, #set_job_context, #setup_activity_monitoring, #stuck?, #supports_activity_monitoring?, #supports_mcp?, #time_since_last_activity, #update_activity_state

Methods included from Adapter

#available?, #capabilities, #classify_error, #dangerous_mode=, #dangerous_mode_enabled?, #dangerous_mode_flags, #error_metadata, #error_patterns, #fetch_mcp_servers, #health_status, #logging_metadata, #redact_secrets, #retryable_error?, #supports_dangerous_mode?, #supports_mcp?, #validate_config

Methods included from MessageDisplay

#display_message, #in_test_environment?, included, #message_display_prompt, #suppress_display_message?

Constructor Details

This class inherits a constructor from Aidp::Providers::Base

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/aidp/providers/gemini.rb', line 11

def self.available?
  !!Aidp::Util.which("gemini")
end

Instance Method Details

#display_nameObject



19
20
21
# File 'lib/aidp/providers/gemini.rb', line 19

def display_name
  "Google Gemini"
end

#nameObject



15
16
17
# File 'lib/aidp/providers/gemini.rb', line 15

def name
  "gemini"
end

#send_message(prompt:, session: nil) ⇒ Object



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
49
50
51
52
53
54
55
56
# File 'lib/aidp/providers/gemini.rb', line 23

def send_message(prompt:, session: nil)
  raise "gemini CLI not available" unless self.class.available?

  # Smart timeout calculation
  timeout_seconds = calculate_timeout

  debug_provider("gemini", "Starting execution", {timeout: timeout_seconds})
  debug_log("📝 Sending prompt to gemini...", level: :info)

  # Check if streaming mode is enabled
  streaming_enabled = ENV["AIDP_STREAMING"] == "1" || ENV["DEBUG"] == "1"
  if streaming_enabled
    display_message("📺 Display streaming enabled - output buffering reduced (gemini CLI does not support true streaming)", type: :info)
  end

  begin
    command_args = ["--prompt", prompt]
    # Use debug_execute_command with streaming support
    result = debug_execute_command("gemini", args: command_args, timeout: timeout_seconds, streaming: streaming_enabled)

    # Log the results
    debug_command("gemini", args: command_args, input: nil, output: result.out, error: result.err, exit_code: result.exit_status)

    if result.exit_status == 0
      result.out
    else
      debug_error(StandardError.new("gemini failed"), {exit_code: result.exit_status, stderr: result.err})
      raise "gemini failed with exit code #{result.exit_status}: #{result.err}"
    end
  rescue => e
    debug_error(e, {provider: "gemini", prompt_length: prompt.length})
    raise
  end
end