cc-usage-bar 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -171,11 +171,11 @@ CC_USAGE_COLORS_BALANCE='0:cyan,60:yellow,90:red'
171
171
  # 自定义填充/空槽字符(cells)
172
172
  --bar-spec='{"mode":"cells","filled":"▰","empty":"▱","width":12}'
173
173
 
174
- # 单色渐变(tint)—— 完成部分上色,剩余部分变暗
175
- --bar-spec='{"mode":"tint","text":"████████","emptyStyle":"dim"}'
174
+ # 单色渐变(tint)—— 默认 reverse:完成部分反色底块,剩余部分变暗
175
+ --bar-spec='{"mode":"tint","text":"Ciallo~(∠・ω< )⌒★"}'
176
176
 
177
- # 反色填充(reverse)—— 完成部分用反色底块增强对比
178
- --bar-spec='{"mode":"tint","text":"Ciallo~(∠・ω< )⌒★","style":"reverse"}'
177
+ # 想要旧的"只染前景"效果,显式加 style:"fg"
178
+ --bar-spec='{"mode":"tint","text":"████████","style":"fg","emptyStyle":"dim"}'
179
179
 
180
180
  # 动画帧(frames)—— 按百分比从帧序列里挑一帧
181
181
  --bar-spec='{"mode":"frames","frames":["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]}'
package/README.md CHANGED
@@ -20,6 +20,36 @@ Or, with `--format=bar-time`:
20
20
  [█████░░░░░] 47% until 18:00 / [██████░░░░] 59% until 5/9 09:00
21
21
  ```
22
22
 
23
+ ## Quick usage
24
+
25
+ ### Method 1: Command line
26
+
27
+ ```bash
28
+ npm install -g cc-usage-bar@latest
29
+ cc-usage-bar install --format=bar-countdown
30
+ ```
31
+
32
+ If you already have a Claude Code statusline command, the installer keeps it as the prefix and appends the usage bar. Run diagnostics any time with:
33
+
34
+ ```bash
35
+ cc-usage-bar status
36
+ ```
37
+
38
+ ### Method 2: Ask an AI assistant
39
+
40
+ In Claude Code, Cursor, Codex, or another coding assistant, say:
41
+
42
+ ```text
43
+ Install cc-usage-bar for my Claude Code statusline.
44
+ Keep my existing statusline prefix and use the bar-countdown format.
45
+ ```
46
+
47
+ If the assistant needs exact instructions, give it the AI-readable guide:
48
+
49
+ ```bash
50
+ npx cc-usage-bar@latest agents
51
+ ```
52
+
23
53
  ## Install
24
54
 
25
55
  ```bash
@@ -111,16 +141,16 @@ cc-usage-bar install --format=bar-time \
111
141
  --bar-spec='{"mode":"tint","text":"Ciallo~(∠・ω< )⌒★"}'
112
142
  ```
113
143
 
114
- `tint` keeps the whole text visible and colors the completed prefix while dimming the rest:
144
+ `tint` keeps the whole text visible. By default the completed prefix is rendered as a reversed-color block (high contrast), and the rest is dimmed:
115
145
 
116
146
  ```json
117
147
  {"mode":"tint","text":"Ciallo~(∠・ω< )⌒★"}
118
148
  ```
119
149
 
120
- For stronger contrast, add `style:"reverse"` so the completed prefix is rendered as a reversed-color block:
150
+ If you prefer the older "color the foreground only" look, set `style:"fg"`:
121
151
 
122
152
  ```json
123
- {"mode":"tint","text":"Ciallo~(∠・ω< )⌒★","style":"reverse"}
153
+ {"mode":"tint","text":"Ciallo~(∠・ω< )⌒★","style":"fg"}
124
154
  ```
125
155
 
126
156
  `cells` replaces the default block characters:
package/README.zh-CN.md CHANGED
@@ -22,6 +22,36 @@
22
22
  [█████░░░░░] 47% until 18:00 / [██████░░░░] 59% until 5/9 09:00
23
23
  ```
24
24
 
25
+ ## 快速使用
26
+
27
+ ### 方法一:正常命令行
28
+
29
+ ```bash
30
+ npm install -g cc-usage-bar@latest
31
+ cc-usage-bar install --format=bar-countdown
32
+ ```
33
+
34
+ 如果你已经有自己的 Claude Code statusline 命令,安装器会把它保留为前缀,再追加用量条。需要诊断时运行:
35
+
36
+ ```bash
37
+ cc-usage-bar status
38
+ ```
39
+
40
+ ### 方法二:直接和大模型交流
41
+
42
+ 在 Claude Code、Cursor、Codex 或其他编程助手里直接说:
43
+
44
+ ```text
45
+ 请安装 cc-usage-bar 并帮我配置 Claude Code statusline。
46
+ 保留我原来的 statusline 前缀,使用 bar-countdown 格式。
47
+ ```
48
+
49
+ 如果大模型需要更精确的操作说明,把下面命令输出的 AI 可读安装指南发给它:
50
+
51
+ ```bash
52
+ npx cc-usage-bar@latest agents
53
+ ```
54
+
25
55
  ## 安装
