🔌
Claude Hub GLM
Claude Code 状态栏插件,实时显示智谱 Coding Plan 用量
Claude Code 插件TypeScript
基于 claude-hud 的 fork,在保留原版所有功能的基础上,新增智谱 Coding Plan 用量显示。
与原版的区别
在原版 claude-hud 的基础上,新增了智谱(Zhipu)Coding Plan 用量实时显示:
- 5 小时用量 — 显示当前 5 小时窗口内的 Token 用量百分比和重置倒计时
- 周用量 — 显示本周 Token 用量百分比和重置倒计时
- MCP 用量 — 显示 MCP 调用次数(已用/总量)和重置倒计时
- 订阅信息 — 显示当前套餐名称和续费时间
- 数据缓存 — 本地缓存 API 响应,避免频繁请求(默认 5 分钟刷新)
显示效果示例:
智谱: 5h ██░░░░░░░░ 25% (resets in 2h 30m) │ 本周 ████░░░░░░ 40% (resets in 3d) │ MCP ██░░ 3/10 (resets in 1h) │ Coding Plan (renews 2026-06-15) [2m]
智谱配置项
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
display.showZhipu | boolean | true | 是否显示智谱用量行 |
display.zhipuCachePath | string | "" | 自定义缓存文件路径(默认自动选择) |
display.zhipuFreshnessMs | number | 300000 | 缓存刷新间隔(毫秒),默认 5 分钟 |
API Key 获取方式
插件会自动检测环境变量来获取智谱 API Key(二选一):
GLM_API_KEY— 直接设置智谱 API Key- 自动检测 — 当
ANTHROPIC_BASE_URL为https://open.bigmodel.cn/api/anthropic时,自动使用ANTHROPIC_AUTH_TOKEN
安装
在 Claude Code 中运行以下命令:
步骤 1:添加市场
/plugin marketplace add Ethanzyc/claude-hub-glm
步骤 2:安装插件
/plugin install claude-hub-glm
安装完成后,重新加载插件:
/reload-plugins
步骤 3:配置状态栏
/claude-hud:setup
完成!重启 Claude Code 即可看到 HUD。
⚠️ Linux 用户注意:
/tmp通常是独立的文件系统(tmpfs),会导致插件安装报错EXDEV: cross-device link not permitted。安装前设置TMPDIR:mkdir -p ~/.cache/tmp && TMPDIR=~/.cache/tmp claude
原版功能
Claude HUD 是一个 Claude Code 插件,实时显示上下文使用率、活跃工具、运行中的 Agent 和待办进度。始终在你的输入下方可见。
| 你看到的内容 | 为什么重要 |
|---|---|
| 项目路径 | 知道你当前在哪个项目中(可配置 1-3 级目录深度) |
| 上下文健康度 | 在上下文窗口满之前准确了解还剩多少 |
| 工具活动 | 实时观察 Claude 读取、编辑和搜索文件 |
| Agent 追踪 | 查看哪些子 Agent 正在运行以及它们在做什么 |
| 待办进度 | 实时跟踪任务完成情况 |
| 智谱用量 | 实时显示智谱 Coding Plan 的用量和配额 |
默认显示(2 行)
[Opus] │ my-project git:(main*)
上下文 █████░░░░░ 45% │ 用量 ██░░░░░░░░ 25%(1h 30m / 5h)
可选行(通过 /claude-hud:configure 启用)
◐ Edit: auth.ts | ✓ Read ×3 | ✓ Grep ×2 ← 工具活动
◐ explore [haiku]: 查找认证代码(2分15秒) ← Agent 状态
▸ 修复认证漏洞(2/5) ← 待办进度
智谱: 5h ██░░░░░░░░ 25% │ 本周 ████░░░░░░ 40% ← 智谱用量
配置
随时自定义你的 HUD:
/claude-hud:configure
配置文件位置
编辑 ~/.claude/plugins/claude-hud/config.json:
{
"language": "zh",
"lineLayout": "expanded",
"pathLevels": 2,
"display": {
"showTools": true,
"showAgents": true,
"showTodos": true,
"showZhipu": true
}
}
配置示例(完整)
{
"language": "zh",
"lineLayout": "expanded",
"pathLevels": 2,
"elementOrder": ["project", "tools", "context", "usage", "zhipu", "memory", "environment", "agents", "todos"],
"gitStatus": {
"enabled": true,
"showDirty": true,
"showAheadBehind": true,
"showFileStats": true
},
"display": {
"showTools": true,
"showAgents": true,
"showTodos": true,
"showConfigCounts": true,
"showDuration": true,
"showMemoryUsage": true,
"showZhipu": true
},
"colors": {
"context": "cyan",
"usage": "cyan",
"warning": "yellow",
"usageWarning": "magenta",
"critical": "red",
"model": "cyan",
"project": "yellow",
"git": "magenta",
"gitBranch": "cyan",
"label": "dim"
}
}
更多配置项详见原版 README。
运行环境要求
- Claude Code v1.0.80+
- Node.js 18+ 或 Bun(macOS/Linux)
- Node.js 18+(Windows)
开发
git clone https://github.com/Ethanzyc/claude-hub-glm
cd claude-hub-glm
npm ci && npm run build
npm test
致谢
本项目基于 jarrodwatts/claude-hud 开发,感谢原作者 Jarrod Watts 的出色工作。
MIT License — 详见 LICENSE。