Class AiMerge

java.lang.Object
io.github.jbastgen.stemma.app.ai.AiMerge

public final class AiMerge extends Object
Resolving the conflicts of a file with the AI (feature 6): the prompt with the three versions of every open conflict and a few lines around it, the strict reading of the answer, and the safety checks a proposal must pass.
  • Field Details

  • Method Details

    • buildPrompt

      public static String buildPrompt(String template, String path, String ours, String theirs, MergeSession session)
      Fills the template: {path}, {ours}, {theirs} and {conflicts}. Each open conflict is a block ### CONFLICT n with the lines before it, and the BASE, OURS and THEIRS lines.
    • parse

      public static AiMerge.Outcome parse(String answer, String path, List<Integer> open)
      Reads ### CONFLICT n (high|medium|low) blocks. Only conflicts in open count; a proposal with conflict markers, or one for a JSON file that is not valid JSON once the file is put together, stays out. Everything else is a proposal.
      Parameters:
      path - the file, for the plausibility check
      open - the numbers (0-based) of the conflicts that were sent
    • plausible

      public static String plausible(String path, String text)
      Whether a whole file is plausible for its type; only JSON can be checked here, everything else is accepted.