26
56
 
27
57
  ```bash
@@ -111,7 +141,7 @@ cc-usage-bar install --format <preset> --bar-width <n>
111
141
 
112
142
  #### tint:整段文字始终可见
113
143
 
114
- 推荐给颜文字、短句、logo 风格文本。已完成部分会染色,未完成部分会变暗,但整段文字一直可见:
144
+ 推荐给颜文字、短句、logo 风格文本。整段文字一直可见,**默认**已完成部分会用反色底块(reverse)增强对比,未完成部分变暗:
115
145
 
116
146
  ```bash
117
147
  cc-usage-bar install --format=bar-time \
@@ -122,10 +152,10 @@ cc-usage-bar install --format=bar-time \
122
152
  {"mode":"tint","text":"Ciallo~(∠・ω< )⌒★"}
123
153
  ```
124
154
 
125
- 如果想让完成部分更像“填充底块”,可以加 `style:"reverse"`,完成部分会用反色块增强对比:
155
+ 如果更喜欢"只给完成部分上前景色、不反色"的旧风格,显式加 `style:"fg"`:
126
156
 
127
157
  ```json
128
- {"mode":"tint","text":"Ciallo~(∠・ω< )⌒★","style":"reverse"}
158
+ {"mode":"tint","text":"Ciallo~(∠・ω< )⌒★","style":"fg"}
129
159
  ```
130
160
 
131
161
  #### cells:替换默认块字符
@@ -147,8 +147,7 @@ function parseBarSpec(raw) {
147
147
  const out = { mode: 'tint', text: obj.text };
148
148
  if (obj.emptyStyle === 'plain' || obj.emptyStyle === 'dim')
149
149
  out.emptyStyle = obj.emptyStyle;
150
- if (obj.style === 'fg' || obj.style === 'reverse')
151
- out.style = obj.style;
150
+ out.style = obj.style === 'fg' ? 'fg' : 'reverse';
152
151
  return out;
153
152
  }
154
153
  if (obj.mode === 'frames') {
@@ -3,13 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.minimaxAdapter = void 0;
4
4
  exports.parseMinimax = parseMinimax;
5
5
  const http_1 = require("./http");
6
- function tier(total, used, endMs) {
7
- if (typeof total !== 'number' || typeof used !== 'number' || total <= 0)
8
- return undefined;
9
- return {
10
- utilization: ((total - (total - used)) / total) * 100,
11
- resets_at: typeof endMs === 'number' ? new Date(endMs).toISOString() : undefined,
12
- };
6
+ function isoFromMs(ms) {
7
+ return typeof ms === 'number' ? new Date(ms).toISOString() : undefined;
13
8
  }
14
9
  function parseMinimax(body) {
15
10
  if (!body || typeof body !== 'object')
@@ -19,16 +14,22 @@ function parseMinimax(body) {
19
14
  if (typeof code === 'number' && code !== 0) {
20
15
  return { error: r.base_resp?.status_msg ?? `MiniMax error ${code}` };
21
16
  }
22
- const remains = r.model_remains?.[0];
23
- if (!remains)
17
+ if (!Array.isArray(r.model_remains))
18
+ return null;
19
+ const item = r.model_remains.find((m) => m && m.model_name === 'general');
20
+ if (!item)
24
21
  return null;
25
22
  const out = { kind: 'subscription', planName: 'MiniMax' };
26
- const fh = tier(remains.current_interval_total_count, remains.current_interval_usage_count, remains.end_time);
27
- if (fh)
28
- out.five_hour = fh;
29
- const wk = tier(remains.current_weekly_total_count, remains.current_weekly_usage_count, remains.weekly_end_time);
30
- if (wk)
31
- out.seven_day = wk;
23
+ const fhRemain = item.current_interval_remaining_percent;
24
+ if (typeof fhRemain === 'number') {
25
+ out.five_hour = { utilization: 100 - fhRemain, resets_at: isoFromMs(item.end_time) };
26
+ }
27
+ if (item.current_weekly_status === 1) {
28
+ const wkRemain = item.current_weekly_remaining_percent;
29
+ if (typeof wkRemain === 'number') {
30
+ out.seven_day = { utilization: 100 - wkRemain, resets_at: isoFromMs(item.weekly_end_time) };
31
+ }
32
+ }
32
33
  if (!out.five_hour && !out.seven_day)
33
34
  return null;
34
35
  return out;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-usage-bar",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Show your Claude Code subscription usage (5h / 7d, or balance) in the statusline. Supports Anthropic, Kimi, GLM, MiniMax, DeepSeek, StepFun, SiliconFlow, OpenRouter, Novita.",
5
5
  "keywords": [
6
6
  "claude",