cchain
Overview
cchain is a command line tool designed to execute a series of commands based on a configuration file. It supports retrying commands if they fail, with a specified number of attempts. Additionally, cchain can generate command inputs using a language model (LLM) based on specified functions.
Features
- Execute commands with specified arguments.
- Retry commands on failure with configurable retry limits.
- Simple configuration using JSON files.
- Logging of command execution and retries.
- Generate command inputs dynamically using LLM functions.
Installation
Cargo
Use Cargo to install cchain:
Building from Source
To install cchain, clone the repository and build it using Cargo:
Usage
Create a JSON configuration file with the commands you want to execute. Example configuration:
Additionally, if you do not specify a configuration file, cchain will list all available configuration files in the current working directory that start with cchain_ and have a .json extension. You can then select the desired configuration file by entering the corresponding number.
Example:
This will prompt you to select from the available configuration files in the current directory.
Run cchain with the path to your configuration file:
Also, if you would like to pick a command chain in a different folder than the current one, you can use the --directory flag:
To generate a template configuration file, use the --generate flag:
Using Functions with LLM
You can specify functions in your configuration file that will generate command inputs dynamically using a language model. Example configuration with a function:
In this example, the llm_generate function will use the specified arguments to generate a git commit message by prompting the LLM with git --no-pager diff.
You can configure the LLM by setting the following environment variables:
Here in the example, we are using a locally hosted Ollama model.
License
This project is licensed under the MIT License.