stepfun-status 1.0.4 → 1.0.5

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.
Files changed (5) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -175
  3. package/cli/api.js +408 -345
  4. package/package.json +1 -1
  5. package/ARCHITECTURE.md +0 -175
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Jochen Yang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jochen Yang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,175 +1,190 @@
1
- # stepfun-status
2
-
3
- > StepFun Token-Plan 使用状态监控工具,支持 Claude Code 状态栏常驻显示。
4
-
5
- [![npm version](https://img.shields.io/npm/v/stepfun-status)](https://www.npmjs.com/package/stepfun-status)
6
- [![npm downloads](https://img.shields.io/npm/dm/stepfun-status)](https://www.npmjs.com/package/stepfun-status?activeTab=downloads)
7
- [![Node >=16](https://img.shields.io/node/v/stepfun-status)](https://nodejs.org)
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
-
10
- ## 效果预览
11
-
12
- Claude Code 底部状态栏:
13
-
14
- ```
15
- my-app │ main │ step-3.5-flash │ ██████░░░░ 60% (40/100) │ ⏱ 1h30m │ W ███░░ 58% │ 到期 12天
16
- ```
17
-
18
- 终端详细视图:
19
-
20
- ```
21
- ┌──────────────────────────────────────────────┐
22
- │ StepFun Claude Code 使用状态 │
23
- │ │
24
- │ 当前模型: step-3.5-flash │
25
- │ 套餐: Mini │
26
- │ │
27
- │ 5小时用量: ██████████████████░░░░░░░░░░ 60% │
28
- │ 剩余: 40% │
29
- │ 重置: 1 小时 30 分钟后重置 │
30
- │ │
31
- │ 每周用量: ████████░░░░░░░ 58% │
32
- │ 剩余: 42% │
33
- │ 重置: 3 小时 12 分钟后重置 │
34
- │ │
35
- │ 套餐到期: 2025/6/1 00:00:00 (还剩 12 天) │
36
- │ │
37
- │ 状态: ⚡ 注意使用 │
38
- └──────────────────────────────────────────────┘
39
- ```
40
-
41
- ## 安装
42
-
43
- ```bash
44
- npm install -g stepfun-status
45
- ```
46
-
47
- ## 快速开始
48
-
49
- ### 1. 获取 Cookie 并认证
50
-
51
- 运行下方命令,会自动打印获取步骤:
52
-
53
- ```bash
54
- stepfun auth
55
- ```
56
-
57
- 按提示操作:
58
- 1. 登录 [https://platform.stepfun.com/plan-subscribe](https://platform.stepfun.com/plan-subscribe)
59
- 2. F12 → Network 标签 → 刷新页面
60
- 3. 点击任意 API 请求(如 `GetStepPlanStatus`)
61
- 4. 滚动到 Request Headers → 找到 `Cookie` 行
62
- 5. **右键 → Copy value**(必须用此方式,直接框选会截断)
63
- 6. 粘贴到终端并回车
64
-
65
- > **提示**:Cookie 较长,建议使用交互式 `stepfun auth`(无参数),避免命令行参数截断问题。
66
-
67
- ### 2. 验证连接
68
-
69
- ```bash
70
- stepfun health
71
- ```
72
-
73
- ### 3. 查看状态
74
-
75
- ```bash
76
- stepfun status
77
- ```
78
-
79
- ## Claude Code 状态栏集成
80
-
81
- ### 配置
82
-
83
- 编辑 `~/.claude/settings.json`,添加:
84
-
85
- ```json
86
- {
87
- "statusLine": {
88
- "type": "command",
89
- "command": "stepfun statusline"
90
- }
91
- }
92
- ```
93
-
94
- 重启 Claude Code 后生效。
95
-
96
-
97
- ### 状态栏格式
98
-
99
- ```
100
- 目录 │ 分支 │ 模型 │ 5小时用量进度条(剩余) │ ⏱ 倒计时 │ W 周用量 │ 到期天数
101
- ```
102
-
103
- **颜色说明**:
104
-
105
- | 指标 | 绿色 | 黄色 | 红色 |
106
- |------|------|------|------|
107
- | 用量 | < 60% | 60–85% | ≥ 85% |
108
- | 到期 | > 7 天 | ≤ 7 天 | ≤ 3 天 |
109
- | 分支 | main/master | — | 有未提交改动(`*`) |
110
-
111
- ## 命令参考
112
-
113
- | 命令 | 选项 | 说明 |
114
- |------|------|------|
115
- | `stepfun auth [cookie]` | — | 设置认证 Cookie(推荐无参数交互式输入) |
116
- | `stepfun health` | — | 检查配置文件、Cookie 和 API 连通性 |
117
- | `stepfun status` | — | 详细模式显示当前使用状态 |
118
- | `stepfun status` | `-c, --compact` | 紧凑单行模式 |
119
- | `stepfun status` | `-w, --watch` | 实时监控,每 10 秒刷新 |
120
- | `stepfun status` | `-c -w` | 紧凑模式 + 实时监控 |
121
- | `stepfun statusline` | — | 输出状态行(供 Claude Code 调用) |
122
- | `stepfun statusline` | `-w, --watch` | 持续刷新状态行输出 |
123
-
124
- ## 配置文件
125
-
126
- | 项目 | 说明 |
127
- |------|------|
128
- | 路径 | `~/.stepfun-config.json` |
129
- | 内容 | `{ "cookie": "..." }` |
130
- | 权限 | Unix/Mac 下自动设置为 `0600`(仅所有者可读写) |
131
-
132
- > **Windows 注意**:不支持 Unix 文件权限位,Cookie 以明文存储,请妥善保管配置文件,避免他人访问。
133
-
134
- > **macOS / Linux**:配置文件权限已自动设为 `0600`,只有当前用户可读写,无需额外操作。
135
-
136
- ## 常见问题
137
-
138
- **Q: 状态栏显示 ❌**
139
- A: Cookie 未配置或已过期,运行 `stepfun health` 诊断,再用 `stepfun auth` 重新设置。
140
-
141
- **Q: Cookie 粘贴后提示"不能为空"**
142
- A: 可能复制到了空内容,请确保在 Network 面板使用"右键 → Copy value"而非框选复制。
143
-
144
- **Q: 状态栏不显示**
145
- A: 确认 `~/.claude/settings.json` `statusLine.command` 为 `stepfun statusline`,且 `stepfun-status` 已全局安装(`npm install -g stepfun-status`)。
146
-
147
- **Q: macOS / Linux 上 `stepfun` 命令找不到**
148
- A: 确认 npm 全局 bin 目录已加入 `PATH`。可运行 `npm bin -g` 查看路径,并将其添加到 `~/.zshrc` 或 `~/.bashrc`:
149
- ```bash
150
- export PATH="$(npm bin -g):$PATH"
151
- ```
152
-
153
- ## 开发
154
-
155
- ```bash
156
- git clone https://github.com/Daiyimo/stepfun-status.git
157
- cd stepfun-status
158
- npm install
159
- npm link # 本地全局链接,方便调试
160
-
161
- npm start # 查看当前状态
162
- npm test # 检查连通性
163
- npm run lint # 语法检查
164
- ```
165
-
166
- ## 许可证
167
-
168
- [MIT](LICENSE)
169
-
170
- ## 相关链接
171
-
172
- - [StepFun 开放平台](https://platform.stepfun.com)
173
- - [StepFun 接口密钥](https://platform.stepfun.com/interface-key)
174
- - [StepFun 订阅情况](https://platform.stepfun.com/plan-subscribe)
175
- - [StepFun 接入指南](https://platform.stepfun.com/docs/zh/step-plan/integrations)
1
+ # stepfun-status
2
+
3
+ > StepFun Token-Plan 使用状态监控工具,支持 Claude Code 状态栏常驻显示。
4
+
5
+ [![npm version](https://img.shields.io/npm/v/stepfun-status)](https://www.npmjs.com/package/stepfun-status)
6
+ [![npm downloads](https://img.shields.io/npm/dm/stepfun-status)](https://www.npmjs.com/package/stepfun-status?activeTab=downloads)
7
+ [![Node >=16](https://img.shields.io/node/v/stepfun-status)](https://nodejs.org)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
+
10
+ ## 效果预览
11
+
12
+ Claude Code 底部状态栏:
13
+
14
+ ```
15
+ my-app │ main │ step-3.5-flash │ ██████░░░░ 60% (40/100) │ ⏱ 1h30m │ W ███░░ 58% │ 到期 12天
16
+ ```
17
+
18
+ 终端详细视图:
19
+
20
+ ```
21
+ ┌──────────────────────────────────────────────┐
22
+ │ StepFun Claude Code 使用状态 │
23
+ │ │
24
+ │ 当前模型: step-3.5-flash │
25
+ │ 套餐: Mini │
26
+ │ │
27
+ │ 5小时用量: ██████████████████░░░░░░░░░░ 60% │
28
+ │ 剩余: 40% │
29
+ │ 重置: 1 小时 30 分钟后重置 │
30
+ │ │
31
+ │ 每周用量: ████████░░░░░░░ 58% │
32
+ │ 剩余: 42% │
33
+ │ 重置: 3 小时 12 分钟后重置 │
34
+ │ │
35
+ │ 套餐到期: 2025/6/1 00:00:00 (还剩 12 天) │
36
+ │ │
37
+ │ 状态: ⚡ 注意使用 │
38
+ └──────────────────────────────────────────────┘
39
+ ```
40
+
41
+ ## 安装
42
+
43
+ ```bash
44
+ npm install -g stepfun-status
45
+ ```
46
+
47
+ ## 快速开始
48
+
49
+ ### 1. 获取 Cookie 并认证
50
+
51
+ 运行下方命令,会自动打印获取步骤:
52
+
53
+ ```bash
54
+ stepfun auth
55
+ ```
56
+
57
+ 按提示操作:
58
+ 1. 登录 [https://platform.stepfun.com/plan-subscribe](https://platform.stepfun.com/plan-subscribe)
59
+ 2. F12 → Network 标签 → 刷新页面
60
+ 3. 点击任意 API 请求(如 `GetStepPlanStatus`)
61
+ 4. 滚动到 Request Headers → 找到 `Cookie` 行
62
+ 5. **右键 → Copy value**(必须用此方式,直接框选会截断)
63
+ 6. 粘贴到终端并回车
64
+
65
+ > **提示**:Cookie 较长,建议使用交互式 `stepfun auth`(无参数),避免命令行参数截断问题。
66
+
67
+ ### 2. 验证连接
68
+
69
+ ```bash
70
+ stepfun health
71
+ ```
72
+
73
+ ### 3. 查看状态
74
+
75
+ ```bash
76
+ stepfun status
77
+ ```
78
+
79
+ ## Claude Code 状态栏集成
80
+
81
+ ### 配置
82
+
83
+ 编辑 `~/.claude/settings.json`,添加:
84
+
85
+ ```json
86
+ {
87
+ "statusLine": {
88
+ "type": "command",
89
+ "command": "stepfun statusline"
90
+ }
91
+ }
92
+ ```
93
+
94
+ 重启 Claude Code 后生效。
95
+
96
+
97
+ ### 状态栏格式
98
+
99
+ ```
100
+ 目录 │ 分支 │ 模型 │ 5小时用量进度条(剩余) │ ⏱ 倒计时 │ W 周用量 │ 到期天数
101
+ ```
102
+
103
+ **颜色说明**:
104
+
105
+ | 指标 | 绿色 | 黄色 | 红色 |
106
+ |------|------|------|------|
107
+ | 用量 | < 60% | 60–85% | ≥ 85% |
108
+ | 到期 | > 7 天 | ≤ 7 天 | ≤ 3 天 |
109
+ | 分支 | main/master | — | 有未提交改动(`*`) |
110
+
111
+ ## 命令参考
112
+
113
+ | 命令 | 选项 | 说明 |
114
+ |------|------|------|
115
+ | `stepfun auth [cookie]` | — | 设置认证 Cookie(推荐无参数交互式输入) |
116
+ | `stepfun health` | — | 检查配置文件、Cookie 和 API 连通性 |
117
+ | `stepfun status` | — | 详细模式显示当前使用状态 |
118
+ | `stepfun status` | `-c, --compact` | 紧凑单行模式 |
119
+ | `stepfun status` | `-w, --watch` | 实时监控,每 10 秒刷新 |
120
+ | `stepfun status` | `-c -w` | 紧凑模式 + 实时监控 |
121
+ | `stepfun statusline` | — | 输出状态行(供 Claude Code 调用) |
122
+ | `stepfun statusline` | `-w, --watch` | 持续刷新状态行输出 |
123
+
124
+ ## 卸载 / 更新
125
+
126
+ ```bash
127
+ # 一键更新到最新版
128
+ npm update -g stepfun-status
129
+
130
+ # 完全卸载
131
+ npm uninstall -g stepfun-status
132
+ # 可选:同时删除配置文件
133
+ # macOS / Linux
134
+ rm -f ~/.stepfun-config.json
135
+ # Windows (PowerShell)
136
+ Remove-Item ~\.stepfun-config.json -ErrorAction SilentlyContinue
137
+ ```
138
+
139
+ ## 配置文件
140
+
141
+ | 项目 | 说明 |
142
+ |------|------|
143
+ | 路径 | `~/.stepfun-config.json` |
144
+ | 内容 | `{ "cookie": "..." }` |
145
+ | 权限 | Unix/Mac 下自动设置为 `0600`(仅所有者可读写) |
146
+
147
+ > **Windows 注意**:不支持 Unix 文件权限位,Cookie 以明文存储,请妥善保管配置文件,避免他人访问。
148
+
149
+ > **macOS / Linux**:配置文件权限已自动设为 `0600`,只有当前用户可读写,无需额外操作。
150
+
151
+ ## 常见问题
152
+
153
+ **Q: 状态栏显示 ❌**
154
+ A: Cookie 未配置或已过期,运行 `stepfun health` 诊断,再用 `stepfun auth` 重新设置。
155
+
156
+ **Q: Cookie 粘贴后提示"不能为空"**
157
+ A: 可能复制到了空内容,请确保在 Network 面板使用"右键 → Copy value"而非框选复制。
158
+
159
+ **Q: 状态栏不显示**
160
+ A: 确认 `~/.claude/settings.json` 中 `statusLine.command` 为 `stepfun statusline`,且 `stepfun-status` 已全局安装(`npm install -g stepfun-status`)。
161
+
162
+ **Q: macOS / Linux 上 `stepfun` 命令找不到**
163
+ A: 确认 npm 全局 bin 目录已加入 `PATH`。可运行 `npm bin -g` 查看路径,并将其添加到 `~/.zshrc` 或 `~/.bashrc`:
164
+ ```bash
165
+ export PATH="$(npm bin -g):$PATH"
166
+ ```
167
+
168
+ ## 开发
169
+
170
+ ```bash
171
+ git clone https://github.com/Daiyimo/stepfun-status.git
172
+ cd stepfun-status
173
+ npm install
174
+ npm link # 本地全局链接,方便调试
175
+
176
+ npm start # 查看当前状态
177
+ npm test # 检查连通性
178
+ npm run lint # 语法检查
179
+ ```
180
+
181
+ ## 许可证
182
+
183
+ [MIT](LICENSE)
184
+
185
+ ## 相关链接
186
+
187
+ - [StepFun 开放平台](https://platform.stepfun.com)
188
+ - [StepFun 接口密钥](https://platform.stepfun.com/interface-key)
189
+ - [StepFun 订阅情况](https://platform.stepfun.com/plan-subscribe)
190
+ - [StepFun 接入指南](https://platform.stepfun.com/docs/zh/step-plan/integrations)