pcli terminal coding agent with hosted gateway registration
Project description
pcli
pcli is a modular terminal coding agent for Kimi-compatible models. It can connect to the hosted pcli gateway with invite-code registration, or to a local OpenAI-compatible proxy for development. The project is split into:
pcli_kimi.py: main CLI/TUI entrypointkimi_openai_proxy.py: local proxy that exposes/v1/chat/completionspcli/: reusable runtime modules for tools, UI, session handling, streaming, resilience, and API plumbing
The default CLI runtime uses the proxy at http://127.0.0.1:8765/v1.
What It Does
- Chat with Kimi from the terminal
- Run tools with confirmation for risky operations
- Read, edit, append, delete, and summarize files
- Search files and the web
- Attach local files, images, and PDFs
- Save and resume sessions
- Track tool loops, query chains, planner state, and reflection checks
- Use either the freebuff TUI or a classic terminal layout
Requirements
- Python 3.8+
- CLI dependencies from the base package
- Playwright Chromium only for the proxy runtime
End-user CLI install:
pip install "kimi-pcli[ui]"
or:
uv tool install "kimi-pcli[ui]"
Proxy install:
pip install "kimi-pcli[proxy]"
python3 -m playwright install chromium
Quick Start
1. Register or log in to the hosted gateway
pp-cli
Inside the CLI:
/register
Enter the gateway URL, email, password, and invite code from your administrator. The default gateway is:
https://pcli.tranlequybaotk12.workers.dev/v1
Existing users can reconnect with:
/login
2. Start the local proxy for development
Default fast IPv4 native mode:
python3 kimi_openai_proxy.py
This starts the proxy with native aiohttp, browser release after credential
refresh, and IPv4-only upstream transport enabled by default.
Legacy browser-backed mode:
KIMI_PROXY_NATIVE_CLIENT=0 python3 kimi_openai_proxy.py
Native mode with dual-stack DNS if IPv4-only is not desired:
KIMI_PROXY_NATIVE_IPV4_ONLY=0 python3 kimi_openai_proxy.py
Useful proxy flags:
python3 kimi_openai_proxy.py --port 8765 --ws-port 8766
3. Start the CLI
pp-cli
If you run the CLI in a TTY with ui_style=freebuff, it starts the freebuff TUI automatically. Otherwise it falls back to the classic text UI.
Hosted gateway mode:
PCLI_BASE_URL="https://<gateway-domain>/v1" \
PCLI_API_KEY="<gateway-user-token>" \
pp-cli
Configuration and State
The CLI bootstrap creates and uses ~/.code_assistant/ by default:
~/.code_assistant/config.json~/.code_assistant/sessions/~/.code_assistant/backups/~/.code_assistant/logs/
Session browser state for the proxy lives under .webchat_state/kimi/.
Common config keys live in pcli/config/settings.py. The important defaults are:
model:kimi-k2.6base_url:http://127.0.0.1:8765/v1ui_style:freebuffauto_context_compact:trueauto_save:true
Example config:
{
"model": "kimi-k2.6",
"base_url": "http://127.0.0.1:8765/v1",
"ui_style": "freebuff",
"auto_context_compact": true
}
CLI Usage
Use /help inside the CLI for the full command list. The common commands are:
/help,/tools,/files/model,/ui,/set/clear,/save,/sessions,/load/backups,/restore/autoyes,/risk/context,/chain,/plan,/autoplan/reflect,/watchdog,/hooks,/warm/exit
The CLI supports:
- multiline input and bracket paste
- session save/resume
- file attachment parsing
- tool call rendering in both TUI and classic layouts
- auto-confirm for safe operations and guided confirmation for risky ones
Proxy API
The proxy is OpenAI-compatible and serves the CLI at /v1.
Common endpoints:
GET /healthGET /metricsGET /kimi/statsGET /kimi/native
If native mode is enabled, the proxy also exposes runtime controls for the native client path. See doc/PHASE3_DEPLOY_GUIDE.md for the full deployment and rollback flow.
For an internal alpha, put an access gateway in front of the hosted Fly proxy so
each developer receives an individual token. See
doc/ACCESS_GATEWAY_DESIGN.md and
doc/PYPI_FLY_DEPLOY.md.
Environment Variables
CLI
PCLI_KIMI_SESSION_ID: override the per-session proxy header valuePCLI_BASE_URL: overridebase_urlwithout editing configPCLI_API_KEY: overrideapi_keywithout editing configPCLI_MODEL: override model without editing configPCLI_AGENT_DEBUG=1: enable agent/tool-loop debug logging
Proxy
KIMI_PROXY_AUTH_TOKEN: requireAuthorization: Bearer <token>orX-API-KeyKIMI_PROXY_NATIVE_CLIENT=1: enable the native aiohttp pathKIMI_PROXY_NATIVE_IPV4_ONLY=1: force native upstream requests to IPv4KIMI_PROXY_NATIVE_MAX_INFLIGHT=2: cap concurrent native requestsKIMI_PROXY_NATIVE_RELEASE_BROWSER=1: release Playwright resources after refreshKIMI_PROXY_DEBUG_PHASE3=1: verbose native routing logs
See doc/PHASE3_DEPLOY_GUIDE.md for the full native-mode environment matrix.
Testing
Run the test suite:
pytest -q
Useful focused checks:
python3 -m py_compile pcli_kimi.py kimi_openai_proxy.py
pytest tests/test_kimi_proxy.py -q
Compare Playwright vs native path on a running proxy:
python3 bench/native_vs_playwright.py --repeats 3
Benchmarks and Docs
doc/USER_GUIDE.mddoc/DEVELOPER_GUIDE.mddoc/ARCHITECTURE.mddoc/PYPI_FLY_DEPLOY.mddoc/PHASE3_DEPLOY_GUIDE.mddoc/PERFORMANCE_IMPROVEMENT_PLAN.mddoc/CHANGELOG_PERF.mdbench/run_bench.pybench/phase3_acceptance.pybench/fast_tool_accuracy.pybench/latency_probe.py
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kimi_pcli-0.1.0a5.tar.gz.
File metadata
- Download URL: kimi_pcli-0.1.0a5.tar.gz
- Upload date:
- Size: 416.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a9e2326def20a8ae9bed63d291fe14c196ce8a289c9500d65a9f9050b28e74
|
|
| MD5 |
2bb7cdc1d83109706645e0c94762e716
|
|
| BLAKE2b-256 |
92030dc1d4a295690030ec540e6f8c97e8d36019faa18a958e69562a4c71e807
|
File details
Details for the file kimi_pcli-0.1.0a5-py3-none-any.whl.
File metadata
- Download URL: kimi_pcli-0.1.0a5-py3-none-any.whl
- Upload date:
- Size: 358.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6f403d58fc4d32a91064b3d66b89e4313ed78782248c92577b4b418338e3d7e
|
|
| MD5 |
80e005e7943547dcdf55185435661b78
|
|
| BLAKE2b-256 |
91fc44f1cdf3605cedd26893acc3310c7e04b185a23d687f768d3438dd0b2b35
|