Conversation
Jovan1666
added a commit
to Jovan1666/zcode-command-code-usage
that referenced
this pull request
Sep 20, 2026
问题:自定义命令本质是一段 prompt,查额度反而要烧一轮对话,与"省额度"的目的相悖。 实测单次 /quota 约 680 tokens。 优化(两处零风险改动): - 命令正文 731 -> 311 字符(约 243 -> 103 tokens):去掉冗余说明 - 明确要求 agent 不要复述面板:工具调用的输出本就显示在界面上, 回复改为 1-3 行结论(约 177 -> 40 tokens) 优化后约 390 tokens/次,省约 43%。 同时把成本分析和零 token 方案写进中英文 README: - ZCode 没有给插件留应用内组件位;hook 渲染的记录只有状态/耗时/名称, 没有输出字段,因此 hook 也无法显示内容(已在 zcode.cjs 核对) - 命令正文的内联 shell 展开确实存在,但 Windows 上用的是 cmd.exe 而非 bash, 只有写死路径才可用、走市场安装会硬失败,故未采用 - 唯一零 token 方式:--serve 当本地页面在内置浏览器面板里打开,每 30s 刷新 版本 1.2.0,同步更新官方市场 PR zai-org/zcode-plugins#19。
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / 改动内容
Adds command-code-usage v1.1.0 to the marketplace: a panel that shows a user's Command Code
plan usage — the 5-hour rolling window, the weekly rolling window, and the monthly credits or
balance — rendered in the conversation.
The plan's two rolling windows are the reason this exists. They open on the first request and reset
a fixed time later, so the monthly balance alone cannot answer "can I still finish this task?".
The panel adds a remaining-requests estimate (remaining allowance ÷ your own average cost per
request) and a burn-rate warning for windows projected to run out before they reset.
Components: commands
/quotaand/usage, plus acommand-code-usageskill. No hooks, no MCPservers, no agents, no background processes.
Visible behavior and how it was tested
/alphaendpoints, all output modes(terminal,
--md,--compact,--json,--from-json, optional HTML/serve), credentialresolution from all three sources, and every error path (no credentials, invalid key, network
failure).
balance, organisation spend caps, and a period with no requests yet.
scripts/verify-discoverable.cjs, which re-implements theclient's own command parser — 2 commands found, 0 diagnostics.
and macOS; that matrix runs a release gate, offline smoke tests, an install-and-discover check
against a throwaway HOME, and the installer's conflict guard.
Version and marketplace registration
plugins/command-code-usage/.zcode-plugin/plugin.jsonversion1.1.0marketplace.jsonentry version1.1.0,source./plugins/command-code-usagedescription_i18nis identical in both (verified byvalidate.py)category:utilitiesDependencies, network requests, permissions, side effects
PATH. Scripts use only Node built-ins and globalfetch; nothing toinstall.
https://api.commandcode.ai(/alpha/whoami,/alpha/billing/credits,/alpha/billing/subscriptions,/alpha/usage/summary). No other host,no telemetry, no proxying.
COMMAND_CODE_API_KEY/CMD_API_KEY/COMMANDCODE_API_KEY,~/.commandcode/auth.json, or theprovider already configured in ZCode. It is only placed in an
Authorization: Bearerheader —never written, printed, logged, or transmitted elsewhere. The plugin contains no credentials.
--htmlwrites one HTMLfile to a user-chosen path, and
--servebinds a local HTTP server to127.0.0.1; both areopt-in flags.
scripts/install-user-scope.mjswrites into~/.zcode/commandsand~/.zcode/skillsfor users who prefer a non-marketplace install, and keeps a manifest so it canupdate or remove them.
node <plugin>/scripts/cc-usage.mjs. That is the onlyprocess started.
Licensing and provenance
All code is original, MIT-licensed, and written for this plugin — no third-party code, assets, or
services are bundled. The icon in
assets/command-code-usage/icon.pngis generated byscripts/make-icon.mjsin the source repository (pure geometry drawn with Node built-ins), so itis reproducible rather than supplied by a third party.
Related upstream repository: https://github.com/Jovan1666/zcode-command-code-usage (MIT).
Self-check / 自查清单
plugins/command-code-usage/versionis1.1.0in BOTHplugin.jsonandmarketplace.jsonREADME.md(EN) andREADME_CN.md(中文) both present and equivalent in structuredescription_i18nhas bothenandzh-CN, identical in manifest and marketplace entrypython3 scripts/validate.py→OK: 27 plugin(s) validatedpython3 scripts/build_dist.py→ buildsplugins/command-code-usage/1.1.0/plugin.zipgit diff --check→ cleanUpdate: version bumped to 1.2.0. The command body was cut from 731 to 311 characters and the agent is now told not to restate the panel (it is already visible from the tool call), cutting the token cost of one
/quotafrom about 680 to about 390. Both READMEs document the cost and the zero-token alternative (--servein the built-in browser pane).validate.py→OK: 27 plugin(s) validated,build_dist.pyandgit diff --checkpass.