fix minimax quota and add colored output via optional statusline_part_colored #13

Merged
guochao merged 4 commits from guochao/agent-run:master into master 2026-06-02 13:16:11 +00:00
Owner
No description provided.
The 'general' model entry returned by api.minimaxi.com populates
*_remaining_percent and *_status but leaves *_total_count and
*_usage_count at 0. The previous code required total > 0 and dropped
both windows, so subscription_quota_usage returned nil and the
statusline emitted no quota part.

- Read counts when present, otherwise derive total/used from the
  remaining percent (total=100, used=round(100-remaining)). Entries
  that populate the count fields still take the count path.
- Display the used amount as a percentage (e.g. '7%') rather than
  'used/total', matching the format used by glm and kimi.
- Skip a window entirely when its used percent is 0, so an unused
  weekly quota does not add noise like 'week(in 5.2d) 0%'.
The context part used to be skipped entirely when context_window was
absent from stdin, and skipped silently when context_window existed
but used_percentage was nil. Both states now show 'ctx used ...%' so
the statusline still indicates a context slot is reserved for the
agent. The matcher is unconditional.

When used_percentage is present, format as a right-aligned width-3
integer with no decimals (e.g. 'ctx used  42%'), matching the
percent-based display used by other providers.
Bridge the Rust tracing module to Lua providers via a `log(level, message)`
global, so statusline scripts can emit structured log lines filtered by
RUST_LOG. Level is one of debug|info|warn|error; unknown levels fall back
to info. All lines are prefixed with [lua] in the Rust side to distinguish
them from internal engine logs.
Providers can now implement a second entry point, M.statusline_part_colored,
that returns a version of the part with ANSI color escapes. The Rust engine:

  * calls statusline_part_colored when present and stores its result
    alongside the plain output in the cache as colored_output
    (Option<String>, omitted from JSON when None)
  * picks the colored form at output time only when the terminal can
    render it (NO_COLOR off, TERM not dumb/empty, COLORTERM mentions
    truecolor/24bit, or TERM matches a 256-color pattern) AND the
    provider actually returned a non-empty string
  * otherwise falls back to the plain statusline_part output

20-context.lua opts in with a hard-coded green/yellow/orange/red palette
at 0/40/70/90 thresholds; no shared color util to keep this commit
self-contained.
guochao merged commit 5151e84f70 into master 2026-06-02 13:16:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: public/agent-run#13
No description provided.