3.9 KiB
mcode-status
Aygea-branded z.ai GLM usage segment for the MiniMax Code statusline — shows your current 5-hour token-window burn right in the TUI:
🔥 23% · 4:12p(2h14m)
Styled with the Aygea palette (blue → lavender → pink as the window fills), rendered via mcode's colorMode: ansi statusline option, with plain-text fallback.
Install (one line)
curl -fsSL https://git.itsaygea.com/admin/mcode-sl/raw/branch/main/install.sh | bash
The installer is self-contained (the statusline script is embedded in it) and:
- installs
~/.local/bin/mcode-zai-usage - checks SecretVault for your
zai_api_keysecret (never prints it) - merges the
tui:section into~/.minimax/config.yaml— atomic write, timestamped backup, refuses ambiguous structures, everything outside thetui:block stays byte-identical - primes the quota cache so the segment appears immediately
Then restart the MiniMax Code TUI.
Secret setup (once per machine)
This looks like an example entry, but it's the actual setup: create a SecretVault secret named zai_api_key holding your z.ai API key (for https://api.z.ai):
- via the SecretVault MCP
create_secrettool in any agent session, or your usual SecretVault flow
No key in the repo, no key in argv, no key in the config file — the statusline reads it at runtime with secretvault run. A legacy ~/.secretvault/credential.json (url + clientKey, the Claude-statusline layout) also works as a fallback.
No cron, no systemd
MiniMax Code re-runs the command every intervalSeconds — mcode is the scheduler. The script never blocks the TUI on the network: display comes from a local cache, and a detached, flock-guarded background job refreshes it when the cache is >150s old (sharing ~/.cache/aygea-sl/quota.json with the Aygea Claude statusline if both are installed).
Config (managed in ~/.minimax/config.yaml)
tui:
statusLine:
- current-dir
- git-branch
- approval-mode
- model-with-reasoning
- context-remaining
- custom-command
customStatusLine:
command: /home/you/.local/bin/mcode-zai-usage
intervalSeconds: 60
timeoutMs: 10000
colorMode: ansi
Installer env overrides: MCODE_SL_ITEMS (item list), MCODE_SL_INTERVAL, MCODE_SL_TIMEOUT, MCODE_SL_SECRET.
Script env tunables
| Variable | Default | Meaning |
|---|---|---|
AYGEA_SL_SECRET_NAME |
zai_api_key |
SecretVault secret name |
AYGEA_SL_URL |
https://api.z.ai |
quota API base URL |
AYGEA_SL_NO_VAULT=1 |
off | skip SecretVault, use credential.json |
AYGEA_SL_QUOTA_CACHE |
~/.cache/aygea-sl/quota.json |
cache path |
AYGEA_SL_REFRESH_AFTER |
150 |
refresh when cache older (sec) |
AYGEA_SL_MAX_AGE |
360 |
hide when cache older (sec) |
AYGEA_SL_CURL_TIMEOUT |
6 |
per-fetch curl --max-time |
AYGEA_SL_ONLY_GLM=1 |
off | show only for glm models |
AYGEA_SL_MEM=1 |
off | prepend an 🧠 memory segment (Linux/macOS) |
NO_COLOR |
— | plain text output |
Uninstall
curl -fsSL https://git.itsaygea.com/admin/mcode-sl/raw/branch/main/install.sh | bash -s -- --uninstall
Development
Requires jq + curl; secretvault optional (fallback: credential.json); python3 for the config merge. Test locally:
printf '{}' | ./zai-usage.sh # statusline preview
./zai-usage.sh --refresh # one foreground refresh
install.sh embeds a copy of zai-usage.sh for curl | bash installs; checkout installs prefer the sibling file. After editing zai-usage.sh, regenerate the embedded copy:
python3 - <<'EOF'
import re
src = open('zai-usage.sh').read(); assert src.endswith("\n")
ins = open('install.sh').read()
new = re.sub(r"(cat <<'ZAI_EMBED_EOF'\n).*?ZAI_EMBED_EOF\n",
lambda m: m.group(1) + src + "ZAI_EMBED_EOF\n", ins, flags=re.S)
open('install.sh', 'w').write(new)
EOF