Class CommitSummary

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

public final class CommitSummary extends Object
The description of one or several commits: builds the prompt (from the editable template and the commit data) and reads the answer. The answer is asked for in a simple fixed shape (HEADLINE:, TYPE:, SUMMARY:, FILES:); an answer in another shape is still shown, as the summary.
  • Field Details

    • TYPES

      public static final Set<String> TYPES
      The kinds of change the model is asked to choose from; they match the default labels.
    • TEMPLATE_NAME

      public static final String TEMPLATE_NAME
      The prompt of the built-in default template.
      See Also:
  • Method Details

    • buildPrompt

      public static String buildPrompt(String template, String repo, String branch, List<CommitData> commits, AiConfig config)
      Fills the template. {repo}, {branch}, {commits} (author, date and message of each commit) and {diff} (the changes, shared out so that the whole prompt stays within the size limit) are replaced. Files that match the privacy patterns never appear, not even by name.
    • buildPrompt

      public static String buildPrompt(String template, String repo, String branch, List<CommitData> commits, AiConfig config, String language)
      As above; language is the English name of the language the answer is written in ({language} of the template; empty = the language of the commit messages). A template that has no {language} gets a closing sentence, so the choice applies to it too.
    • parse

      public static CommitSummary.Summary parse(String answer)
      Reads the answer; never fails: whatever does not fit the shape becomes the summary text.