手册
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.
/sessions /sessions
/resume
/continue
Opens the session picker. Use arrow keys to switch between current-project and all-project sessions.
/task-policy /task-policy
/task-policy compaction
/task-policy extra-on
/task-policy extra-off
/task-policy extra-status
Opens the local TUI task-route table. extra-on/extra-off toggles the extra task router; extra-status shows current state. Does not call the model or inject the table into conversation.
/permissions /permissions Opens the project permission policy panel. Choose Trust All, Safe, Ask Everything, Readonly, or Reset. Writes to ./.openchinacode/openchinacode.jsonc and applies a runtime override immediately.
/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.
/media-auth /media-auth
/media-auth <ARK_API_KEY>
Saves the Volcengine Ark API key for native image and video generation.
/image-generate /image-generate
/image-generate a cyberpunk cat mascot
Opens the ByteDance Seedream 5.0 Pro image generation wizard with optional inline prompt.
/video-generate /video-generate
/video-generate a 5s product promo
Opens the ByteDance Seedance 2.0 Mini video generation wizard with optional inline prompt.

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 } } } }

Extra Task Router

When enabled, ordinary prompts pass through a fast LLM judge that can automatically insert a routed subtask — no explicit /task call needed. Disabled by default.

Base

System-level base routing

Explicit task/subagent calls trigger the built-in route table — GLM for planning, Kimi for speed, DeepSeek for debug.

Extra

Extra smart dispatch

A fast judge (DeepSeek V4 Flash) inspects each ordinary prompt and inserts a subtask with task_kind + complexity when delegation is appropriate.

Control

Toggle and configure

Use /task-policy extra-on / extra-off / extra-status, or set task_policy.extra_router.enabled in config.

{ "task_policy": { "extra_router": { "enabled": true, "confidence_threshold": 0.7, "allow": ["plan", "refactor", "review", "debug", "test_fix"], "deny": ["general", "summarize", "compaction"] } } }

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

Session Management

Open the session picker with /sessions (aliases /resume, /continue). Use arrow keys to switch scope.

Scope

Arrow-key scope switch

Press / to toggle between Current Project (with pin/unpin) and All Projects (global session list).

Cross-project

Cross-project fork

Selecting another project's session offers: open the original project, or fork the session into the current directory.

Manage

Delete and rename

Delete (with confirmation) and rename are available for any session in either scope.

/sessions /resume /continue

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.

Native Media Generation

OpenChinaCode can generate images and videos through Volcengine Ark, powered by ByteDance Seedream 5.0 Pro and Seedance 2.0 Mini.

Auth

Volcengine Ark credentials

Run /media-auth in the TUI, or set the ARK_API_KEY environment variable. The key is stored in ~/.local/share/openchinacode/auth.json under provider volcengine-ark.

Image

ByteDance Seedream 5.0 Pro

Up to 2K resolution, 1:1 to 21:9 aspect ratios, up to 10 reference images (local paths, URLs, or data URIs), PNG or JPEG output.

/image-generate /image-generate a cyberpunk cat mascot, neon pink, clean vector style
Video

ByteDance Seedance 2.0 Mini

4–15 second clips, 480p or 720p, adaptive to 21:9 ratios, up to 9 reference images, 3 reference video URLs, strict first/last frame control, and generated audio.

/video-generate /video-generate a 5s product promo, slow dolly-in, tech but not flashy
Trigger

Natural language or slash command

Describe what you want in plain language, or run /image-generate / /video-generate with an optional prompt. When key parameters are missing, the agent asks follow-up questions instead of guessing. Generated files are downloaded immediately to /tmp/openchinacode/media/images and /tmp/openchinacode/media/videos with matching metadata JSON.

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/