### Development Setup and Commands Source: https://github.com/moonshotai/kimi-cli/blob/main/packages/kosong/README.md Commands for cloning the repository, installing dependencies, and running development tasks. ```bash git clone https://github.com/MoonshotAI/kosong.git cd kosong uv sync --all-extras make check # run lint and type checks make test # run tests make format # format code ``` -------------------------------- ### Kimi Web UI Server Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-command.md Common usage patterns for starting the web server with specific configurations. ```sh # Default startup, automatically opens browser kimi web # Specify port kimi web --port 8080 # Don't automatically open browser kimi web --no-open # Bind to all network interfaces (allow LAN access) kimi web --host 0.0.0.0 ``` -------------------------------- ### Install Prek via uv tool Source: https://github.com/moonshotai/kimi-cli/blob/main/CONTRIBUTING.md Install the prek tool using the uv tool. This is one of the options for manual setup if not using `make prepare`. ```bash uv tool install prek ``` -------------------------------- ### Run Custom Kimi Soul Example Source: https://github.com/moonshotai/kimi-cli/blob/main/examples/custom-kimi-soul/README.md Navigate to the custom Kimi Soul example directory, install dependencies, and run the main Python script. ```sh cd examples/custom-kimi-soul uv sync --reinstall uv run main.py ``` -------------------------------- ### Install Prek via pipx Source: https://github.com/moonshotai/kimi-cli/blob/main/CONTRIBUTING.md Install the prek tool using pipx. This is an alternative method for manual setup. ```bash pipx install prek ``` -------------------------------- ### Install Prek via pip Source: https://github.com/moonshotai/kimi-cli/blob/main/CONTRIBUTING.md Install the prek tool using pip. This is another option for manual setup. ```bash pip install prek ``` -------------------------------- ### Run Kimi Code CLI Stream JSON Example Source: https://github.com/moonshotai/kimi-cli/blob/main/examples/kimi-cli-stream-json/README.md Navigate to the example directory and run the Python script to start the Kimi Code CLI subprocess. ```shell cd examples/kimi-cli-stream-json uv run main.py ``` -------------------------------- ### Install via uv Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/guides/getting-started.md Alternative installation method if uv is already present on the system. ```sh uv tool install --python 3.13 kimi-cli ``` -------------------------------- ### Initialize and Install Kosong Source: https://github.com/moonshotai/kimi-cli/blob/main/packages/kosong/README.md Commands to initialize a project and install the Kosong library with optional extras. ```bash uv init --python 3.12 # or higher ``` ```bash uv add kosong ``` ```bash uv add 'kosong[contrib]' ``` -------------------------------- ### Initialize Request and Response Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md JSON-RPC examples for the initialize request and a successful response. ```json {"jsonrpc": "2.0", "method": "initialize", "id": "550e8400-e29b-41d4-a716-446655440000", "params": {"protocol_version": "1.7", "client": {"name": "my-ui", "version": "1.0.0"}, "capabilities": {"supports_question": true}, "external_tools": [{"name": "open_in_ide", "description": "Open file in IDE", "parameters": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}}]}} ``` ```json {"jsonrpc": "2.0", "id": "550e8400-e29b-41d4-a716-446655440000", "result": {"protocol_version": "1.7", "server": {"name": "Kimi Code CLI", "version": "1.14.0"}, "slash_commands": [{"name": "init", "description": "Analyze the codebase ...", "aliases": []}], "capabilities": {"supports_question": true}, "external_tools": {"accepted": ["open_in_ide"], "rejected": []}}} ``` -------------------------------- ### GET /api/work-dirs/startup Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/WorkDirsApi.md Retrieves the directory where the kimi web application was started. ```APIDOC ## GET /api/work-dirs/startup ### Description Get the directory where kimi web was started. ### Method GET ### Endpoint /api/work-dirs/startup ### Parameters This endpoint does not require any parameters. ### Request Example ```ts import { Configuration, WorkDirsApi, } from ''; import type { GetStartupDirApiWorkDirsStartupGetRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new WorkDirsApi(); try { const data = await api.getStartupDirApiWorkDirsStartupGet(); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` ### Response #### Success Response (200) - **(string)** - The startup directory path. #### Response Example ```json "/path/to/startup/directory" ``` ``` -------------------------------- ### Install Kimi Code CLI Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/guides/getting-started.md Use the provided installation scripts for Linux/macOS or Windows to set up the CLI. ```sh # Linux / macOS curl -LsSf https://code.kimi.com/install.sh | bash ``` ```powershell # Windows (PowerShell) Invoke-RestMethod https://code.kimi.com/install.ps1 | Invoke-Expression ``` -------------------------------- ### List Installed Plugins Source: https://context7.com/moonshotai/kimi-cli/llms.txt Displays a list of all plugins currently installed in the Kimi CLI. ```bash kimi plugin list ``` -------------------------------- ### Get Startup Directory with TypeScript Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/WorkDirsApi.md Retrieves the directory where the kimi web service was started. ```ts import { Configuration, WorkDirsApi, } from ''; import type { GetStartupDirApiWorkDirsStartupGetRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new WorkDirsApi(); try { const data = await api.getStartupDirApiWorkDirsStartupGet(); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Steer JSON-RPC Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md JSON-RPC request and response examples for the steer method. ```json {"jsonrpc": "2.0", "method": "steer", "id": "7ca7c810-9dad-11d1-80b4-00c04fd430c8", "params": {"user_input": "Use Python"}} ``` ```json {"jsonrpc": "2.0", "id": "7ca7c810-9dad-11d1-80b4-00c04fd430c8", "result": {"status": "steered"}} ``` ```json {"jsonrpc": "2.0", "id": "7ca7c810-9dad-11d1-80b4-00c04fd430c8", "error": {"code": -32000, "message": "No agent turn is in progress"}} ``` -------------------------------- ### Initialize Project and Login Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/guides/getting-started.md Commands for starting the CLI in a project directory and configuring authentication. ```sh cd your-project kimi ``` ```sh /login ``` ```sh Show me the directory structure of this project ``` -------------------------------- ### Verify Installation Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/guides/getting-started.md Check the installed version of the CLI. ```sh kimi --version ``` -------------------------------- ### QuestionRequest and Response JSON Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md JSON-RPC examples for sending and responding to structured questions. ```json {"jsonrpc": "2.0", "method": "request", "id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890", "params": {"type": "QuestionRequest", "payload": {"id": "q-1", "tool_call_id": "tc-1", "questions": [{"question": "Which language should I use?", "header": "Lang", "options": [{"label": "Python", "description": "Widely used, large ecosystem"}, {"label": "Rust", "description": "High performance, memory safe"}], "multi_select": false}]}}} ``` ```json {"jsonrpc": "2.0", "id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890", "result": {"request_id": "q-1", "answers": {"Which language should I use?": "Python"}}} ``` ```json {"jsonrpc": "2.0", "id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890", "result": {"request_id": "q-1", "answers": {}}} ``` -------------------------------- ### Install Plugin from Git Repository Source: https://context7.com/moonshotai/kimi-cli/llms.txt Installs a Kimi CLI plugin directly from a Git repository URL. Supports installation from the root of the repository or a specific subdirectory. ```bash kimi plugin install https://github.com/user/repo.git ``` ```bash kimi plugin install https://github.com/user/repo.git/plugins/my-plugin ``` -------------------------------- ### Complete Kimi CLI Configuration Example Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/configuration/config-files.md A comprehensive TOML example demonstrating all top-level configuration items for Kimi Code CLI, including API providers, models, and runtime parameters. ```toml default_model = "kimi-for-coding" default_thinking = false default_yolo = false default_plan_mode = false default_editor = "" theme = "dark" show_thinking_stream = true merge_all_available_skills = false [providers.kimi-for-coding] type = "kimi" base_url = "https://api.kimi.com/coding/v1" api_key = "sk-xxx" [models.kimi-for-coding] provider = "kimi-for-coding" model = "kimi-for-coding" max_context_size = 262144 [loop_control] max_steps_per_turn = 500 max_retries_per_step = 3 max_ralph_iterations = 0 reserved_context_size = 50000 compaction_trigger_ratio = 0.85 [background] max_running_tasks = 4 keep_alive_on_exit = false agent_task_timeout_s = 900 [services.moonshot_search] base_url = "https://api.kimi.com/coding/v1/search" api_key = "sk-xxx" [services.moonshot_fetch] base_url = "https://api.kimi.com/coding/v1/fetch" api_key = "sk-xxx" [mcp.client] tool_call_timeout_ms = 60000 ``` -------------------------------- ### Install zsh-kimi-cli Plugin Source: https://github.com/moonshotai/kimi-cli/blob/main/README.md Instructions for installing the zsh-kimi-cli plugin for Oh My Zsh. After installation, add 'kimi-cli' to your Zsh plugins list in ~/.zshrc. ```sh git clone https://github.com/MoonshotAI/zsh-kimi-cli.git \ ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/kimi-cli ``` -------------------------------- ### Install Prek Hooks in Repository Source: https://github.com/moonshotai/kimi-cli/blob/main/CONTRIBUTING.md After installing prek manually, run this command to install the git hooks for the current repository. ```bash prek install ``` -------------------------------- ### Prompt JSON-RPC Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md JSON-RPC request and response examples for the prompt method. ```json {"jsonrpc": "2.0", "method": "prompt", "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "params": {"user_input": "Hello"}} ``` ```json {"jsonrpc": "2.0", "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "result": {"status": "finished"}} ``` ```json {"jsonrpc": "2.0", "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "error": {"code": -32001, "message": "LLM is not set"}} ``` -------------------------------- ### MCP Configuration File Example Source: https://context7.com/moonshotai/kimi-cli/llms.txt An example JSON file defining MCP server configurations, including URLs, headers, and commands for stdio servers. ```json // ~/.kimi/mcp.json - MCP configuration file { "mcpServers": { "context7": { "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "your-key" } }, "chrome-devtools": { "command": "npx", "args": ["chrome-devtools-mcp@latest"], "env": { "SOME_VAR": "value" } } } } ``` -------------------------------- ### Replay JSON-RPC Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md JSON-RPC request and response examples for the replay method. ```json {"jsonrpc": "2.0", "method": "replay", "id": "6ba7b812-9dad-11d1-80b4-00c04fd430c8"} ``` ```json {"jsonrpc": "2.0", "id": "6ba7b812-9dad-11d1-80b4-00c04fd430c8", "result": {"status": "finished", "events": 42, "requests": 3}} ``` -------------------------------- ### Install Plugin from ZIP File Source: https://context7.com/moonshotai/kimi-cli/llms.txt Installs a Kimi CLI plugin packaged as a ZIP archive. The CLI will extract and install the plugin from the provided file. ```bash kimi plugin install my-plugin.zip ``` -------------------------------- ### Kimi Agent (Rust) Installation Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md Instructions for downloading and installing Kimi Agent (Rust) binaries. ```APIDOC ## Kimi Agent (Rust) Installation ### Description Provides instructions for downloading pre-built binaries for Kimi Agent (Rust) from GitHub Releases. ### Installation Commands **macOS (Apple Silicon)** ```sh curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-aarch64-apple-darwin.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ ``` **Linux (x86_64)** ```sh curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-x86_64-unknown-linux-gnu.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ ``` ``` -------------------------------- ### Kimi SDK Usage Example Source: https://github.com/moonshotai/kimi-cli/blob/main/klips/klip-7-kimi-sdk.md Basic initialization and generation call using the Kimi SDK. ```python from kimi_sdk import Kimi, Message, generate kimi = Kimi( base_url="https://api.moonshot.ai/v1", api_key="sk-xxx", model="kimi-k2-turbo-preview", ) history = [Message(role="user", content="Who are you?")] result = await generate(chat_provider=kimi, system_prompt="You are a helper.", tools=[], history=history) ``` -------------------------------- ### Install Kimi Code CLI Source: https://context7.com/moonshotai/kimi-cli/llms.txt Install or upgrade Kimi Code CLI using the provided scripts or uv package manager. Ensure Python 3.12+ is installed. ```bash curl -LsSf https://code.kimi.com/install.sh | bash ``` ```powershell Invoke-RestMethod https://code.kimi.com/install.ps1 | Invoke-Expression ``` ```bash uv tool install --python 3.13 kimi-cli ``` ```bash kimi --version ``` ```bash uv tool upgrade kimi-cli --no-cache ``` ```bash uv tool uninstall kimi-cli ``` -------------------------------- ### Text output example for kimi info Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-info.md Example of the default text output format for the info command. ```sh $ kimi info kimi-cli version: 1.20.0 agent spec versions: 1 wire protocol: 1.7 python version: 3.13.1 ``` -------------------------------- ### Install Plugin from Local Directory Source: https://context7.com/moonshotai/kimi-cli/llms.txt Installs a Kimi CLI plugin located in a local directory. Ensure the path points to the plugin's root directory. ```bash kimi plugin install /path/to/my-plugin ``` -------------------------------- ### Kimi CLI Provider Configuration Example Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/configuration/config-files.md Example TOML snippet for configuring an API provider, specifying its type, base URL, API key, and custom headers. ```toml [providers.moonshot-cn] type = "kimi" base_url = "https://api.moonshot.cn/v1" api_key = "sk-xxx" custom_headers = { "X-Custom-Header" = "value" } ``` -------------------------------- ### Initialize Request Example (Wire Protocol) Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/wire-mode.md An example JSON payload for the `initialize` request in the Wire protocol, demonstrating how to specify protocol version, client information, capabilities, and external tools. ```json {"jsonrpc": "2.0", "method": "initialize", "id": "550e8400-e29b-41d4-a716-446655440000", "params": {"protocol_version": "1.7", "client": {"name": "my-ui", "version": "1.0.0"}, "capabilities": {"supports_question": true}, "external_tools": [{"name": "open_in_ide", "description": "Open file in IDE", "parameters": {"type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"]}}]}} ``` -------------------------------- ### Install Plugins via CLI Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/plugins.md Commands to install plugins from local directories, ZIP files, or Git repositories. ```sh kimi plugin install /path/to/my-plugin ``` ```sh kimi plugin install my-plugin.zip ``` ```sh # Install the root plugin kimi plugin install https://github.com/user/repo.git # Install a plugin from a subdirectory (multi-plugin repo) kimi plugin install https://github.com/user/repo.git/plugins/my-plugin # Specify a branch (use browser-style GitHub URL without .git) kimi plugin install https://github.com/user/repo/tree/develop/plugins/my-plugin ``` -------------------------------- ### Kimi Agent (Rust) Installation and Usage Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/wire-mode.md Instructions for installing and running the Kimi Agent (Rust implementation) in Wire mode, including download links and common command-line options. ```APIDOC ## Kimi Agent (Rust) Wire Server ::: warning 注意 Kimi Agent is currently an experimental feature, and its API and behavior may change in future versions. ::: Kimi Agent (Rust) is the Rust implementation of the Kimi Code CLI kernel, designed specifically for Wire mode. It offers a lighter-weight option if you only need Wire protocol services. The Rust implementation is located at [`MoonshotAI/kimi-agent-rs`](https://github.com/MoonshotAI/kimi-agent-rs). ### Features - **Full Wire Protocol Compatibility**: Uses the same Wire protocol as Python's `kimi --wire`, requiring no modifications to existing clients. - **Smaller Footprint**: A single, statically linked binary, eliminating the need for a Python runtime. - **Faster Startup**: Natively compiled for quicker launch times. - **Identical Configuration**: Uses the same configuration file (`~/.kimi/config.toml`) and session directory. ### Limitations - **Wire Mode Only**: Does not support Shell/Print/ACP UI. - **Kimi Provider Only**: Does not support other providers like OpenAI or Anthropic. - **No Kimi Account Login**: Lacks `login`/`logout` subcommands and `/login`, `/logout` slash commands; API keys must be configured manually. - **No `--prompt`/`--command` Support**: The Wire server does not accept initial prompts. - **Local Execution Only**: Does not support SSH Kaos. - **Different MCP OAuth Storage**: Kimi Agent stores credentials at `~/.kimi/credentials/mcp_auth.json`, which is incompatible with the Python version's storage location (`~/.fastmcp/oauth-mcp-client-cache/`). ### Installation Download pre-compiled binaries from [GitHub Releases](https://github.com/MoonshotAI/kimi-agent-rs/releases): ```sh # macOS (Apple Silicon) curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-aarch64-apple-darwin.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ # Linux (x86_64) curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-x86_64-unknown-linux-gnu.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ ``` ### Usage Kimi Agent runs in Wire mode by default: ```sh kimi-agent ``` Common options are the same as the `kimi` command: ```sh ``` -------------------------------- ### JSON output example for kimi info Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-info.md Example of the JSON output format when using the --json flag. ```sh $ kimi info --json {"kimi_cli_version": "1.20.0", "agent_spec_versions": ["1"], "wire_protocol_version": "1.7", "python_version": "3.13.1"} ``` -------------------------------- ### Initialize Success Response Example (Wire Protocol) Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/wire-mode.md An example JSON payload for a successful `initialize` response in the Wire protocol, detailing the server's protocol version, name, capabilities, and available slash commands. ```json {"jsonrpc": "2.0", "id": "550e8400-e29b-41d4-a716-446655440000", "result": {"protocol_version": "1.7", "server": {"name": "Kimi Code CLI", "version": "1.14.0"}, "slash_commands": [{"name": "init", "description": "Analyze the codebase ...", "aliases": []}], "capabilities": {"supports_question": true}, "external_tools": {"accepted": ["open_in_ide"], "rejected": []}}} ``` -------------------------------- ### Install Kimi SDK via uv Source: https://github.com/moonshotai/kimi-cli/blob/main/sdks/kimi-sdk/README.md Initialize a project and add the Kimi SDK dependency using the uv package manager. ```bash uv init --python 3.12 # or higher ``` ```bash uv add kimi-sdk ``` -------------------------------- ### Start Kimi Web UI Server Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-command.md Basic command to launch the web server with default settings. ```sh kimi web [OPTIONS] ``` -------------------------------- ### Verify Installation and ACP Path Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/faq.md Check version and configure ACP path for IDE integration. ```sh kimi --version kimi acp ``` -------------------------------- ### GET /api/sessions/{session_id} Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/SessionsApi.md Get session details. ```APIDOC ## GET /api/sessions/{session_id} ### Description Get session details. ### Method GET ### Endpoint /api/sessions/{session_id} ### Parameters #### Path Parameters - **session_id** (string) - Required - The ID of the session to retrieve. ### Response #### Success Response (200) - **Session** (Session) - The session object. #### Response Example ```json { "example": "Session object" } ``` ``` -------------------------------- ### Start Kimi Web UI Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-web.md Launches the Web UI server, which defaults to http://127.0.0.1:5494. ```sh kimi web ``` -------------------------------- ### Configure Visualizer Options Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/reference/kimi-vis.md Examples of launching the visualizer with custom port, browser behavior, and network accessibility settings. ```sh # 指定端口 kimi vis --port 8080 # 不自动打开浏览器 kimi vis --no-open # 在局域网中共享(自动探测并显示 LAN IP) kimi vis -n ``` -------------------------------- ### Initialize and Run Custom Tools Source: https://github.com/moonshotai/kimi-cli/blob/main/examples/custom-tools/README.md Use these commands to prepare the environment and execute the main script for custom tools. ```sh cd examples/custom-tools uv sync --reinstall uv run main.py ``` -------------------------------- ### Example Configuration File (config.toml) Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/configuration/overrides.md Illustrates a TOML configuration file with default model, provider settings, and model definitions. This file is used as a base for overrides. ```toml default_model = "kimi-for-coding" [providers.kimi-for-coding] type = "kimi" base_url = "https://api.kimi.com/coding/v1" api_key = "sk-config" [models.kimi-for-coding] provider = "kimi-for-coding" model = "kimi-for-coding" max_context_size = 262144 ``` -------------------------------- ### QuestionRequest JSON Example Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/wire-mode.md A JSON-RPC example of a QuestionRequest sent by the Agent. ```json {"jsonrpc": "2.0", "method": "request", "id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890", "params": {"type": "QuestionRequest", "payload": {"id": "q-1", "tool_call_id": "tc-1", "questions": [{"question": "Which language should I use?", "header": "Lang", "options": [{"label": "Python", "description": "Widely used, large ecosystem"}, {"label": "Rust", "description": "High performance, memory safe"}], "multi_select": false}]}}} ``` -------------------------------- ### Complete Plugin Manifest Example Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/plugins.md A full plugin.json file defining metadata and tool command mappings. ```json { "name": "sample-plugin", "version": "1.0.0", "description": "Sample plugin demonstrating Skills + Tools", "tools": [ { "name": "py_greet", "description": "Generate a greeting message (Python tool)", "command": ["python3", "scripts/greet.py"], "parameters": { "type": "object", "properties": { "name": { "type": "string", "description": "Name to greet" }, "lang": { "type": "string", "enum": ["en", "zh", "ja"], "description": "Language" } }, "required": ["name"] } }, { "name": "ts_calc", "description": "Evaluate a math expression (TypeScript tool)", "command": ["npx", "tsx", "scripts/calc.ts"], "parameters": { "type": "object", "properties": { "expression": { "type": "string", "description": "Math expression to evaluate" } }, "required": ["expression"] } } ] } ``` -------------------------------- ### GET /api/sessions/{session_id}/git-diff Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/SessionsApi.md Get git diff stats for a session. ```APIDOC ## GET /api/sessions/{session_id}/git-diff ### Description Get git diff stats for a session. ### Method GET ### Endpoint /api/sessions/{session_id}/git-diff ### Parameters #### Path Parameters - **session_id** (string) - Required - The ID of the session. ### Response #### Success Response (200) - **string** - The git diff statistics. #### Response Example ```json { "example": "Git diff output" } ``` ``` -------------------------------- ### Migrate configuration from JSON to TOML Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/release-notes/breaking-changes.md Examples showing the transition from the legacy JSON configuration format to the current TOML format. ```json { "default_model": "kimi-k2-0711", "providers": { "kimi": { "type": "kimi", "base_url": "https://api.kimi.com/coding/v1", "api_key": "your-key" } } } ``` ```toml default_model = "kimi-k2-0711" [providers.kimi] type = "kimi" base_url = "https://api.kimi.com/coding/v1" api_key = "your-key" ``` -------------------------------- ### Run Kimi CLI with Wire Messages Source: https://github.com/moonshotai/kimi-cli/blob/main/examples/kimi-cli-wire-messages/README.md Navigate to the example directory, synchronize dependencies, and run the main Python script to process wire messages with the Kimi Code CLI. ```sh cd examples/kimi-cli-wire-messages uv sync --reinstall uv run main.py ``` -------------------------------- ### Run kimi term with options Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-term.md Example of passing configuration options like working directory and model to the terminal interface. ```sh kimi term --work-dir /path/to/project --model kimi-k2 ``` -------------------------------- ### Manage Installed Plugins Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/plugins.md Commands to list, view details, or remove installed plugins. ```sh kimi plugin list ``` ```sh kimi plugin info my-plugin ``` ```sh kimi plugin remove my-plugin ``` -------------------------------- ### Prepare Kimi CLI Dependencies and Hooks Source: https://github.com/moonshotai/kimi-cli/blob/main/CONTRIBUTING.md Run this command to sync dependencies and install prek hooks for contributing to the Kimi Code CLI project. ```bash make prepare ``` -------------------------------- ### GET /api/sessions/{session_id}/uploads/{path} Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/SessionsApi.md Get uploaded file from session uploads directory. ```APIDOC ## GET /api/sessions/{session_id}/uploads/{path} ### Description Get uploaded file from session uploads directory. ### Method GET ### Endpoint /api/sessions/{session_id}/uploads/{path} ### Parameters #### Path Parameters - **session_id** (string) - Required - The ID of the session. - **path** (string) - Required - The path to the uploaded file within the uploads directory. ### Response #### Success Response (200) - **string** - The content of the uploaded file. #### Response Example ```json { "example": "Uploaded file content" } ``` ``` -------------------------------- ### GET /api/sessions/{session_id}/files/{path} Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/SessionsApi.md Get file or list directory from session work_dir. ```APIDOC ## GET /api/sessions/{session_id}/files/{path} ### Description Get file or list directory from session work_dir. ### Method GET ### Endpoint /api/sessions/{session_id}/files/{path} ### Parameters #### Path Parameters - **session_id** (string) - Required - The ID of the session. - **path** (string) - Required - The path within the session's work directory. ### Response #### Success Response (200) - **string** - The content of the file or a list of directory contents. #### Response Example ```json { "example": "File content or directory listing" } ``` ``` -------------------------------- ### Initialize and Serialize ConfigToml Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/ConfigToml.md Demonstrates how to instantiate a ConfigToml object, convert it to a JSON string, and parse it back into a typed object. ```typescript import type { ConfigToml } from '' // TODO: Update the object below with actual values const example = { "content": null, "path": null, } satisfies ConfigToml console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ConfigToml console.log(exampleParsed) ``` -------------------------------- ### Start ACP Server with Kimi CLI Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-acp.md Initializes a multi-session Agent Client Protocol server for IDE or client communication. ```sh kimi acp ``` -------------------------------- ### Kimi Agent Installation Commands Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/wire-mode.md Shell commands to download and install the Kimi Agent binary for macOS and Linux. ```sh # macOS (Apple Silicon) curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-aarch64-apple-darwin.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ # Linux (x86_64) curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-x86_64-unknown-linux-gnu.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ ``` -------------------------------- ### GET /api/sessions/{sessionId}/files/{path} Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/SessionsApi.md Gets a file or lists a directory from the session's work directory. ```APIDOC ## GET /api/sessions/{sessionId}/files/{path} ### Description Get file or list directory from session work_dir Get a file or list directory from session work directory. ### Method GET ### Endpoint /api/sessions/{sessionId}/files/{path} ### Parameters #### Path Parameters - **sessionId** (string) - Required - The ID of the session. - **path** (string) - Required - The path to the file or directory within the session's work directory. ### Response #### Success Response (200) - **any** - The content of the file or a list of directory contents. #### Response Example ```json { "file_content": "This is the content of the file." } ``` ``` -------------------------------- ### QuestionResponse Interface and Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/wire-mode.md Interface for the client's response to a QuestionRequest, including examples for valid and empty answers. ```typescript interface QuestionResponse { /** 对应的请求 ID */ request_id: string /** 答案映射,键为问题文本,值为选中的选项标签(多选时用逗号分隔) */ answers: Record } ``` ```json {"jsonrpc": "2.0", "id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890", "result": {"request_id": "q-1", "answers": {"Which language should I use?": "Python"}}} ``` ```json {"jsonrpc": "2.0", "id": "b1a2c3d4-e5f6-7890-abcd-ef1234567890", "result": {"request_id": "q-1", "answers": {}}} ``` -------------------------------- ### Update CLI installation and command usage Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/release-notes/breaking-changes.md Update installation commands and CLI entry points following the package rename. ```bash pip install ensoul ``` ```bash pip install kimi-cli ``` ```bash uv tool install kimi-cli ``` ```bash ensoul ``` ```bash kimi ``` -------------------------------- ### Hook Communication Protocol Examples Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/zh/customization/hooks.md Examples of the JSON input received by hooks and the structured JSON output for permission decisions. ```json { "session_id": "abc123", "cwd": "/path/to/project", "hook_event_name": "PreToolUse", "tool_name": "Shell", "tool_input": {"command": "rm -rf /"} } ``` ```json { "hookSpecificOutput": { "hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "请使用 rg 代替 grep" } } ``` -------------------------------- ### Plugin Configuration Format Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/plugins.md Example of a plugin.json file defining plugin metadata and tool definitions. ```json { "name": "my-plugin", "version": "1.0.0", "description": "My custom plugin for project X", "config_file": "config.json", "inject": { "api_key": "api_key", "endpoint": "base_url" }, "tools": [ { "name": "greet", "description": "Generate a greeting message", "command": ["python3", "scripts/greet.py"], "parameters": { "type": "object", "properties": { "name": { "type": "string", "description": "Name to greet" } }, "required": ["name"] } } ] } ``` -------------------------------- ### Session Properties and Example Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/Session.md This snippet details the properties of a session object and provides a TypeScript example for its usage, including serialization and deserialization. ```APIDOC ## Session Properties This section outlines the properties available for a session object. ### Properties Name | Type ------------ | ------------- `sessionId` | string `title` | string `lastUpdated` | Date `isRunning` | boolean `status` | [SessionStatus](SessionStatus.md) `workDir` | string `sessionDir` | string `archived` | boolean ## Session Example This example demonstrates how to use the Session object in TypeScript, including creating an example instance, converting it to a JSON string, and parsing it back. ### Request Example ```typescript import type { Session } from '' // TODO: Update the object below with actual values const example = { "sessionId": null, "title": null, "lastUpdated": null, "isRunning": null, "status": null, "workDir": null, "sessionDir": null, "archived": null, } satisfies Session console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as Session console.log(exampleParsed) ``` ### Response Example ```json { "sessionId": null, "title": null, "lastUpdated": null, "isRunning": null, "status": null, "workDir": null, "sessionDir": null, "archived": null } ``` ``` -------------------------------- ### Display Kimi Code CLI Help Source: https://github.com/moonshotai/kimi-cli/blob/main/README.md Show all available make targets and commands for Kimi Code CLI by running 'make help'. ```sh make help # show all make targets ``` -------------------------------- ### Install kimi-cli with specific Python version Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-term.md Command to install the CLI tool using a specific Python version required for the terminal interface. ```sh uv tool install --python 3.14 kimi-cli ``` -------------------------------- ### TypeScript Usage Example Source: https://github.com/moonshotai/kimi-cli/blob/main/web/src/lib/api/docs/OpenInRequest.md Example demonstrating how to use the OpenInRequest model in TypeScript, including type definition, instantiation, JSON conversion, and parsing. ```APIDOC ## TypeScript Example This example shows how to import and use the `OpenInRequest` type in TypeScript. ### Code ```typescript import type { OpenInRequest } from ''; // TODO: Update the object below with actual values const example: OpenInRequest = { "app": null, "path": null, }; console.log(example); // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example); console.log(exampleJSON); // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as OpenInRequest; console.log(exampleParsed); ``` ``` -------------------------------- ### Basic Kimi Code CLI Usage Source: https://context7.com/moonshotai/kimi-cli/llms.txt Interact with Kimi Code CLI in your project directory. Use /login for first-time API provider setup. Commands can be run interactively or non-interactively. ```bash cd your-project kimi ``` ```bash /login ``` ```bash kimi --print --command "List all Python files in this directory" ``` ```bash kimi --continue ``` ```bash kimi --session ``` ```bash kimi --plan ``` ```bash kimi --yolo ``` ```bash kimi --config-file /path/to/config.toml ``` ```bash kimi --add-dir /path/to/another/directory ``` -------------------------------- ### Switch to Kimi Web UI from Terminal Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/reference/kimi-web.md Execute the /web command in the Kimi Code CLI terminal mode to automatically start the Web UI server and open the current session in the browser. Conversation history will remain synchronized. ```sh /web ``` -------------------------------- ### Specify Working Directory Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/faq.md Set the working directory at startup using the --work-dir flag. ```sh kimi --work-dir /path/to/project ``` -------------------------------- ### Install Kimi Agent (Rust) on macOS Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md Installs the Kimi Agent binary on macOS using curl and tar. Ensure the binary is moved to a directory in your system's PATH. ```sh # macOS (Apple Silicon) curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-aarch64-apple-darwin.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ ``` -------------------------------- ### Clone and Prepare Kimi Code CLI Development Environment Source: https://github.com/moonshotai/kimi-cli/blob/main/README.md Clone the Kimi Code CLI repository and prepare the development environment using the 'make prepare' command. ```sh git clone https://github.com/MoonshotAI/kimi-cli.git cd kimi-cli make prepare # prepare the development environment ``` -------------------------------- ### Install Kimi Agent (Rust) on Linux Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/customization/wire-mode.md Installs the Kimi Agent binary on Linux (x86_64) using curl and tar. Ensure the binary is moved to a directory in your system's PATH. ```sh # Linux (x86_64) curl -L https://github.com/MoonshotAI/kimi-agent-rs/releases/latest/download/kimi-agent-x86_64-unknown-linux-gnu.tar.gz | tar xz sudo mv kimi-agent /usr/local/bin/ ``` -------------------------------- ### Upgrade and Uninstall Source: https://github.com/moonshotai/kimi-cli/blob/main/docs/en/guides/getting-started.md Commands to manage the CLI lifecycle. ```sh uv tool upgrade kimi-cli --no-cache ``` ```sh uv tool uninstall kimi-cli ``` -------------------------------- ### Run kimi-psql with Connection URL Source: https://github.com/moonshotai/kimi-cli/blob/main/examples/kimi-psql/README.md Execute the kimi-psql script using a connection URL that includes the password. Ensure you are in the 'examples/kimi-psql' directory and have synced dependencies. ```sh cd examples/kimi-psql uv sync --reinstall # Connection URL with password uv run main.py --conninfo 'postgresql://user:pass@host/db' ``` -------------------------------- ### View Plugin Details Source: https://context7.com/moonshotai/kimi-cli/llms.txt Shows detailed information about a specific installed plugin, including its version, description, and available tools. ```bash kimi plugin info my-plugin ```