1.0.0 • Published 6 months ago

@arjunambavane/clai v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

CLAI Demo

✨ Features

  • Terminal Integration: AI assistant that lives in your terminal
  • Command Execution: Automatically runs shell commands on your behalf
  • Multiple AI Models: Switch between various language models (Mistral, Claude, GPT, Gemini, etc.)
  • Context Awareness: Maintains chat history for more contextual responses
  • Beautiful TUI: Modern terminal UI built with React Ink

šŸ“¦ Installation

npm install -g clai

or

yarn global add clai

šŸ”‘ Prerequisites

CLAI requires an OpenRouter API key to function. If you don't have one:

  1. Create an account at OpenRouter.ai
  2. Generate an API key from your dashboard
  3. The API key will be requested on first run or can be set manually (see Configuration)

šŸš€ Quick Start

After installation, simply run:

clai

On first run, you'll be prompted for your OpenRouter API key. After that, you can start chatting with your AI assistant.

šŸ’¬ Usage

CLAI provides two main types of responses:

1. Explanations

The AI will respond with helpful text, code examples, and guidance.

2. Command Execution

When appropriate, the AI will suggest and execute terminal commands:

  • The command will be shown with an explanation
  • You'll see real-time execution
  • Results will be displayed directly in the chat

āš™ļø Configuration

You can set your OpenRouter API key in one of these ways:

  1. Let CLAI prompt you on first run
  2. Create a config file at ~/.clai/config.json:
    {
      "apiKey": "your-openrouter-api-key"
    }

šŸ”„ Model Selection

CLAI supports multiple AI models through OpenRouter:

  • mistralai/mistral-7b-instruct (default)
  • neversleep/noromaid-20b
  • perplexity/llama-3.1-sonar-small-128k-online
  • perplexity/sonar
  • openai/gpt-3.5-turbo
  • anthropic/claude-3.5-haiku
  • google/gemini-flash-1.5-8b

To change models during a session:

  1. Type /models at the prompt
  2. Select your preferred model from the list

āŒØļø Commands

  • /help - Show all available commands
  • /clear - Clear the current chat history
  • /model - Change the AI model
  • /exit or Ctrl+C - Exit CLAI

šŸ“Š Project Structure

clai/
ā”œā”€ā”€ components/        # React components for the TUI
ā”œā”€ā”€ hooks/             # Custom React hooks
ā”œā”€ā”€ utils/             # Utility functions and types
│   ā”œā”€ā”€ aiClient.ts    # OpenRouter API client
│   ā”œā”€ā”€ models.ts      # Model definitions
│   ā”œā”€ā”€ chatTypes.ts   # Type definitions
│   └── config.js      # Configuration management
└── index.tsx          # Application entry point

šŸ”’ Privacy & Security

CLAI:

  • Only sends your prompts to the selected AI model via OpenRouter
  • Can execute shell commands on your machine, so review before confirming
  • Does not collect telemetry or user data

šŸ“ TODO

  • Implement previous chat context memory
  • Add offline support
  • Add support for command aliasing

šŸ¤ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

šŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.