cco-budget

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Context Budget Manager

上下文预算管理器

Manage the token budget for Claude Code sessions.
Parse $ARGUMENTS:
管理Claude Code会话的令牌预算。
解析$ARGUMENTS:

status
(or no arguments)

status
(或无参数)

Show current budget configuration, usage, and auto-compact settings:
bash
cat ~/.claude-context-optimizer/config.json 2>/dev/null
echo "---"
cat ~/.claude-context-optimizer/budget-config.json 2>/dev/null
If no config exists, show defaults (100K tokens, warn at 50/70/85/95%). Show auto-compact status: enabled/disabled, thresholds (default: auto-compact at 80%, critical at 90%).
显示当前预算配置、使用情况和自动压缩设置:
bash
cat ~/.claude-context-optimizer/config.json 2>/dev/null
echo "---"
cat ~/.claude-context-optimizer/budget-config.json 2>/dev/null
如果不存在配置,则显示默认值(10万令牌,在50%/70%/85%/95%时发出警告)。 显示自动压缩状态:启用/禁用,阈值(默认:80%时自动压缩,90%时触发临界状态)。

set <tokens>

set <令牌数量>

Update the budget limit. Parse the token count from arguments. Create or update
~/.claude-context-optimizer/config.json
:
json
{
  "budgetTokens": <parsed_number>,
  "warnAt": [50, 70, 85, 95],
  "autoCompactAt": 90,
  "model": "opus"
}
更新预算限制。从参数中解析令牌数量。 创建或更新
~/.claude-context-optimizer/config.json
json
{
  "budgetTokens": <parsed_number>,
  "warnAt": [50, 70, 85, 95],
  "autoCompactAt": 90,
  "model": "opus"
}

model <name>

model <模型名称>

Set the model for cost estimation (haiku, sonnet, opus). Update the
model
field in config.json.
设置用于成本估算的模型(haiku、sonnet、opus)。 更新config.json中的
model
字段。

auto <on|off>

auto <开启|关闭>

Toggle auto-compact behavior. When enabled, the budget monitor will output strong directive messages at configurable thresholds to prompt Claude to run /compact.
Update
~/.claude-context-optimizer/budget-config.json
:
  • auto on
    — set
    autoCompactEnabled
    to
    true
  • auto off
    — set
    autoCompactEnabled
    to
    false
Read the existing budget-config.json first, then update only the
autoCompactEnabled
field. If the file doesn't exist, create it with defaults:
json
{
  "autoCompactEnabled": true,
  "autoCompactThreshold": 80,
  "criticalThreshold": 90
}
After toggling, confirm the new setting to the user. Explain:
  • When enabled (default): At 80% budget usage, a strong recommendation to run /compact is emitted. At 90%, a critical warning is emitted. These repeat every 10K/5K tokens respectively.
  • When disabled: Only the standard threshold warnings (50/70/85/95%) are shown, with legacy compact suggestions at 90%+.
Explain that budget warnings will appear automatically during the session as hook feedback when thresholds are crossed.
切换自动压缩行为。启用后,预算监控器会在可配置的阈值输出强烈的指令消息,提示Claude运行/compact。
更新
~/.claude-context-optimizer/budget-config.json
  • auto on
    — 将
    autoCompactEnabled
    设置为
    true
  • auto off
    — 将
    autoCompactEnabled
    设置为
    false
先读取现有的budget-config.json,然后仅更新
autoCompactEnabled
字段。 如果文件不存在,则使用默认值创建:
json
{
  "autoCompactEnabled": true,
  "autoCompactThreshold": 80,
  "criticalThreshold": 90
}
切换后,向用户确认新设置。说明:
  • 启用时(默认): 当预算使用率达到80%时,会发出运行/compact的强烈建议。 达到90%时,会发出临界警告。这些消息分别每1万/5千令牌重复一次。
  • 禁用时: 仅显示标准阈值警告(50%/70%/85%/95%), 在90%及以上时显示旧版压缩建议。
说明当超过阈值时,预算警告会作为钩子反馈在会话期间自动显示。