cookie-ai-cli v1.4.3
Cookie AI CLI
Read the full docs at ai.cookiecloud.dev
Overview
Cookie AI CLI is a sophisticated command-line interface tool that seamlessly integrates natural language processing with command-line operations. It acts as an AI Terminal Assistant, transforming user prompts given in natural language into executable CLI commands. This tool is ideal for those unfamiliar with specific CLI syntax or looking to enhance their command-line efficiency.
Key Features:
- Natural Language Command Interpretation: Converts natural language inputs into executable CLI commands.
- Customizable Settings: Offers various configurations for different AI models and custom API endpoints.
- System-Specific Adaptability: Tailors commands for various systems based on CPU architecture, OS platform, type, and kernel version.
- Response Schema Flexibility: Supports a predefined response schema for executing commands, command lists, or handling complex operations needing additional user info.
Installation
Install Cookie AI CLI globally with npm to access the ai
command anywhere on your system:
npm install -g cookie-ai-cli
Configuration
Initialization
Initialize your configuration with:
ai --init
This will prompt for API service, endpoint, and an optional API key. Settings are saved in ~/.cookie-ai/settings.json
.
Usage
Input your prompt after the ai
command or enter the CLI for more complex prompts:
ai what is my public ip address
For special characters like ?
, !
, or .
, use quotes or enter the CLI:
ai
> Enter your command: what is my public ip address?
Settings Configuration
The Cookie AI CLI tool uses a structured settings schema to manage various configuration options. Here’s how to set up and understand the settings for the tool:
File Location
The settings are stored in a JSON file located at ~/.cookie-ai/settings.json
. You can manually edit this file or run ai --init
to initialize or update the settings through a guided setup.
Settings Schema Overview
The settings schema is defined as follows:
endpoint
: Optional. A URL string required when using a custom service.service
: Required. Specifies the service type, either"custom"
or"openai"
.model
: Required. Indicates the model to use (e.g.,"gpt-4"
).openai
: Optional. Contains OpenAI specific settings.key
: Required for theopenai
service. Your OpenAI API key.
custom
: Optional. Contains settings for a custom service.payload
: Optional. A record of strings for additional payload data.
headers
: Optional. A record of strings for custom headers in each request.
Example Configurations
OpenAI Service Example
{
"service": "openai",
"model": "gpt-4",
"openai": {
"key": "<your-open-ai-api-key>"
}
}
Custom Service Example
{
"service": "custom",
"endpoint": "https://<your-custom-endpoint>/v1/chat/completions",
"model": "gpt-4",
"headers": {
"Authorization": "Bearer <your-token>",
"Some-Other-Header": "Some-Other-Value"
}
}
Custom Payload Example
{
"service": "custom",
"endpoint": "https://<your-custom-endpoint>/v1/chat/completions",
"model": "gpt-4",
"payload": {
"instruction_template": "Alpaca"
}
}
Error Handling
Cookie AI CLI provides feedback and suggests new commands in case of errors. It tracks context from previous commands to streamline user experience.
Command Not Found Handling
The tool assists with unrecognized commands, suggesting corrections or alternatives.
Integrating with Zsh
Add a custom command_not_found_handler
function to your .zshrc
or .zprofile
:
command_not_found_handler() {
echo "zsh: command not found: $@"
ai "zsh: command not found: $@"
}
Reload the shell configuration with source ~/.zshrc
or source ~/.zprofile
.
Integrating with Bash
Define a command_not_found_handle
function in your .bashrc
or .bash_profile
:
command_not_found_handle() {
echo "bash: command not found: $@"
ai "bash: command not found: $@"
}
Reload with source ~/.bashrc
or source ~/.bash_profile
.
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago