Class: CleoQualityReview::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/formatter.rb

Overview

Formats quality review results using an LLM with format-specific prompts

Constant Summary collapse

CONFIGURATION_FORMAT =

Format name of the shared configuration prompt applied to every run

"configuration"

Instance Method Summary collapse

Constructor Details

#initialize(run:, command_runner:, llm_config: LlmConfig.new, llm_client: nil) ⇒ Formatter

Returns a new instance of Formatter.

Parameters:

  • run (Run)

    the quality review run to format

  • command_runner (CommandRunner)

    for executing shell commands

  • llm_config (LlmConfig) (defaults to: LlmConfig.new)

    LLM provider configuration

  • llm_client (LlmClient, nil) (defaults to: nil)

    optional pre-configured client



22
23
24
25
26
27
# File 'lib/cleo_quality_review/formatter.rb', line 22

def initialize(run:, command_runner:, llm_config: LlmConfig.new, llm_client: nil)
  @run = run
  @command_runner = command_runner
  @llm_config = llm_config
  @llm_client = llm_client
end

Instance Method Details

#formatString

Format the run by generating an LLM review. Returns an empty string without contacting the LLM when there are no files to review.

Returns:

  • (String)

    formatted review text, or an empty string when there is nothing to review



34
35
36
37
38
# File 'lib/cleo_quality_review/formatter.rb', line 34

def format
  return "" unless run.reviewable?

  llm_client.generate_review(prompt, instructions: configuration_prompt)
end