aicli logo

A CLI that converts natural language to shell commands.

Inspired by the GitHub Copilot X CLI, but open source for everyone.


aicli

Ruby port by Antonio Molinari, inspired by the original BuilderIO/ai-shell CLI.

Setup

Requires Ruby 3.0+

  1. Install aicli:

    gem install aicli
    

    Or from this repository:

    bundle install
    bundle exec rake install
    # or
    gem build aicli.gemspec && gem install ./aicli-*.gem
    
  2. Retrieve your API key from OpenAI

    Note: If you haven't already, you'll have to create an account and set up billing.

  3. Set the key so aicli can use it:

    aicli config set OPENAI_KEY=<your token>
    

    This will create a .aicli file in your home directory.

Usage

aicli <prompt>

For example:

aicli list all log files

Then you will get an output where you can choose to run the suggested command, revise it via a prompt, edit it, copy it, or cancel.

The short alias ai is also available.

Special characters

Some shells handle characters like ? or * specially. Wrap the prompt in quotes if needed:

aicli 'what is my ip address'

Chat mode

aicli chat

Engage in a conversation with the AI directly through the CLI.

Silent mode (skip explanations)

aicli -s list all log files

Or save the preference:

aicli config set SILENT_MODE=true

Custom API endpoint

aicli config set OPENAI_API_ENDPOINT=<your proxy endpoint>

Default: https://api.openai.com/v1

Set Language

Language Key
English en
Simplified Chinese zh-Hans
Traditional Chinese zh-Hant
Spanish es
Japanese jp
Korean ko
French fr
German de
Russian ru
Ukrainian uk
Vietnamese vi
Arabic ar
Portuguese pt
Turkish tr
Indonesian id
Italian it
aicli config set LANGUAGE=zh-Hans

Config UI

aicli config

Upgrading

aicli --version
gem update aicli

Or:

aicli update

Development

bundle install
bundle exec bin/aicli --help
bundle exec bin/aicli config set OPENAI_KEY=<your token>
bundle exec bin/aicli list all log files

Common Issues

429 error

This is due to incorrect billing setup or excessive quota usage. Please follow this guide to fix it.

You can activate billing at this link.

Motivation

I am not a bash wizard, and am dying for access to the copilot CLI, and got impatient.

Credit

  • Ruby port by Antonio Molinari
  • Inspired by BuilderIO/ai-shell
  • Thanks to GitHub Copilot for their amazing tools and the idea for this
  • Thanks to Hassan and his work on aicommits, which inspired the workflow and some parts of the code and flows
  • Original Node.js implementation by Builder.io