Class ManualPrepareEngine

java.lang.Object
org.egothor.methodatlas.ai.ManualPrepareEngine

public final class ManualPrepareEngine extends Object
Handles the prepare phase of the manual AI workflow.

This engine supports operators who cannot use an automated AI API but can interact with an AI through a standard chat window. For each test class it writes a work file to the configured work directory. Each work file contains:

  • human-readable operator instructions
  • the complete AI prompt (taxonomy, method list, class source) that the operator should paste into their AI chat window

After the AI responds the operator pastes the response text into the pre-created <fqcn>.response.txt stub and then runs the consume phase (via ManualConsumeEngine) to produce the final enriched CSV.

File naming

Work files are named <fqcn>.txt and written to the work directory. Empty response stubs are named <fqcn>.response.txt and written to the response directory. Both directories are flat (no sub-directory structure). The two directories may be the same path.

See Also:
  • Constructor Details

    • ManualPrepareEngine

      public ManualPrepareEngine(Path workDir, Path responseDir, AiOptions options) throws AiSuggestionException
      Creates a new prepare engine that writes work files and response stubs to separate directories.

      Both directories are created if they do not already exist. The two paths may point to the same directory.

      Parameters:
      workDir - path to the directory where work files (<fqcn>.txt) will be written
      responseDir - path to the directory where empty response stubs (<fqcn>.response.txt) will be pre-created
      options - AI options used to load the taxonomy text; only taxonomy settings are relevant here — provider settings are ignored
      Throws:
      AiSuggestionException - if either directory cannot be created or the configured taxonomy file cannot be read
  • Method Details

    • prepare

      public Path prepare(String fileStem, String fqcn, String classSource, List<PromptBuilder.TargetMethod> targetMethods) throws AiSuggestionException
      Builds and writes the work file for the specified test class, and pre-creates an empty response file alongside it.

      The work file contains operator instructions at the top followed by the full AI prompt. The prompt is built using PromptBuilder.build(java.lang.String, java.lang.String, java.lang.String, java.util.List<org.egothor.methodatlas.ai.PromptBuilder.TargetMethod>, boolean) and embeds the complete class source so the operator can paste the entire block into their AI chat window without attaching any files separately.

      File names are derived from fileStem (a dot-separated path identifier based on the source file's location relative to the scan root) rather than the FQCN. This ensures uniqueness in multi-module projects where the same FQCN may appear in multiple modules. For a standard Maven source root (e.g. src/test/java), the stem is identical to the FQCN.

      An empty <fileStem>.response.txt file is also written to the response directory so the operator only needs to paste the AI response into the pre-existing file rather than creating it manually. If the response file already contains content (e.g. from a previous run) it is left untouched.

      Parameters:
      fileStem - dot-separated path stem used as the base name for the work file and response stub; derived from the source file path relative to the scan root
      fqcn - fully qualified class name of the test class; used in the work file content and AI prompt
      classSource - complete source code of the test class
      targetMethods - deterministically discovered JUnit test methods to classify
      Returns:
      path of the written work file
      Throws:
      AiSuggestionException - if the work file or the empty response file cannot be written