手册
USAGE & CONFIGURATION GUIDE

OpenChinaCode Manual

This page covers the OpenChinaCode-specific workflow: GLM/Kimi/DeepSeek provider setup, custom slash commands, task policy routing, smart compaction, LSP diagnostics, and Playwright testing.

Quick Start

OpenChinaCode installs as a separate command, so it can coexist with upstream opencode.

Install

Install the binary

curl -fsSL https://openchinacode.muffin-labs.com/install | bash
Auth

Add provider credentials

openchinacode providers login --provider zhipuai-pay2go openchinacode providers login --provider moonshotai-cn openchinacode providers login --provider deepseek
Run

Start in a project

cd /path/to/project openchinacode

Configuration Files

OpenChinaCode uses independent config and data paths. Do not put API keys in the repository.

Global

User config

~/.config/openchinacode/openchinacode.jsonc

Use this for personal defaults: model, task policy overrides, LSP, compaction, and MCP.

Auth

Local credentials

~/.local/share/openchinacode/auth.json

Written by openchinacode providers login. File mode is restricted when written by the CLI.

Project

Project overrides

./openchinacode.jsonc ./.openchinacode/openchinacode.jsonc

Use this when one codebase needs a different task policy or testing setup.

Auth file shape

{ "zhipuai-pay2go": { "type": "api", "key": "YOUR_GLM_API_KEY" }, "moonshotai-cn": { "type": "api", "key": "YOUR_KIMI_API_KEY" }, "deepseek": { "type": "api", "key": "YOUR_DEEPSEEK_API_KEY" } }

Main provider IDs

Provider Purpose Protocol Notes
zhipuai-pay2go GLM / BigModel pay-as-you-go OpenAI compatible Base URL is fixed to https://open.bigmodel.cn/api/paas/v4.
moonshotai-cn Kimi / Moonshot China OpenAI compatible Used for fast implementation, review, summarize, and quick routes.
deepseek DeepSeek official API OpenAI compatible Used for debug/test-fix loops and low-cost judge paths.

Custom Slash Commands

OpenChinaCode-specific commands are grouped under OpenChinaCode in the TUI command palette.

Command Usage Effect
/auto-maxtokens /auto-maxtokens heuristic
/auto-maxtokens llm deepseek/deepseek-v4-flash
Controls sliding output-token budgeting. Heuristic is the recommended daily mode; LLM mode uses a low-cost judge for ambiguous turns.
/compact /compact
/compact keep 3
/compact keep auto
Runs smart compaction. keep N also preserves the latest N raw user turns and follow-up assistant/tool messages.
/lsp /lsp status
/lsp on
/lsp off
Enables language-server diagnostics so the model can see and fix type, syntax, and reference errors.
/task-policy /task-policy
/task-policy compaction
Opens the local TUI task-route table. It does not call the current model and does not inject the table into the conversation.
/task-classify /task-classify do a full code review Asks the current model to explain task kind, complexity, route, and classification signals.
/test-mcp /test-mcp on
/test-mcp headed
/test-mcp off
Writes Playwright MCP config and hot-connects or disconnects it from inside the TUI.
/browser-check /browser-check http://127.0.0.1:5173 Prompts the agent to run browser-level checks, preferably through Playwright MCP.
/integration-test /integration-test check login flow Prompts the agent to use the OpenChinaCode integration-test workflow: run, inspect report, define bug, fix, rerun.

Task Routing Policy

Subagents are routed by task kind and complexity. General tasks inherit the parent model; specialized tasks use opinionated GLM/Kimi/DeepSeek defaults.

Task kind Quick Medium Complex
generalinheritinheritinherit
planGLM-5.2 highGLM-5.2 highGLM-5.2 max
architectureGLM-5.2 highGLM-5.2 highGLM-5.2 max
refactorGLM-5.2 highGLM-5.2 highGLM-5.2 max
reviewKimi K2.7 highspeedKimi K2.7 highspeedGLM-5.2 high
implementKimi K2.7 highspeedKimi K2.7 highspeedGLM-5.2 high
exploreKimi K2.7 highspeedGLM-5.2 highGLM-5.2 max
visual_checkGLM-5V TurboGLM-5V TurboGLM-5V Turbo
debugDeepSeek V4 ProDeepSeek V4 ProDeepSeek V4 Pro
test_fixDeepSeek V4 ProDeepSeek V4 ProDeepSeek V4 Pro
summarizeKimi K2.7 highspeedKimi K2.7 highspeedGLM-5.2 high
compactionGLM-5.2 highGLM-5.2 highGLM-5.2 high

Override example

Put this in ~/.config/openchinacode/openchinacode.jsonc or in a project-level OpenChinaCode config.

{ "task_policy": { "enabled": true, "routes": { "review.complex": { "model": "zhipuai-pay2go/glm-5.2", "variant": "high" }, "explore.quick": { "model": "moonshotai-cn/kimi-k2.7-code-highspeed" }, "visual_check": { "model": "zhipuai-pay2go/glm-5v-turbo" }, "general": { "inherit": true } } } }

Smart Compaction

OpenChinaCode compaction is routed through task policy and defaults to zhipuai-pay2go/glm-5.2#high. It uses three layers: general summary, active-task extraction, and minimal raw recent tail.

Strategy

Profile-aware summary

A judge model first emits a stable JSON profile, then OpenChinaCode builds a fixed Markdown compaction prompt from that profile.

Recent

Active task extraction

The recent active task is extracted at higher granularity than the general summary, so long debugging or refactor context survives.

Manual

Raw tail retention

/compact keep N asks OpenChinaCode to keep the latest N raw user turns and their following assistant/tool messages.

/compact /compact keep 3 /compact keep auto

LSP and Browser Testing

LSP

Diagnostics in coding turns

Use /lsp on. When enabled, language-server diagnostics can be fed into the model during code edits.

MCP

Playwright from the TUI

Use /test-mcp on. This writes Playwright MCP config and hot-connects it without leaving OpenChinaCode.

Vision

Screenshot interpretation

Visual checks route to zhipuai-pay2go/glm-5v-turbo. Animation checks should prefer DOM/CSS telemetry and pixel diffs.

Debugging and Observability

Subagent rows in the TUI show the selected provider, model, variant, task classification, and route source.

-> zhipuai-pay2go/glm-5.2#high - review.complex - openchinacode.default
Route

Subagent route logs

tail -f ~/.local/share/openchinacode/log/openchinacode.log | grep --line-buffered "subagent route"
Compact

Compaction profile logs

tail -f ~/.local/share/openchinacode/log/openchinacode.log | grep --line-buffered "compaction profile"
Test

Integration report

openchinacode test init openchinacode test run ls .openchinacode/reports/