Skip to content

feat(zcode-token-usage-statusbar): add token usage statusbar plugin - #119

Open
ByteRax wants to merge 1 commit into
zai-org:mainfrom
ByteRax:feat/zcode-token-usage-statusbar
Open

ByteRax wants to merge 1 commit into
zai-org:mainfrom
ByteRax:feat/zcode-token-usage-statusbar

Conversation

@ByteRax

@ByteRax ByteRax commented Oct 23, 2026

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin / 是 UI 插件 — provides MCP Apps interactive pages / 提供 MCP Apps 交互页面
  • Standard plugin / 普通插件(非 UI) — does not provide MCP Apps interactive pages / 不提供 MCP Apps 交互页面
  • Not applicable / 不适用 — repository-only changes; no plugin content changed / 仅仓库级改动,不涉及插件内容

Affected plugin name(s) / 涉及的插件名称:zcode-token-usage-statusbar

No ui.surfaces, no _meta.ui.resourceUri; the MCP server and the renderer-bridge status bar do not provide MCP Apps pages.

What / 改动内容

New community plugin zcode-token-usage-statusbar v1.5.3, registered under external_plugins/ with category developer-tools.

User problem it solves / 解决的用户问题: ZCode's UI shows no token usage, model speed, context consumption, or plan-quota usage, so users cannot see what a session costs or how fast the model actually streams. This plugin makes that visible without leaving the chat.

What users get / 用户可见行为:

  • A floating status bar in the desktop client: generation speed (tok/s), per-turn / session / today token usage, cache hit rate, sub-agent breakdown, context usage, plan-quota chip, Git status chip, with tooltips and a ⚙ settings panel.
  • A per-answer rate line appended under each reply (tok/s, TTFT, output tokens, duration).
  • /usage command (today / week / models / current), token_usage(scope) MCP tool, and a skill for agent-driven queries.

How to test / 测试方式:

  1. Install from this marketplace, keep the plugin enabled, open a session — the status bar installs automatically (this modifies the client's app.asar; fully quit and reopen ZCode).
  2. Ask a question → per-answer rate line appears; hover the status bar → details; /usage today → usage report; the token_usage MCP tool answers scope queries.
  3. /uninstall-overlay removes the status bar and leaves an opt-out marker; "plugin_auto_install_overlay": false keeps query-tools-only mode.

Version & marketplace registration / 版本与市场注册: v1.5.3 in plugin.json (both manifests) and marketplace.json, description_i18n identical in all three. 1.5.2 exists on this plugin's own GitHub release channel (immutable), so this content change bumps to 1.5.3.

Dependencies, network, permissions, side effects / 依赖、网络请求、权限与副作用 (also documented in both READMEs):

  • Python 3.8+ standard library only; no pip packages; no third-party code bundled (plain Python + plain JavaScript, Electron main-process CommonJS). MIT.
  • Modifies the client's app.asar to inject the status bar loader (removable patch, keeps a backup, opt-out respected, full disclosure in README).
  • Hooks: SessionStart (runtime-file sync, update check, restart notice), UserPromptSubmit (prompt timestamp + rate line). MCP: stdio usage_mcp.py exposing token_usage, read-only on the local usage DB.
  • Files written: ~/.zcode/zcode-token-usage-statusbar/ (runtime files, config, state; secrets 0600), the app.asar patch + backup, overlay settings in ~/.zcode/zusage3.
  • Network: local stats never leave the machine (read-only SQLite). The plan-quota chip decrypts the host's stored OAuth credentials in memory only and calls BigModel / Z.ai usage endpoints directly; credentials never reach config/logs/diagnostics. Plugin updates download code from the configured source. Optional SSH/WSL remote queries use user-configured channels; host passwords/key passphrases are never decrypted or reused; no auto-deploy. The Git chip is local read-only git (no fetch).

Third-party material / 第三方材料: none — no third-party code, assets, or services bundled. Source: ByteRax/zcode-token-usage-statusbar (MIT).

Self-check / 自查清单

  • Plugin name is unique kebab-case; new external plugin directory is external_plugins/<name>/; existing fixes retain ownership / 插件名唯一且 kebab-case,外部新增插件位于 external_plugins/<name>/,已有插件修复保留原归属
  • Usage category is set independently of publisher ownership / 用途分类 category 已填写,与维护归属分开
  • Plugin type and affected names are declared above / 已在上方声明插件类型与涉及的插件名称
  • version bumped in BOTH plugin.json and marketplace.json (artifacts are immutable) / plugin.json 与 marketplace.json 两处版本号已同步升级(制品不可变)
  • README.md (EN) and README_CN.md (中文) both updated and equivalent / 中英文 README 均已更新且语义一致
  • description_i18n has both en and zh-CN / description_i18n 包含 en 与 zh-CN
  • No secrets, machine-specific paths, or private dependencies / 不含密钥、机器专属路径或私有依赖
  • Model/API/network dependencies documented / 模型、API、网络依赖已写明
  • python3 scripts/validate.py and python3 scripts/build_dist.py pass locally / 本地校验与构建均通过

Notes on the checks / 校验说明:

  • scripts/validate.py: OK: 52 plugin(s) validated (includes this one).
  • git diff --check: clean.
  • scripts/build_dist.py: the full-repo run stops at the pre-existing excalidraw step in this shallow clone (incomplete build; run pnpm build first — reproduced on unmodified main, it needs the CI pnpm build artifacts, unrelated to this PR). To verify this plugin's packaging, build_zip + build_index_entry from scripts/build_dist.py were invoked directly on external_plugins/zcode-token-usage-statusbar: 31 entries, no __pycache__/.pyc, README_CN.md included, marketplace source rewrite to the zip install source works, and the build is deterministic (identical sha256 on rebuild).

Community plugin: token usage query (token_usage MCP tool, /usage command,
skill) plus a desktop floating status bar (speed, usage, context, plan
quota, Git status) and a per-answer rate line. Desktop status bar install
modifies app.asar (removable patch, opt-out respected, documented in the
bilingual README). Plain Python 3.8 stdlib + plain JS, no third-party code,
MIT.
@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants