This package is now maintained in the wopr-plugins monorepo.
This repository is archived and no longer accepts contributions.
Moonshot AI Kimi Code CLI provider plugin for WOPR - Self-sovereign AI session management over P2P.
Kimi Code CLI is Moonshot AI's terminal-based AI agent for software development, offering powerful code generation, analysis, and task automation capabilities.
- π Auto-Installation - Automatically installs Python 3.12+, uv, and kimi-cli
- π OAuth Authentication - Secure OAuth2 login flow via Kimi Agent SDK
- π Session Resumption - Resume previous conversations seamlessly
- β‘ Streaming Responses - Real-time token streaming for interactive sessions
- π― YOLO Mode - Auto-approve filesystem operations (enabled by default)
- π§ Kimi K2 Model - Full support for the Kimi K2 model
- πΌοΈ Image Support - Include images in prompts for analysis
- π Multi-Session - Manage multiple concurrent Kimi sessions
- π A2A/MCP Support - Agent-to-Agent communication via MCP server configuration
- Node.js 18+ (for WOPR)
- Python 3.12+ (auto-installed if missing)
- uv (auto-installed if missing)
wopr plugin install wopr-plugin-provider-kimiThe plugin will automatically:
- Check for Python 3.12+ and install via
uvif missing - Install
uv(Python package manager) if not present - Install
kimi-clitool viauv
npm install -g wopr-plugin-provider-kimiThe Kimi provider supports OAuth authentication.
# The plugin uses OAuth - authenticate via Kimi's web flow
wopr providers auth kimiThis will:
- Open your browser to the Kimi OAuth consent page
- Request permissions for code access
- Store the secure token in WOPR's credential store
wopr providers listYou should see kimi with a β
indicating successful authentication.
Create a session with default settings:
wopr session create my-kimi-session --provider kimiwopr session create my-kimi-session \
--provider kimi \
--model kimi-k2 \
--yolo-mode| Option | Type | Default | Description |
|---|---|---|---|
model |
string | kimi-k2 |
Model to use for the session |
workDir |
string | /tmp |
Working directory for the session |
resume |
string | - | Session ID to resume from |
a2aServers |
object | - | A2A/MCP server configuration for agent-to-agent communication |
Note: YOLO mode (auto-approve filesystem operations) is always enabled in the current version.
{
"provider": "kimi",
"model": "kimi-k2",
"workDir": "/home/user/projects",
"a2aServers": {
"my-tools": {
"name": "my-tools",
"version": "1.0.0",
"tools": [
{
"name": "my_tool",
"description": "A custom tool",
"inputSchema": {}
}
]
}
}
}Note: YOLO mode is always enabled in this provider version.
See docs/CONFIGURATION.md for detailed configuration options.
| Model | Description | Best For |
|---|---|---|
kimi-k2 |
Kimi K2 (default) | General coding, analysis, and automation |
Note: Moonshot AI periodically updates available models. Run
wopr providers models kimifor the latest list.
See docs/MODELS.md for detailed model information and capabilities.
One of the most powerful features is the ability to resume previous sessions.
When you create a session, WOPR receives a unique session ID from Kimi:
wopr session create my-session --provider kimi
# Output: Session initialized with ID: sess_abc123xyz# Resume using the session ID
wopr session resume my-session --session-id sess_abc123xyzOr via the configuration resume option:
{
"provider": "kimi",
"model": "kimi-k2",
"resume": "sess_abc123xyz"
}The plugin emits a session_id in the response when a session is created, which you can store for later resumption.
Sessions persist on Moonshot AI's servers for 30 days of inactivity. WOPR automatically:
- Stores session IDs securely
- Handles re-authentication when needed
- Cleans up expired session references
wopr session create coding-task --provider kimi
wopr prompt coding-task "Create a Python function to parse JSON with error handling"wopr prompt my-session "Review this code" \
--system "You are a senior code reviewer. Focus on security and performance."wopr prompt my-session "Describe this image" \
--images ./screenshot.png,./diagram.jpgNote: Images are included in the prompt text as references. The Kimi model will process and analyze the images alongside your text prompt.
YOLO mode is enabled by default in this provider, allowing Kimi to make filesystem changes without requiring manual confirmation for each operation.
wopr session create auto-task --provider kimi
wopr prompt auto-task "Refactor the src/ directory to use TypeScript"Note: YOLO mode is enabled by default for streamlined automation workflows. Use only in version-controlled environments where changes can be reviewed and reverted if needed.
Check the examples/ directory for complete configuration examples:
- examples/basic.json - Basic setup
- examples/yolo-mode.json - Automated workflows
- examples/multi-model.json - Multi-model orchestration
Kimi CLI not found
# Re-run the installation
wopr plugin reinstall wopr-plugin-provider-kimiOAuth authentication failed
# Reset credentials and re-authenticate
wopr providers remove kimi
wopr providers auth kimiSession resumption failed
- Sessions expire after 30 days of inactivity
- Check if the session ID is correct
- Some sessions may be invalidated server-side
See docs/TROUBLESHOOTING.md for comprehensive troubleshooting.
- π Installation Guide - Detailed setup instructions
- βοΈ Configuration Reference - All configuration options
- π€ Model Information - Available models and capabilities
- π§ Troubleshooting - Common issues and solutions
This plugin uses the @moonshot-ai/kimi-agent-sdk to interact with the Kimi AI service. Key components:
- KimiClient: Implements the WOPR
ModelClientinterface - Session Management: Creates and manages Kimi sessions with automatic session ID tracking
- A2A/MCP Integration: Converts WOPR A2A server configs to Kimi MCP format
- Streaming: Real-time token streaming via async generators
# Clone the repository
git clone https://github.com/TSavo/wopr-plugin-provider-kimi.git
cd wopr-plugin-provider-kimi
# Install dependencies
npm install
# Build
npm run build@moonshot-ai/kimi-agent-sdk- Official Kimi Agent SDKwinston- Logging
This plugin is part of the WOPR ecosystem:
| Package | Description |
|---|---|
| wopr | Core WOPR CLI |
| wopr-plugin-router | Intelligent model routing |
| wopr-plugin-p2p | P2P session synchronization |
| wopr-plugin-webui | Web UI for WOPR |
MIT Β© TSavo
Contributions welcome! Please read the WOPR Contributing Guide first.
- π Report Issues
- π¬ Discussions
- π§ Contact: See WOPR repository