================================================================================
  SindByte MCP Server -- Kimi Code CLI Setup Guide
  Connecting Moonshot Kimi Code to Your Local Endpoint
================================================================================
Date: 2026-04-17
For: SindByte Server v1.9.09

--------------------------------------------------------------------------------
 1. WHAT IS KIMI CODE CLI?
--------------------------------------------------------------------------------
Kimi Code CLI is Moonshot AI's official terminal-based coding assistant.
It is NOT the same as Kimi CLI (the chat tool) or any other tool.

  Official source:   https://www.kimi.com/code
  Install command:   npm install -g @anthropic/kimi-cli
                     (or curl -fsSL https://kimi.com/code/install.sh | bash)
  Config file:       ~/.kimi/settings.json

--------------------------------------------------------------------------------
  2. REQUIRED INFORMATION
--------------------------------------------------------------------------------
  SindByte Base URL:   http://127.0.0.1:8091/v1
  API Key:             sk-sindbyte-local   (or any text -- not checked)

  IMPORTANT: SindByte must be running before you start Kimi Code.

--------------------------------------------------------------------------------
 3. INSTALL KIMI CODE CLI
--------------------------------------------------------------------------------
  STEP 1 -- Open PowerShell and install:

    npm install -g @anthropic/kimi-cli

    Or use the official install script:
    curl -fsSL https://kimi.com/code/install.sh | bash

  STEP 2 -- Verify installation:

    kimi --version

--------------------------------------------------------------------------------
 4. CONFIGURE KIMI CODE FOR SINDBYTE
--------------------------------------------------------------------------------
Kimi Code uses OPENAI-compatible environment variables.

  STEP 1 -- Set these environment variables in your terminal:

    set KIMI_API_KEY=sk-sindbyte-local
    set KIMI_BASE_URL=http://127.0.0.1:8091/v1

  STEP 2 -- Make permanent (Windows):
    Win+R -> sysdm.cpl -> Advanced -> Environment Variables
    Add:
      KIMI_API_KEY   = sk-sindbyte-local
      KIMI_BASE_URL  = http://127.0.0.1:8091/v1

  STEP 3 -- Start Kimi Code in your project folder:

    cd "[your-project-path]"
    kimi

--------------------------------------------------------------------------------
 5. ALTERNATIVE: CONFIG FILE SETUP
--------------------------------------------------------------------------------
You can also configure Kimi Code via its JSON settings file:

  STEP 1 -- Create or edit the config:

    mkdir "%USERPROFILE%\.kimi" 2>$null
    notepad "%USERPROFILE%\.kimi\settings.json"

  STEP 2 -- Paste this config:

    {
      "modelProviders": {
        "openai": [
          {
            "id": "LMDirect",
            "name": "SindByte LMDirect",
            "baseUrl": "http://127.0.0.1:8091/v1",
            "description": "SindByte MCP Server via OpenAI-compatible API",
            "envKey": "KIMI_API_KEY"
          }
        ]
      },
      "env": {
        "KIMI_API_KEY": "sk-sindbyte-local"
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "LMDirect"
      }
    }

  STEP 3 -- Save and start Kimi Code:

    kimi

--------------------------------------------------------------------------------
 6. USING IQ TOOLS WITH KIMI CODE
--------------------------------------------------------------------------------
Kimi Code does not have built-in IQ profile selection.
To use IQ Tools, either:

  OPTION A -- Set the default IQ profile in SindByte Config
    1. Open SindByte tray icon -> Config
    2. Find API Provider -> Default IQ Profile
    3. Set to "default", "research", or "trading"
    4. Save and restart SindByte

  OPTION B -- Use an IQ model alias in the config file:

    Change the model name from "LMDirect" to:
      "iq/full"      -- Full IQ pipeline
      "iq/research"  -- Web research + CoT
      "iq/trading"   -- Trading tools
      "iq/minimal"   -- Auto-expert only
      "iq/off"       -- Direct chat, no IQ

--------------------------------------------------------------------------------
 7. TROUBLESHOOTING
--------------------------------------------------------------------------------

  PROBLEM: "kimi command not found"
  FIX:     Make sure npm global bin is in your PATH.

  PROBLEM: "Cannot connect" or "Connection refused"
  FIX:     Verify SindByte is running on port 8091.

  PROBLEM: Kimi asks for OAuth login
  FIX:     Make sure KIMI_BASE_URL is set. If using the config file,
           make sure "security.auth.selectedType" is "openai".

  PROBLEM: "Model not found"
  FIX:     Use one of the exact SindByte model aliases (LMDirect, iq/full, etc.)

--------------------------------------------------------------------------------
 8. QUICK REFERENCE
--------------------------------------------------------------------------------
  | Setting          | Value                                  |
  |------------------|----------------------------------------|
  | Tool             | Kimi Code CLI (npm: @anthropic/kimi-cli) |
  | Base URL         | http://127.0.0.1:8091/v1               |
  | API Key          | sk-sindbyte-local                      |
  | Env var (URL)    | KIMI_BASE_URL                          |
  | Env var (Key)    | KIMI_API_KEY                           |
  | Config file      | ~/.kimi/settings.json                  |
  | IQ Timeout       | 3600 sec (1 hour)                      |

================================================================================
  END OF GUIDE
================================================================================
