Skip to content

A powerful terminal AI agent powered by Moonshot AI's Kimi K2 model. This CLI tool provides interactive chat with tool-calling capabilities and autonomous agent spawning.

License

Notifications You must be signed in to change notification settings

peterkure3/kimi-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kimi CLI

A powerful terminal AI agent powered by Moonshot AI's Kimi K2 model. This CLI tool provides interactive chat with tool-calling capabilities and autonomous agent spawning.

Features

  • 🤖 Interactive Chat: Have conversations with the Kimi K2 model in your terminal
  • 🔧 Tool Calling: Built-in tools for file operations, shell commands, and web scraping
  • 🚀 Agent Spawning: Generate and run autonomous Python agents
  • 📝 Rich Output: Beautiful markdown rendering and colored output
  • 🔌 Extensible: Easy to add custom tools

Installation

  1. Clone the repository:
git clone <repository-url>
cd kimi-cli
  1. Install the package:
pip install -e .
  1. Set up your environment:
# Create a .env file with your Moonshot AI API key
echo "MOONSHOT_API_KEY=your_api_key_here" > .env

Get your API key from Moonshot AI Platform

Usage

Interactive Chat with Tools

Start an interactive chat session with tool-calling capabilities:

kimi chat

This will start a REPL where you can:

  • Chat with the AI
  • Use built-in tools (file operations, shell commands)
  • Use custom tools from the tools/ directory

Spawn Autonomous Agents

Generate and run autonomous Python agents:

kimi agent "create a python script that downloads the top HN stories and saves them to hn_top.json"

This will:

  1. Generate a Python script based on your prompt
  2. Save it to a temporary file
  3. Execute it automatically

Built-in Tools

The CLI comes with several built-in tools:

  • shell(command): Run arbitrary shell commands
  • read_file(path): Read local files
  • write_file(path, content): Write content to files
  • list_directory(path): List directory contents

Custom Tools

Add custom tools by placing Python files in the tools/ directory. Each tool should expose:

  • name: Tool name
  • description: Tool description
  • parameters: JSON schema for parameters
  • func: The actual function

Example tool structure:

name = "my_tool"
description = "Description of what this tool does"
parameters = {
    "type": "object",
    "properties": {
        "param1": {"type": "string", "description": "Parameter description"}
    },
    "required": ["param1"]
}

def func(param1: str) -> str:
    # Tool implementation
    return "result"

Available Custom Tools

  • web_get: Fetch raw HTML/text from URLs
  • aria2_download: Download files using aria2c (supports HTTP, FTP, SFTP, magnet links, torrents)

Configuration

Environment variables:

  • MOONSHOT_API_KEY: Your Moonshot AI API key (required)
  • KIMI_MODEL: Model to use (default: kimi-k2-0711-preview)

Models

This CLI uses Moonshot AI's models:

  • kimi-k2-0711-preview: Mixture-of-Experts model with 128K context window, 1 trillion parameters (32B active per forward pass)
  • moonshot-v1-8k: Standard LLM with 8K context window

Requirements

  • Python 3.9+
  • Moonshot AI API key
  • For aria2 tool: aria2c binary on PATH

License

About

A powerful terminal AI agent powered by Moonshot AI's Kimi K2 model. This CLI tool provides interactive chat with tool-calling capabilities and autonomous agent spawning.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published