Module: RailVerdict::Repair::PromptRenderer

Defined in:
lib/rail_verdict/repair/prompt_renderer.rb

Class Method Summary collapse

Class Method Details

.render(packet_hash) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rail_verdict/repair/prompt_renderer.rb', line 6

def self.render(packet_hash)
  trusted = packet_hash["instructions"] || Constraints.instructions
  plan = packet_hash["verification_plan"] || {}
  untrusted = {
    "finding" => packet_hash.dig("target", "finding"),
    "evidence" => packet_hash["evidence"],
    "source_context" => packet_hash["source_context"],
    "diff_context" => packet_hash["diff_context"],
    "rails_context" => packet_hash["rails_context"]
  }
  <<~PROMPT
    TRUSTED_RAILVERDICT_INSTRUCTIONS:
    #{trusted.join("\n")}
    Verification required: #{plan.dig("required", 0, "display") || "bundle exec railverdict check"}

    UNTRUSTED_REPOSITORY_DATA:
    #{JSON.generate(untrusted)}
  PROMPT
end