From 3678f270337c544d48abf69ca8aa841ebdbcadd0 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 31 Aug 2025 04:04:16 +0300 Subject: [PATCH] Switch to the YAML-based prompt file --- .../alyverkko_cli/commands/WizardCommand.java | 2 +- .../alyverkko_cli/configuration/Configuration.java | 12 ++++++++---- .../alyverkko_cli/configuration/PromptConfig.java | 8 ++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 src/main/java/eu/svjatoslav/alyverkko_cli/configuration/PromptConfig.java diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/WizardCommand.java b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/WizardCommand.java index f68192f..742bd06 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/WizardCommand.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/WizardCommand.java @@ -154,7 +154,7 @@ public class WizardCommand implements Command { configuration.getPromptsDirectory(), "Prompts directory", null, - "The prompts directory is where the AI prompt files (*.txt) are stored. " + + "The prompts directory is where the AI prompt files (*.yaml) are stored. " + "Please specify new prompts directory path.", true) ); diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/Configuration.java b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/Configuration.java index 01ed019..db4d82f 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/Configuration.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/Configuration.java @@ -5,8 +5,9 @@ import lombok.Data; import java.io.*; import java.util.List; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import static eu.svjatoslav.commons.file.IOHelper.getFileContentsAsString; /** *

Central configuration class storing all application parameters. @@ -79,11 +80,14 @@ public class Configuration { * maps to "writer.txt" in the prompt's directory. * * @param promptName the name of the prompt file (without ".txt"). - * @return the full text content of the prompt file. + * @return the full-text content of the prompt file. * @throws IOException if reading the prompt file fails. */ public String getPromptByName(String promptName) throws IOException { - File promptFile = new File(promptsDirectory, promptName + ".txt"); - return getFileContentsAsString(promptFile); + File promptFile = new File(promptsDirectory, promptName + ".yaml"); + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + PromptConfig config = mapper.readValue(promptFile, PromptConfig.class); + return config.getPrompt(); } + } diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/PromptConfig.java b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/PromptConfig.java new file mode 100644 index 0000000..55cb4e7 --- /dev/null +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/PromptConfig.java @@ -0,0 +1,8 @@ +package eu.svjatoslav.alyverkko_cli.configuration; + +import lombok.Data; + +@Data +public class PromptConfig { + private String prompt; +} \ No newline at end of file -- 2.20.1