From dec2df05961f7727771458b1f48e7dc8715c33a2 Mon Sep 17 00:00:00 2001
From: Svjatoslav Agejenko Executes AI inference tasks through llama.cpp CLI. This class handles the complete workflow
+ * from prompt construction to response formatting, including temporary file management and process execution. Key processing steps:
+ *
+ *
+ *
Temperature settings, context size, and thread counts are all derived from the current configuration. + * The response is formatted to match org-mode conventions while preserving original conversation structure.
*/ public class AiTask { @@ -250,29 +260,6 @@ public class AiTask { "--file " + inputFile ); -// Old solution that sometimes went into an infinite loop, for backup purposes: -// -// return join(" ", -// "nice", "-n", Integer.toString(niceValue), -// executablePath, -// "--model " + mailQuery.model.filesystemPath, -// "--threads " + configuration.getThreadCount(), -// "--threads-batch " + configuration.getBatchThreadCount(), -// "--mirostat 2", -// "--flash-attn", -// "--cache-type-k q8_0", -// "--cache-type-v q8_0", -// "--no-display-prompt", -// "--no-warmup", -// "--temp " + temperature, -// "--ctx-size " + mailQuery.model.contextSizeTokens, -// "--batch-size 8", -// "--no-conversation", -// "-n -1", -// "--repeat_penalty 1.1", -// "--file " + inputFile -// ); - } /** diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/Command.java b/src/main/java/eu/svjatoslav/alyverkko_cli/Command.java index dfd9b14..fca9e37 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/Command.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/Command.java @@ -3,9 +3,15 @@ package eu.svjatoslav.alyverkko_cli; import java.io.IOException; /** - * A simple interface for all subcommands used by the Ãlyverkko CLI. - * Implementing classes define a unique name (e.g., "wizard") and an - * {@code execute} method for the command's logic. + *Base interface for all subcommands in the Ãlyverkko CLI. Each command must define its name and execution logic.
+ *Commands typically: + *
Commands should be stateless and self-contained, using the configuration object for persistent data when needed.
*/ public interface Command { diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/Utils.java b/src/main/java/eu/svjatoslav/alyverkko_cli/Utils.java index 8f42cde..4e0c94d 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/Utils.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/Utils.java @@ -1,7 +1,10 @@ package eu.svjatoslav.alyverkko_cli; /** - * Utility functions for miscellaneous tasks such as colored console output. + *General utility functions for the Ãlyverkko CLI application. Currently provides ANSI color output capabilities for + * console messages.
+ *Color formatting follows standard ANSI escape sequences, with specific methods for common message types like errors.
+ *For future extensions, this class could include additional helper functions for file operations or string processing.
*/ public class Utils { diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/JoinFilesCommand.java b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/JoinFilesCommand.java index 072bb3a..e74e5a2 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/JoinFilesCommand.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/JoinFilesCommand.java @@ -29,6 +29,21 @@ import static eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper.load * alyverkko-cli joinfiles -s /path/to/source -p "*.java" -t "my_topic" --edit * */ + +/** + *Aggregates files from a source directory into a single file for AI processing. + * This is particularly useful for creating comprehensive inputs from multiple files + * matching a specified pattern.
+ *Features include: + *
By default, the output file is saved in the mail directory with a .org extension.
+ */ public class JoinFilesCommand implements Command { /** diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/ListModelsCommand.java b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/ListModelsCommand.java index 5078177..177a443 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/ListModelsCommand.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/ListModelsCommand.java @@ -10,8 +10,16 @@ import static eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper.getC import static eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper.loadConfiguration; /** - * Lists all configured models in the system, loading them from the - * userâs configuration and printing them to the console. + *Displays all available AI models in the configured models directory. This command provides a quick overview of + * currently available models and their metadata.
+ *The implementation: + *
This command is primarily intended for administrative use to verify model availability before running tasks.
*/ public class ListModelsCommand implements Command { 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 36616d6..c9df3ca 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/WizardCommand.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/WizardCommand.java @@ -19,16 +19,19 @@ import static eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper.getC import static eu.svjatoslav.commons.cli_helper.CLIHelper.*; /** - * A single WizardCommand that: - * 1. Loads existing configuration (if any). - * 2. Performs "selftest" style validation checks interactively, - * prompting the user to fix invalid or missing items. - * 3. If no config file exists, it goes through all config parameters - * from scratch. - * 4. Offers to remove model entries that reference missing files. - * 5. Autodiscovers new .gguf files and lets the user add them to the config. - * 6. Saves the resulting (fixed) config file. - * 7. Prints a final pass/fail summary for the user. + *Interactive configuration wizard that helps users validate and fix their configuration files. + * It performs system checks and offers to fix any missing or invalid paths, discovers new models, + * and updates the configuration accordingly.
+ *Key workflow steps: + *
When handling split models (.gguf files with part numbering), the wizard automatically + * detects base models and only adds part-1 files to the configuration.
*/ public class WizardCommand implements Command { diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/MailCorrespondentCommand.java b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/MailCorrespondentCommand.java index bf291dc..cb71e41 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/MailCorrespondentCommand.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/MailCorrespondentCommand.java @@ -24,16 +24,21 @@ import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; /** - * The MailCorrespondentCommand continuously monitors a specified mail - * directory for new or modified text files, checks if they have a - * "TOCOMPUTE:" marker, and if so, processes them with an AI model. - * Once processed, results are appended to the same file. - *- * Usage: - *
- * alyverkko-cli mail - *+ *
Monitors a designated mail directory for text files containing "TOCOMPUTE:" markers. + * When new or modified files are detected, it processes them with appropriate AI models + * and appends the results using a standardized format.
+ *The processing pipeline includes: + *
This implementation uses a sleep delay (1 second) after detecting file changes to allow complete writes before + * processing. The response format follows org-mode conventions for easy reading and further processing.
*/ + public class MailCorrespondentCommand implements Command { /** diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/package-info.java b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/package-info.java index 64ce203..3bf376d 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/package-info.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/mail_correspondant/package-info.java @@ -1,8 +1,12 @@ /** - * This package contains mail processing commands for the Ãlyverkko CLI application. - *- * The MailCorrespondentCommand monitors a mail directory for tasks and processes them - * using AI models. MailQuery encapsulates the data needed for each mail-based query. + *
This subpackage implements the mail-based AI task processing functionality. It watches mail directories for + * new/modified files with specific markers and processes them using AI models.
+ *Key components: + *
- * Each command class implements the Command interface and provides functionality for - * specific user actions like model management, file joining, and mail processing. + *
This package implements all subcommands available in the Ãlyverkko CLI application. Each command class provides a + * specific functionality through the Command interface.
+ *Available commands include: + *
Central configuration class storing all application parameters. + * This class is serialized to YAML format for user editing and persistence.
+ *Configuration parameters include: + *
All paths are resolved relative to the user's home directory by default, but can be customized. The class provides + * direct access to prompt content for AI query construction.
*/ @Data public class Configuration { diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/ConfigurationHelper.java b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/ConfigurationHelper.java index 45891db..7a4a36b 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/ConfigurationHelper.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/ConfigurationHelper.java @@ -7,6 +7,17 @@ import eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption; import java.io.File; import java.io.IOException; +/** + *Helper class for configuration file operations. Provides methods for loading configurations + * and determining the default configuration file path in the user's home directory.
+ *Key functionality includes: + *
- * The Configuration class holds global settings, while ConfigurationModel represents - * individual model configurations. ConfigurationHelper provides utility methods for - * loading and managing configuration files. + *
This package handles the configuration system for the Ãlyverkko CLI application. + * It provides classes for storing and retrieving application-wide settings, including + * model configurations, directory paths, and performance parameters.
+ *Configuration is stored in YAML format and includes: + *
Represents an AI model stored on the filesystem with metadata about its capabilities and identification. + * This class serves as a lightweight container for model information, enabling quick lookup and validation.
+ *Models are typically discovered through configuration files and stored in the ModelLibrary for easy access. + *
Key fields include: + *
Prints the model's metadata to standard output in a consistent format. This includes the model's alias, + * filesystem path, and context token capacity. The output format is designed to be both human-readable and + * machine-parsable when needed.
+ *Typical output: + *
+ * Model: default + * Path: /path/to/model.gguf + * Context size: 32768 + *+ * */ public void printModelDetails() { System.out.println("Model: " + alias); diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/model/package-info.java b/src/main/java/eu/svjatoslav/alyverkko_cli/model/package-info.java index 9fb1aca..717d44e 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/model/package-info.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/model/package-info.java @@ -1,8 +1,12 @@ /** - * This package contains classes for managing AI models in the Ãlyverkko CLI application. - *
- * The Model class represents an AI model with metadata like path and context size. - * The ModelLibrary class manages a collection of models, providing lookup and validation. + *
This package defines the model management system for the Ãlyverkko CLI. + * It includes classes for representing AI models and maintaining a library of available models.
+ *Key features: + *
- * It includes the Main entry point, Command interface, and utility classes like Utils. + *
This package contains the core components of the Ãlyverkko CLI application, including the main entry point, + * command interfaces, and utility classes. It serves as the central hub for orchestrating subcommands and core + * application behavior.
+ *Key responsibilities include: + *