ai

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2025 License: MIT

README

AI Command Line Tool

Quick start

AI Cloud Hub is now live: https://ai.dhnt.io/

You can build and run locally.

git clone https://github.com/qiangli/ai.git
cd ai
#
# ./build.sh
go mod download

CGO_ENABLED=0 go build -o "$(go env GOPATH)/bin/ai" -ldflags="-w -extldflags '-static' ${CLI_FLAGS:-}" ./cmd

Build and Run

As a software engineer, I need two types of tools for my daily tasks: one for working inside a file and the other outside.

This AI tool assists you with all the tasks beyond file editing on your system complementing Continue, Cline and the like.

Specialist agents - such as shell, web, git, pr, code, and sql - will empower you to be much more productive...

If you prefer graphical UI, this tool can serve as backend hub service to the web widget, browser/vscode extensions, and desktop app, including a web terminal: AI Chatbot Conversation history is shared among all the different UIs so LLMs won't lose the context when switching the interfaces.

Build
git clone https://github.com/qiangli/ai.git
cd ai
# make build
# just build
./build.sh
Run
# command line
ai [OPTIONS] AGENT [message...]

ai --help

# setup (optional)
# minimum requirement: OPENAI_API_KEY or GEMINI_API_KEY environment variable is set
ai /setup
ai /help info

# @ask is optional and the default agent by default
ai @ask what is the capital of France?

# generate a commit message based on the diff from stdin
git diff origin main | ai @git/long commit message

# / is short for @shell/
ai / What tools could I use to search for a pattern in files

# interactive shell
ai -i

# run ai (interative) over ssh
ssh --tty user@host ai -i
Test

No API calls will be made in dry-run mode.

ai --dry-run --dry-run-content "fake data" ...
Debug
ai --verbose ...

ai /help info
Usage
Command line
$ ai
AI Command Line Tool

Usage:
  ai [OPTIONS] [@AGENT] MESSAGE...

Examples:

ai what is fish
ai / what is fish
ai @ask what is fish


Miscellaneous:
  ai /hub                        Manage Hub services
  ai /mcp                        Manage MCP server
  ai /setup                      Setup configuration

Use "ai /help [agents|commands|tools|info]" for more information.
$ ai /help
AI Command Line Tool

Usage:
  ai [OPTIONS] [@AGENT] MESSAGE...

There are multiple ways to interact with this AI tool.

+ Command line input:

  ai @agent what is fish?

+ Read from standard input:

  ai @agent --stdin
  ai @agent -

Ctrl+D to send, Ctrl+C to cancel.

+ Here document:

  ai @agent <<eof
what is the weather today?
eof

+ Piping input:

  git diff origin/main | ai @agent [message...]

+ File redirection:

  ai @agent [message...] < file.txt

