Introduction¶
When using the ctrip model provider to run conversations or agents in DeepSeek Harness (DSH), aligning the billing cycle usage and the rolling 5-hour window of the Coding Plan often requires opening separate pages or checking the console. During a conversation, if the quota approaches the limit or the 5-hour window caps out, the lack of proximal feedback can lead to request failures before the issue is discovered. The following introduces the community plugin dsh-coding-plan-balance (maintainer zq0929). It renders the quota as a capsule below the input box on the Web interface and reuses the same API Key already configured for ctrip in your profile. The key remains in the Host process; only the numbers are displayed on the page.
What is this¶
dsh-coding-plan-balance is a network-dependent plugin for DSH (community directory SkillHub entry). In one sentence: it registers a persistent capsule at conversation.composer.dock to display current billing cycle usage/limit (USD), usage percentage, and rolling 5-hour window usage. Data is sourced from the Coding Plan upstream API, using the same credentials as the ctrip provider. The current npm package version is 1.0.1, License MIT (© 2026 zq0929).
Example capsule line (from the repository README):
◔ $50 Plan · $0.13 / $50.00 · 0% · 5h $0.00 / $50.00
Core Features¶
Interface and Interaction¶
The plugin injects a capsule into conversation.composer.dock via the Client side (client.js), placed side-by-side with DSH’s native activity/usage capsules without occupying the main conversation area. At a glance, you can see: plan name, cycle usage/limit, percentage, and 5h window usage. Hovering reveals details such as plan status, remaining quota, cycle reset time, 5h window end time, and the time of the last data fetch. Clicking the capsule forces a fresh data pull (?refresh=1); otherwise, it auto-polls based on the interval下发 by the Host, defaulting to 60 seconds. Polling utilizes a Host-side snapshot reuse window (default 10 seconds); when multiple browser sessions are watching simultaneously, upstream requests are merged to avoid redundant hits on the API.
Styles and text depend on --dsw-alias-* theme tokens (for light/dark themes) and Client locale (Chinese/English) respectively.
Host Routes and Agent Tools¶
The Host side (index.js) resolves credentials and calls upstream /api/coding-plan/quota/me, /api/coding-plan/5h-usage, and /api/user/api-tokens/userinfo (the first is required for cycle quota, the other two are best-effort). It normalizes this into a single snapshot and registers it via ctx.connection.fetch.register() at /api/coding-plan.balance. Authentication, Host/Origin validation, and browser session cookies are handled uniformly by the Connection; requests without a session return 401.
The same read path is also registered as an agent tool coding_plan_balance (config option tool defaults to true). You can directly ask “how much quota is left,” and it shares the same snapshot as the UI click, avoiding logic duplication.
Behavior on Failure¶
If the Key is not configured, the network is unreachable, or the quota is blocked, the capsule does not disappear. Instead, it displays the reason in place, with the numbers using the theme’s warning/error colors.
Installation and Activation¶
Choose one of the installation methods officially supported by DSH:
- Web GUI: Settings → Plugins → Add Plugin, enter
https://github.com/zq0929/dsh-coding-plan-balance - Command Line:
dsh plugin add https://github.com/zq0929/dsh-coding-plan-balance
- Local Development: Clone the repository and enter the absolute directory path in “Add Plugin”. Changes to
index.jstrigger a Loader-side rebuild, and changes toclient.jstrigger a Client module graph rebuild.
After installation, you must refresh the page for the browser-side modules to take effect.
The plugin runs with the current dsh process permissions; it is recommended to review the source code and MIT license on GitHub before installing to ensure compliance with your environment policies.
Credentials¶
The plugin does not add independent key configuration items. By default, it reuses the Key used by the ctrip model provider in the profile. The resolution order is:
config.apiKey(explicit configuration, highest priority)ctx.credentials.resolve(config.apiKeyEnv)—— covers process environment variables, provider credential libraries,.env. The default environment variable name isCTRIP_API_KEYprocess.env[config.apiKeyEnv]
If the provider uses a different variable name, simply change apiKeyEnv to the corresponding name in the profile’s cordis.patch.yml. The token must be bound to an active Coding Plan subscription.
Configuration¶
Override settings in the profile’s cordis.patch.yml by line id (the profile layer is applied after the bundle layer):
- id: coding-plan-balance
config:
apiKeyEnv: MY_CTRIP_KEY
refreshSeconds: 120
| Field | Default | Description |
|---|---|---|
baseUrl |
https://ada-cli-go.ctripcorp.com |
Main Coding Plan API domain |
fallbackBaseUrl |
http://ada-cli-golang.ctripcorp.com |
Fallback when the main domain is unreachable; leave empty to disable fallback |
apiKeyEnv |
CTRIP_API_KEY |
Credential name |
apiKey |
Empty | Explicit key, takes precedence over apiKeyEnv |
refreshSeconds |
60 |
Page polling interval; values less than 20 are treated as 20 |
cacheSeconds |
10 |
Host-side snapshot reuse window |
timeoutMs |
8000 |
Timeout for a single upstream request |
routePath |
/api/coding-plan.balance |
Host route for the page to read quota (must start with /api/) |
tool |
true |
Whether to register the coding_plan_balance tool |
Typical Usage¶
Checking Quota Daily¶
Open the DSH Web conversation page and locate the Coding Plan capsule below the input box. Click the capsule for instant data; otherwise, wait for the default ~60-second auto-refresh. Hover to view reset times and 5h window details.
Let the Agent Read Quota¶
With the coding_plan_balance tool enabled, ask about remaining quota or cycle usage in the conversation. The agent will use the same Host route as the UI and return the same snapshot JSON.
Scenarios and Notes¶
Suitable for: Developers who have already configured the ctrip provider in their DSH profile, are using a Coding Plan personal subscription, and whose environment can access *.ctripcorp.com (intranet or proxy).
Limitations (from the repository README):
- Read-only personal quota; interfaces requiring broader permissions (like team plan details or team AI code statistics) are out of scope.
- For the 5-hour window, when
source: none(no costs yet, no active window), the upstream returns fallback display values for window times; therefore, the plugin does not display “Window End”. - An upstream field
limit_usdof 0 indicates no limit is configured; the interface displays “Unlimited”. - The repository CI performs static validation (syntax, manifest, id, language files, icons) but has no browser visual regression testing.
The DSH ecosystem emphasizes “Everything is a plugin”; SkillHub is a community directory site and has no official affiliation with DeepSeek or High-Flyer.
Conclusion¶
dsh-coding-plan-balance integrates Coding Plan cycle usage and the 5h window into the Web composer dock. It shares credentials with ctrip, keeps keys within the Host, and optionally provides the agent with the same read-only quota query capability. For installation or source code details, see the GitHub Repository and the SkillHub Directory Page.