Class: Ace::Review::Models::ReviewOptions
- Inherits:
-
Object
- Object
- Ace::Review::Models::ReviewOptions
- Defined in:
- lib/ace/review/models/review_options.rb
Overview
Options for code review execution
Instance Attribute Summary collapse
-
#add_focus ⇒ Object
Returns the value of attribute add_focus.
-
#auto_execute ⇒ Object
Returns the value of attribute auto_execute.
-
#context ⇒ Object
Returns the value of attribute context.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#feedback_model ⇒ Object
Returns the value of attribute feedback_model.
-
#gh_timeout ⇒ Object
Returns the value of attribute gh_timeout.
-
#help ⇒ Object
Returns the value of attribute help.
-
#list_presets ⇒ Object
Returns the value of attribute list_presets.
-
#list_prompts ⇒ Object
Returns the value of attribute list_prompts.
-
#model ⇒ Object
Returns the value of attribute model.
-
#models ⇒ Object
Returns the value of attribute models.
-
#no_feedback ⇒ Object
Returns the value of attribute no_feedback.
-
#output ⇒ Object
Returns the value of attribute output.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#post_comment ⇒ Object
Returns the value of attribute post_comment.
-
#pr ⇒ Object
Returns the value of attribute pr.
-
#pr_comment_data ⇒ Object
Returns the value of attribute pr_comment_data.
-
#pr_comments ⇒ Object
Returns the value of attribute pr_comments.
-
#pr_metadata ⇒ Object
Returns the value of attribute pr_metadata.
-
#preset ⇒ Object
Returns the value of attribute preset.
-
#prompt_base ⇒ Object
Returns the value of attribute prompt_base.
-
#prompt_focus ⇒ Object
Returns the value of attribute prompt_focus.
-
#prompt_format ⇒ Object
Returns the value of attribute prompt_format.
-
#prompt_guidelines ⇒ Object
Returns the value of attribute prompt_guidelines.
-
#save_session ⇒ Object
Returns the value of attribute save_session.
-
#session_dir ⇒ Object
Returns the value of attribute session_dir.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#effective_model(config_model = nil) ⇒ Object
Get effective model (single model) Priority: model scalar > first model in models array > config_model > default.
-
#effective_models(config_models = nil) ⇒ Object
Get effective models array Returns array of models, handling both single model and multi-model cases Priority: models array > model scalar > config_models > default.
-
#feedback_enabled? ⇒ Boolean
Check if feedback extraction is enabled.
-
#include_pr_comments? ⇒ Boolean
Check if PR comments should be included as feedback source Enabled by default for PR reviews, can be disabled with –no-pr-comments.
-
#initialize(hash = {}) ⇒ ReviewOptions
constructor
A new instance of ReviewOptions.
-
#list_command? ⇒ Boolean
Check if this is a list command.
-
#merge_config(config) ⇒ Object
Merge with config values.
-
#pr_review? ⇒ Boolean
Check if this is a PR review.
-
#save_output? ⇒ Boolean
Check if output should be saved.
-
#should_post_comment? ⇒ Boolean
Check if comment posting should be triggered (includes dry-run preview).
-
#system_prompt_composition ⇒ Object
Build system prompt composition hash.
-
#to_h ⇒ Object
Convert back to hash for compatibility.
Constructor Details
#initialize(hash = {}) ⇒ ReviewOptions
Returns a new instance of ReviewOptions.
17 18 19 20 21 22 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 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ace/review/models/review_options.rb', line 17 def initialize(hash = {}) # Core options @preset = hash[:preset] || Ace::Review.get("defaults", "preset") @output_dir = hash[:output_dir] @output = hash[:output] # Context and subject @context = hash[:context] @subject = hash[:subject] # Prompt composition overrides @prompt_base = hash[:prompt_base] @prompt_format = hash[:prompt_format] @prompt_focus = hash[:prompt_focus] @add_focus = hash[:add_focus] @prompt_guidelines = hash[:prompt_guidelines] # Execution options @model = hash[:model] @models = hash[:models] @dry_run = hash[:dry_run] || false @verbose = hash[:verbose] || false @auto_execute = if @dry_run false elsif hash[:auto_execute].nil? Ace::Review.get("defaults", "auto_execute") || false else hash[:auto_execute] end # Session options @save_session = hash.fetch(:save_session, true) @session_dir = hash[:session_dir] # PR review options @pr = hash[:pr] @post_comment = hash[:post_comment] || false @pr_metadata = hash[:pr_metadata] @gh_timeout = hash[:gh_timeout] # PR comment options @pr_comments = hash[:pr_comments] # nil = use default, true/false = explicit @pr_comment_data = nil # Populated during execution # Feedback extraction options @no_feedback = hash[:no_feedback] || false @feedback_model = hash[:feedback_model] # List commands @list_presets = hash[:list_presets] || false @list_prompts = hash[:list_prompts] || false @help = hash[:help] || false end |
Instance Attribute Details
#add_focus ⇒ Object
Returns the value of attribute add_focus.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def add_focus @add_focus end |
#auto_execute ⇒ Object
Returns the value of attribute auto_execute.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def auto_execute @auto_execute end |
#context ⇒ Object
Returns the value of attribute context.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def context @context end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def dry_run @dry_run end |
#feedback_model ⇒ Object
Returns the value of attribute feedback_model.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def feedback_model @feedback_model end |
#gh_timeout ⇒ Object
Returns the value of attribute gh_timeout.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def gh_timeout @gh_timeout end |
#help ⇒ Object
Returns the value of attribute help.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def help @help end |
#list_presets ⇒ Object
Returns the value of attribute list_presets.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def list_presets @list_presets end |
#list_prompts ⇒ Object
Returns the value of attribute list_prompts.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def list_prompts @list_prompts end |
#model ⇒ Object
Returns the value of attribute model.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def model @model end |
#models ⇒ Object
Returns the value of attribute models.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def models @models end |
#no_feedback ⇒ Object
Returns the value of attribute no_feedback.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def no_feedback @no_feedback end |
#output ⇒ Object
Returns the value of attribute output.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def output @output end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def output_dir @output_dir end |
#post_comment ⇒ Object
Returns the value of attribute post_comment.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def post_comment @post_comment end |
#pr ⇒ Object
Returns the value of attribute pr.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def pr @pr end |
#pr_comment_data ⇒ Object
Returns the value of attribute pr_comment_data.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def pr_comment_data @pr_comment_data end |
#pr_comments ⇒ Object
Returns the value of attribute pr_comments.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def pr_comments @pr_comments end |
#pr_metadata ⇒ Object
Returns the value of attribute pr_metadata.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def @pr_metadata end |
#preset ⇒ Object
Returns the value of attribute preset.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def preset @preset end |
#prompt_base ⇒ Object
Returns the value of attribute prompt_base.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def prompt_base @prompt_base end |
#prompt_focus ⇒ Object
Returns the value of attribute prompt_focus.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def prompt_focus @prompt_focus end |
#prompt_format ⇒ Object
Returns the value of attribute prompt_format.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def prompt_format @prompt_format end |
#prompt_guidelines ⇒ Object
Returns the value of attribute prompt_guidelines.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def prompt_guidelines @prompt_guidelines end |
#save_session ⇒ Object
Returns the value of attribute save_session.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def save_session @save_session end |
#session_dir ⇒ Object
Returns the value of attribute session_dir.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def session_dir @session_dir end |
#subject ⇒ Object
Returns the value of attribute subject.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def subject @subject end |
#verbose ⇒ Object
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/ace/review/models/review_options.rb', line 8 def verbose @verbose end |
Instance Method Details
#effective_model(config_model = nil) ⇒ Object
Get effective model (single model) Priority: model scalar > first model in models array > config_model > default
120 121 122 123 124 |
# File 'lib/ace/review/models/review_options.rb', line 120 def effective_model(config_model = nil) return model if model return models.first if models&.any? config_model || "google:gemini-2.5-flash" end |
#effective_models(config_models = nil) ⇒ Object
Get effective models array Returns array of models, handling both single model and multi-model cases Priority: models array > model scalar > config_models > default
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/ace/review/models/review_options.rb', line 129 def effective_models(config_models = nil) # If models array is set (from CLI), use it return models if models&.any? # If model scalar is set, wrap in array return [model] if model # If config provides models array, use it if config_models.is_a?(Array) && config_models.any? return config_models end # If config provides single model, wrap in array if config_models.is_a?(String) && !config_models.empty? return [config_models] end # Default to single model ["google:gemini-2.5-flash"] end |
#feedback_enabled? ⇒ Boolean
Check if feedback extraction is enabled
114 115 116 |
# File 'lib/ace/review/models/review_options.rb', line 114 def feedback_enabled? !@no_feedback end |
#include_pr_comments? ⇒ Boolean
Check if PR comments should be included as feedback source Enabled by default for PR reviews, can be disabled with –no-pr-comments
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ace/review/models/review_options.rb', line 97 def include_pr_comments? return false unless pr_review? # Explicit flag overrides everything return pr_comments unless pr_comments.nil? # Check config default (defaults to true for PR reviews) config_default = Ace::Review.get("defaults", "pr_comments") config_default.nil? || config_default end |
#list_command? ⇒ Boolean
Check if this is a list command
81 82 83 |
# File 'lib/ace/review/models/review_options.rb', line 81 def list_command? list_presets || list_prompts || help end |
#merge_config(config) ⇒ Object
Merge with config values
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/ace/review/models/review_options.rb', line 151 def merge_config(config) return if config.nil? # Merge system prompt configuration if not overridden @prompt_base ||= config.dig("system_prompt", "base") @prompt_format ||= config.dig("system_prompt", "format") # Handle focus modules if @add_focus && config.dig("system_prompt", "focus") existing_focus = config.dig("system_prompt", "focus") || [] additional_focus = @add_focus.split(",").map(&:strip) @prompt_focus = (existing_focus + additional_focus).uniq.join(",") elsif !@prompt_focus && config.dig("system_prompt", "focus") @prompt_focus = Array(config.dig("system_prompt", "focus")).join(",") end @prompt_guidelines ||= Array(config.dig("system_prompt", "guidelines")).join(",") if config.dig("system_prompt", "guidelines") # Merge other config values @context ||= config["context"] @subject ||= config["subject"] # Handle models from config # CLI models override preset models unless @models&.any? if config["models"].is_a?(Array) && config["models"].any? @models = config["models"] elsif config["model"] @model ||= config["model"] end end @gh_timeout ||= config["gh_timeout"] self end |
#pr_review? ⇒ Boolean
Check if this is a PR review
86 87 88 |
# File 'lib/ace/review/models/review_options.rb', line 86 def pr_review? !pr.nil? && !pr.to_s.strip.empty? end |
#save_output? ⇒ Boolean
Check if output should be saved
109 110 111 |
# File 'lib/ace/review/models/review_options.rb', line 109 def save_output? !dry_run && save_session end |
#should_post_comment? ⇒ Boolean
Check if comment posting should be triggered (includes dry-run preview)
91 92 93 |
# File 'lib/ace/review/models/review_options.rb', line 91 def should_post_comment? pr_review? && post_comment end |
#system_prompt_composition ⇒ Object
Build system prompt composition hash
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/ace/review/models/review_options.rb', line 189 def system_prompt_composition composition = {} composition["base"] = prompt_base if prompt_base composition["format"] = prompt_format if prompt_format if prompt_focus composition["focus"] = prompt_focus.split(",").map(&:strip) end if prompt_guidelines composition["guidelines"] = prompt_guidelines.split(",").map(&:strip) end composition.empty? ? nil : composition end |
#to_h ⇒ Object
Convert back to hash for compatibility
72 73 74 75 76 77 78 |
# File 'lib/ace/review/models/review_options.rb', line 72 def to_h instance_variables.each_with_object({}) do |var, hash| key = var.to_s.delete_prefix("@").to_sym value = instance_variable_get(var) hash[key] = value unless value.nil? end end |