+ Reading from system clipboard:

  ai @agent [message...] --pb-read
  ai @agent [message...] {
  ai @agent [message...] --pb-tail
  ai @agent [message...] {{

Use system copy (Ctrl+C on Unix) to add selected contents.
Ctrl+C to cancel.

+ Composing with text editor:

  export AI_EDITOR=nano # default: builtin
  ai @agent -e



Options:
  -a, --agent string    Specify the agent to use. @<agent> (default "ask")
      --chat string     Continue conversation with the chat id
  -e, --edit            Launch editor
      --format string   Output format: raw, text, json, markdown, or tts. (default "markdown")
  -h, --help            help for ai
  -i, --interactive     Interactive mode
      --log string      Log all debugging information to a file
      --max-turns int   Max number of turns (default 16)
  -m, --models string   LLM model alias defined in the models directory
  -n, --new             Start a new conversation
      --output string   Save final response to a file.
      --pb-append       Append output to clipboard. '}}'
      --pb-read         Read input from clipboard. '{'
      --pb-tail         Read input from clipboard and wait. '{{'
      --pb-write        Copy output to clipboard. '}'
      --quiet           Operate quietly. Only show final response
      --stdin           Read input from stdin. '-'
      --unsafe          Skip command security check to allow unsafe operations. Use with caution
      --verbose         Show progress and debugging information
  -v, --version         version for ai

Environment variables:
  AI_AGENT, AI_ALLOW, AI_API_KEY, AI_BASE_URL, AI_CHAT, AI_CONFIG, AI_DENY, AI_DRY_RUN, AI_DRY_RUN_CONTENT, AI_EDIT, AI_EDITOR, AI_FILE, AI_FORMAT, AI_HELP, AI_HOST, AI_IMAGE_VIEWER, AI_INTERACTIVE, AI_INTERNAL, AI_L1_API_KEY, AI_L1_BASE_URL, AI_L1_MODEL, AI_L2_API_KEY, AI_L2_BASE_URL, AI_L2_MODEL, AI_L3_API_KEY, AI_L3_BASE_URL, AI_L3_MODEL, AI_LOG, AI_MAX_HISTORY, AI_MAX_SPAN, AI_MAX_TIME, AI_MAX_TURNS, AI_MCP_SERVER_ROOT, AI_MESSAGE, AI_MODEL, AI_MODELS, AI_NEW, AI_OUTPUT, AI_PB_APPEND, AI_PB_READ, AI_PB_TAIL, AI_PB_WATCH, AI_PB_WRITE, AI_PORT, AI_PROMPT, AI_PROVIDER, AI_QUIET, AI_ROLE, AI_SCREENSHOT, AI_SHELL, AI_SQL_DB_HOST, AI_SQL_DB_NAME, AI_SQL_DB_PASSWORD, AI_SQL_DB_PORT, AI_SQL_DB_USERNAME, AI_STDIN, AI_TEMPLATE, AI_TTS_API_KEY, AI_TTS_BASE_URL, AI_TTS_MODEL, AI_TTS_PROVIDER, AI_UNSAFE, AI_VERBOSE, AI_VERSION, AI_VOICE, AI_WATCH, AI_WORKSPACE

Use "ai /help [agents|commands|tools|info]" for more information.
Interactive shell
ai -i
ai.git@main/. ai> help
  exit                     │  exit ai shell
  history [-c]             │  display or clear command history
  alias [name[=value]      │  set or print aliases
  env [name[=value]        │  export or print environment
  source [file]            │  set alias and environment from file
  edit [file]              │  text editor
  explore [--help] [path]  │  explore local file system
  | page                   │  similar to more or less
  help                     │  help for ai shell
  @[agent]                 │  agent command
  /[command]               │  slash (shell agent) command

  Key Bindings:
  Ctrl + A	Go to the beginning of the line (Home)
  Ctrl + E	Go to the end of the line (End)
  Ctrl + P	Previous command (Up arrow)
  Ctrl + N	Next command (Down arrow)
  Ctrl + F	Forward one character
  Ctrl + B	Backward one character
  Ctrl + D	Delete character under the cursor
  Ctrl + H	Delete character before the cursor (Backspace)
  Ctrl + W	Cut the word before the cursor to the clipboard
  Ctrl + K	Cut the line after the cursor to the clipboard
  Ctrl + U	Cut the line before the cursor to the clipboard
  Ctrl + L	Clear the screen

AI Graphical UI

Please see Chatbot at https://github.com/qiangli/chatbot

Credits

Directories

Path Synopsis
cmd
bubble/choose
Package choose provides an interface to choose one option from a given list of options.
Package choose provides an interface to choose one option from a given list of options.
bubble/confirm
Package confirm provides an interface to ask a user to confirm an action.
Package confirm provides an interface to ask a user to confirm an action.
bubble/file
Package file provides an interface to pick a file from a folder (tree).
Package file provides an interface to pick a file from a folder (tree).
bubble/util/tty
Package tty provides tty-aware printing.
Package tty provides tty-aware printing.
bubble/write
Package write provides a shell script interface for the text area bubble.
Package write provides a shell script interface for the text area bubble.
pager
Package pager provides a pager (similar to less) for the terminal.
Package pager provides a pager (similar to less) for the terminal.
Adapted from https://github.com/justinas/alice/blob/master/chain.go
Adapted from https://github.com/justinas/alice/blob/master/chain.go
api
llm
log
tool/web/ddg
https://github.com/tmc/langchaingo/blob/main/tools/duckduckgo/internal/client.go https://github.com/tmc/langchaingo?tab=MIT-1-ov-file#readme
https://github.com/tmc/langchaingo/blob/main/tools/duckduckgo/internal/client.go https://github.com/tmc/langchaingo?tab=MIT-1-ov-file#readme
tool/web/scrape
https://github.com/tmc/langchaingo/blob/main/tools/scraper/scraper.go https://github.com/tmc/langchaingo?tab=MIT-1-ov-file#readme
https://github.com/tmc/langchaingo/blob/main/tools/scraper/scraper.go https://github.com/tmc/langchaingo?tab=MIT-1-ov-file#readme
vfs
vos

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL