A Rust-based CLI client that allows using LLMs right from the terminal.
wish is a utility that facilitates interaction with LLMs through a command-line interface, allowing users to execute shell commands or copy outputs based on LLM responses. It supports self-hosted models, both interactive and non-interactive modes, and includes configuration management for service endpoints, model parameters, and response parsing.
wish [OPTIONS] [-- <QUERY>...]Example:
wish -- list all .tmp fileswish, make sure you have a valid configuration. Check the defaults-wish.yaml for default config file.
By default, when you run wish, it prompts for input and offers choices for:
- Executing the command directly
- Copying to clipboard
- Continuing the conversation
With --non-interactive, the application processes the query and outputs the result:
- Optionally serialized as YAML with
--serialize-output - Otherwise printed to stdout as the extracted command
This project is built using Cargo, Rust's package manager and build system. To compile and run the application, first ensure you have Rust installed on your system, then navigate to the project root directory and execute:
cargo buildOr for production build with optimizations:
cargo build --releaseThe compiled binary will be located in target/debug/wish (or target/release/wish for release builds).
The main application entry point with most of the app's logic.
- Parses command-line arguments using
clap - Initializes logging using
simplelog - Configures and initializes a LLM API client
- Implements the main interaction loop
- Handles user input, command execution, and clipboard copying
- Supports both interactive and non-interactive modes
Defines the public API, including the WishOutput structure for serializing results in non-interactive mode.
Manages configuration loading and parsing logic.
- Defines configuration structures for logging, service, model, and response parsing
- Loads configuration from multiple sources.
- Uses
configcrate for flexible configuration management
The configuration system supports hierarchical loading from various locations with fallbacks to environment variables, in the following order:
- System-wide config at
/usr/share/wish/config.yaml - System config at
/etc/wish/config.yaml - User config at
$HOME/.config/wish/config.yaml - Executable-specific defaults and config files
- Defaults loaded from
<executable path>/defaults-wish.yaml - Configuration loaded from
<executable path>/config-wish.yaml
- Defaults loaded from
- Environment variables prefixed with
WISH_
log_level: Logging verbosity (default: "warn")service: LLM service configuration:url: API endpoint URLapi_key: Authentication keymodel_name: Custom model identifiertimeout: Request timeout in seconds
model: Model behavior settings:prompt: System prompt for the LLMtemp: Temperature setting for response randomness
response: Response parsing settings:regexp: Regular expression for extracting commandsignore_chars: Number of characters to trim from each side of matched text
Logs are written to:
- Terminal (stdout/stderr) with
TermLogger - File in
$XDG_STATE_HOME/wish/wish.log(if--dont_logis not set)
Logging levels are configurable through log_level.
