Skip to content

fim-sh/wish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wish

A Rust-based CLI client that allows using LLMs right from the terminal.

Preview of wish

Overview

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.

Usage

wish [OPTIONS] [-- <QUERY>...]

Example:

wish -- list all .tmp files

⚠️ Before running wish, make sure you have a valid configuration. Check the defaults-wish.yaml for default config file.

Interactive Mode

By default, when you run wish, it prompts for input and offers choices for:

  1. Executing the command directly
  2. Copying to clipboard
  3. Continuing the conversation

Non-Interactive Mode

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

Buidling

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 build

Or for production build with optimizations:

cargo build --release

The compiled binary will be located in target/debug/wish (or target/release/wish for release builds).

Architecture

src/main.rs

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

src/lib.rs

Defines the public API, including the WishOutput structure for serializing results in non-interactive mode.

src/config.rs

Manages configuration loading and parsing logic.

  • Defines configuration structures for logging, service, model, and response parsing
  • Loads configuration from multiple sources.
  • Uses config crate for flexible configuration management

Configuration Structure

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
  • Environment variables prefixed with WISH_

Configuration Parameters

  • log_level: Logging verbosity (default: "warn")
  • service: LLM service configuration:
    • url: API endpoint URL
    • api_key: Authentication key
    • model_name: Custom model identifier
    • timeout: Request timeout in seconds
  • model: Model behavior settings:
    • prompt: System prompt for the LLM
    • temp: Temperature setting for response randomness
  • response: Response parsing settings:
    • regexp: Regular expression for extracting commands
    • ignore_chars: Number of characters to trim from each side of matched text

Logging

Logs are written to:

  • Terminal (stdout/stderr) with TermLogger
  • File in $XDG_STATE_HOME/wish/wish.log (if --dont_log is not set)

Logging levels are configurable through log_level.

About

A Rust-based CLI client that allows using LLMs right from the terminal.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages