Class: Aidp::Providers::Kilocode
- Includes:
- DebugMixin
- Defined in:
- lib/aidp/providers/kilocode.rb
Constant Summary collapse
- MODEL_PATTERN =
Model name pattern for OpenAI models (since Kilocode uses OpenAI)
/^gpt-[\d.o-]+(?:-turbo)?(?:-mini)?$/i
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::TIER_TIMEOUT_MULTIPLIERS, 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
Instance Attribute Summary
Attributes inherited from Base
#activity_state, #last_activity_time, #model, #start_time, #step_name, #stuck_timeout
Class Method Summary collapse
- .available? ⇒ Boolean
-
.discover_models ⇒ Array<Hash>
Discover available models from registry.
-
.firewall_requirements ⇒ Object
Get firewall requirements for Kilocode provider.
-
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family.
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?, #configure, discover_models_from_registry, #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, included, #message_display_prompt
Constructor Details
This class inherits a constructor from Aidp::Providers::Base
Class Method Details
.available? ⇒ Boolean
16 17 18 |
# File 'lib/aidp/providers/kilocode.rb', line 16 def self.available? !!Aidp::Util.which("kilocode") end |
.discover_models ⇒ Array<Hash>
Discover available models from registry
Note: Kilocode CLI doesn’t have a standard model listing command Returns registry-based models that match OpenAI patterns
34 35 36 37 38 |
# File 'lib/aidp/providers/kilocode.rb', line 34 def self.discover_models return [] unless available? discover_models_from_registry(MODEL_PATTERN, "kilocode") end |
.firewall_requirements ⇒ Object
Get firewall requirements for Kilocode provider
41 42 43 44 45 46 47 48 49 |
# File 'lib/aidp/providers/kilocode.rb', line 41 def self.firewall_requirements { domains: [ "kilocode.ai", "api.kilocode.ai" ], ip_ranges: [] } end |
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family
24 25 26 |
# File 'lib/aidp/providers/kilocode.rb', line 24 def self.supports_model_family?(family_name) MODEL_PATTERN.match?(family_name) end |
Instance Method Details
#display_name ⇒ Object
55 56 57 |
# File 'lib/aidp/providers/kilocode.rb', line 55 def display_name "Kilocode" end |
#name ⇒ Object
51 52 53 |
# File 'lib/aidp/providers/kilocode.rb', line 51 def name "kilocode" end |
#send_message(prompt:, session: nil, options: {}) ⇒ Object
59 60 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 97 98 99 100 101 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 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/aidp/providers/kilocode.rb', line 59 def (prompt:, session: nil, options: {}) raise "kilocode not available" unless self.class.available? # Smart timeout calculation timeout_seconds = calculate_timeout debug_provider("kilocode", "Starting execution", {timeout: timeout_seconds}) debug_log("📝 Sending prompt to kilocode (length: #{prompt.length})", level: :info) # Check if prompt is too large and warn if prompt.length > 3000 debug_log("⚠️ Large prompt detected (#{prompt.length} chars) - this may cause rate limiting", level: :warn) end # Set up activity monitoring setup_activity_monitoring("kilocode", method(:activity_callback)) record_activity("Starting kilocode execution") # Create a spinner for activity display spinner = TTY::Spinner.new("[:spinner] :title", format: :dots, hide_cursor: true) spinner.auto_spin activity_display_thread = Thread.new do start_time = Time.now loop do sleep 0.5 # Update every 500ms to reduce spam elapsed = Time.now - start_time # Break if we've been running too long or state changed break if elapsed > timeout_seconds || @activity_state == :completed || @activity_state == :failed update_spinner_status(spinner, elapsed, "🔄 kilocode") end end begin # Build kilocode command arguments args = ["--auto"] # Add model if specified model = ENV["KILOCODE_MODEL"] if model args.concat(["-m", model]) end # Add workspace detection if needed if Dir.exist?(".git") && ENV["KILOCODE_WORKSPACE"] args.concat(["--workspace", ENV["KILOCODE_WORKSPACE"]]) end # Set authentication via environment variable env_vars = {} if ENV["KILOCODE_TOKEN"] env_vars["KILOCODE_TOKEN"] = ENV["KILOCODE_TOKEN"] end # Use debug_execute_command for better debugging result = debug_execute_command("kilocode", args: args, input: prompt, timeout: timeout_seconds, env: env_vars) # Log the results debug_command("kilocode", args: args, input: prompt, output: result.out, error: result.err, exit_code: result.exit_status) if result.exit_status == 0 spinner.success("✓") mark_completed result.out else spinner.error("✗") mark_failed("kilocode failed with exit code #{result.exit_status}") debug_error(StandardError.new("kilocode failed"), {exit_code: result.exit_status, stderr: result.err}) raise "kilocode failed with exit code #{result.exit_status}: #{result.err}" end rescue => e spinner&.error("✗") mark_failed("kilocode execution failed: #{e.}") debug_error(e, {provider: "kilocode", prompt_length: prompt.length}) raise ensure cleanup_activity_display(activity_display_thread, spinner) end end |