Skip to content

jo-hoe/ai-cli-assistant

Repository files navigation

AI CLI Assistant

Go Reference Test Status Coverage Status Lint Status CodeQL Status Go Report Card

Provides CLI commands based on natural language using GenAI. The tool is platform and CLI independent (works on Mac, Windows, and Linux).

Demo

Prerequisites

Configuration (YAML)

Non-secret configuration is read from a YAML config file. Secrets (API keys) are provided via environment variables.

  • Config lookup order:
    1. If the environment variable AI_CLI_CONFIG is set, that path is used
    2. Otherwise, config.yaml in the current working directory is used
    3. If no file is found, built-in defaults are used

You can find a template with all supported options at config.example.yaml. Copy it to config.yaml and adjust as needed, or set AI_CLI_CONFIG to point to a specific file:

  • Windows PowerShell: $Env:AI_CLI_CONFIG = "C:\path\to\my-config.yaml"
  • bash/zsh: export AI_CLI_CONFIG="/path/to/my-config.yaml"

Secrets:

  • OPENAI_API_KEY must be provided via environment variable (not in the config file)

Build

Build the CLI binary from the entrypoint package:

go build -o ai-cli-assistant ./cmd/ai-cli-assistant

Run

Set your OpenAI API key as environment variable OPENAI_API_KEY.

Windows (PowerShell):

$Env:OPENAI_API_KEY = "sk-..."
# optional: set CLI kind to tailor wording (e.g., powershell, bash, kubectl)
$Env:CLI_KIND = "powershell"

.\ai-cli-assistant "list all folders in this folder"

macOS/Linux (bash/zsh):

export OPENAI_API_KEY="sk-..."
# optional:
export CLI_KIND="bash"

./ai-cli-assistant "list all folders in this folder"

You can also run without building:

go run ./cmd/ai-cli-assistant "list all folders in this folder"

Testing

Run all tests:

go test ./...

About

Uses GenAI to create CLI commands

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages