@miloya/oc-minimax-status 0.2.0 → 0.4.0

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/README.md CHANGED
@@ -15,10 +15,11 @@
15
15
 
16
16
  ## 功能特性
17
17
 
18
- - 实时用量查询 - 查询 MiniMax Coding Plan 使用状态
18
+ - 实时用量查询 - 查询 MiniMax Coding Plan 使用状态(5小时窗口 + 周用量)
19
19
  - 安全认证 - 安全的 token 和 groupId 管理,配置文件与 Claude Code CLI 状态栏版共享(Windows: `%USERPROFILE%\.minimax-config.json`,macOS/Linux: `~/.minimax-config.json`)
20
20
  - 美观输出 - 终端友好的进度条展示
21
21
  - 一键安装 - 自动安装到全局插件目录,无需手动配置
22
+ - 便捷更新 - 开发调试时可使用 `minimax-status-update` 命令同步最新代码
22
23
 
23
24
  ## 安装
24
25
 
@@ -26,11 +27,11 @@
26
27
  npm install -g @miloya/oc-minimax-status
27
28
  ```
28
29
 
29
- 安装过程会自动:
30
- 1. 复制插件到全局插件目录 (~/.config/opencode/plugins)
31
- 2. 复制 /minimax 命令到全局命令目录 (~/.config/opencode/command)
32
- 3. 添加插件到 opencode.json 配置
33
- 4. 显示使用说明
30
+ 安装过程会自动:
31
+ 1. 复制插件到全局插件目录 (~/.config/opencode/plugins)
32
+ 2. 复制 /minimax 命令到全局命令目录 (~/.config/opencode/command)
33
+ 3. 添加插件到 opencode.json 配置
34
+ 4. 显示使用说明
34
35
 
35
36
  ## 配置认证
36
37
 
@@ -44,40 +45,39 @@ npm install -g @miloya/oc-minimax-status
44
45
 
45
46
  ```json
46
47
  {
47
- "token": "your-api-token",
48
- "groupId": "your-group-id"
48
+ "token": "your-api-token"
49
49
  }
50
50
  ```
51
51
 
52
- ### 如何获取 token 和 groupId
52
+ ### 如何获取 token
53
53
 
54
54
  1. 登录 [https://platform.minimaxi.com/user-center/payment/coding-plan](https://platform.minimaxi.com/user-center/payment/coding-plan)
55
- 2. 获取 API Key 和 Group ID
55
+ 2. 获取 API Key
56
56
 
57
57
  ## 使用方法
58
58
 
59
59
  在 OpenCode 对话框中直接说**自然语言**即可(不是命令行),插件会自动识别并调用对应功能:
60
60
 
61
- ### 查询用量(自然语言或命令)
62
- ```
63
- 查看 minimax 用量
64
- 我的用量还有多少
65
- minimax 状态
66
- /minimax
67
- ```
68
-
69
- ### 管理认证(自然语言或命令)
70
- ```
71
- 查看 minimax 认证
72
- 设置 minimax 认证 tokenxxx groupIdxxx
73
- /minimax set tokenxxx groupIdxxx
74
- ```
61
+ ### 查询用量(自然语言或命令)
62
+ ```
63
+ 查看 minimax 用量
64
+ 我的用量还有多少
65
+ minimax 状态
66
+ /minimax
67
+ ```
68
+
69
+ ### 管理认证(自然语言或命令)
70
+ ```
71
+ 查看 minimax 认证
72
+ 设置 minimax 认证 tokenxxx groupIdxxx
73
+ /minimax set tokenxxx groupIdxxx
74
+ ```
75
75
 
76
76
  ### 直接调用工具名
77
77
  ```
78
78
  minimax_status
79
79
  minimax_auth action=get
80
- minimax_auth action=set token=xxx groupId=xxx
80
+ minimax_auth action=set token=xxx
81
81
  ```
82
82
 
83
83
  ## 输出示例
@@ -85,14 +85,18 @@ minimax_auth action=set token=xxx groupId=xxx
85
85
  ### 用量查询成功
86
86
 
87
87
  ```
88
- MiniMax Claude Code 用量状态
89
- ==============================
90
- Model: MiniMax-M2
91
- 已用: 1,500 / 4,500
92
- 进度: [███░░░░░░] 33%
93
- 剩余: 3,000
94
- 重置: 2026/02/26 14:30 (2h 30m)
95
- ==============================
88
+ MiniMax Coding Plan 用量状态
89
+ ----------------------------------------
90
+ 模型: MiniMax-M2
91
+ 已用(5h): 191 / 4,500
92
+ 进度: [█░░░░░░░░] 4%
93
+ 剩余(5h): 4,309 次
94
+ 重置: 2026/03/19 00:00 (约3小时后)
95
+ ----------------------------------------
96
+ 周用量: 2,091 / 157,500
97
+ 周进度: [█░░░░░░░░] 1%
98
+ 周重置: 2026/03/23 00:00 (约4天2小时后)
99
+ ----------------------------------------
96
100
  ```
97
101
 
98
102
  ### 未配置认证
@@ -104,13 +108,12 @@ Model: MiniMax-M2
104
108
  1. 如果已安装 Claude Code 版 minimax-status,配置文件已自动共享,无需重复配置
105
109
  2. 或手动创建 ~/.minimax-config.json:
106
110
  {
107
- "token": "your-api-token",
108
- "groupId": "your-group-id"
111
+ "token": "your-api-token"
109
112
  }
110
113
 
111
- 获取 token 和 groupId:
114
+ 获取 token:
112
115
  1. 登录 https://platform.minimaxi.com/user-center/payment/coding-plan
113
- 2. 获取 API Key 和 Group ID
116
+ 2. 获取 API Key
114
117
  ```
115
118
 
116
119
  ## 相关项目
package/bin/update.js ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Update script - syncs plugin files to global plugins directory
3
+ * Run manually after code updates without needing full npm reinstall
4
+ */
5
+
6
+ import fs from "fs";
7
+ import path from "path";
8
+ import { execSync } from "child_process";
9
+
10
+ const PLUGIN_NAME = "oc-minimax-status";
11
+
12
+ function getGlobalPluginsDir() {
13
+ const home = process.env.HOME || process.env.USERPROFILE;
14
+ return path.join(home, ".config", "opencode", "plugins");
15
+ }
16
+
17
+ function getCommandDir() {
18
+ const home = process.env.HOME || process.env.USERPROFILE;
19
+ return path.join(home, ".config", "opencode", "commands");
20
+ }
21
+
22
+ function getPackageDir() {
23
+ const pkgJson = process.env.npm_package_json;
24
+ if (pkgJson) {
25
+ return path.dirname(pkgJson);
26
+ }
27
+ return process.cwd();
28
+ }
29
+
30
+ async function update() {
31
+ console.log("\n-- MiniMax Status Plugin Updating --\n");
32
+
33
+ const globalPluginsDir = getGlobalPluginsDir();
34
+ const packageDir = getPackageDir();
35
+
36
+ // Sync index.js
37
+ console.log("-- Syncing plugin files...");
38
+ const srcIndex = path.join(packageDir, "index.js");
39
+ const destIndex = path.join(globalPluginsDir, `${PLUGIN_NAME}.js`);
40
+
41
+ if (!fs.existsSync(srcIndex)) {
42
+ console.error(` [FAIL] Source file not found: ${srcIndex}`);
43
+ console.log(" Make sure you run this from the plugin directory.");
44
+ return;
45
+ }
46
+
47
+ fs.copyFileSync(srcIndex, destIndex);
48
+ console.log(` [OK] Synced ${PLUGIN_NAME}.js`);
49
+
50
+ // Sync command files
51
+ const commandDir = getCommandDir();
52
+ if (!fs.existsSync(commandDir)) {
53
+ fs.mkdirSync(commandDir, { recursive: true });
54
+ }
55
+
56
+ const cmdFiles = ["minimax.md", "minimax-set.md", "minimax-update.md"];
57
+ for (const cmdFile of cmdFiles) {
58
+ const srcCommand = path.join(packageDir, "commands", cmdFile);
59
+ const destCommand = path.join(commandDir, cmdFile);
60
+ if (fs.existsSync(srcCommand)) {
61
+ fs.copyFileSync(srcCommand, destCommand);
62
+ console.log(` [OK] Synced /${cmdFile.replace(".md", "")} command`);
63
+ }
64
+ }
65
+
66
+ // Ensure axios is installed
67
+ console.log("-- Checking dependencies...");
68
+ try {
69
+ execSync("npm install axios", {
70
+ cwd: globalPluginsDir,
71
+ stdio: "pipe"
72
+ });
73
+ console.log(" [OK] axios installed");
74
+ } catch (e) {
75
+ console.log(" [SKIP] axios already installed");
76
+ }
77
+
78
+ console.log("\n-- Update complete --\n");
79
+ console.log("Restart OpenCode to use the updated plugin.\n");
80
+ }
81
+
82
+ update().catch(console.error);
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: Update MiniMax Status plugin to latest version
3
+ ---
4
+
5
+ The user wants to update the MiniMax Status plugin.
6
+
7
+ Run the update script to sync the latest plugin files to the global plugins directory.
8
+
9
+ Execute: `node bin/update.js` or `minimax-status-update`
package/index.js CHANGED
@@ -28,15 +28,14 @@ function getCredentials() {
28
28
  }
29
29
 
30
30
  function saveCredentials(token, groupId) {
31
- const config = { token, groupId };
31
+ const config = { token };
32
32
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
33
33
  }
34
34
 
35
- async function fetchUsageStatus(token, groupId) {
35
+ async function fetchUsageStatus(token) {
36
36
  const response = await axios.get(
37
37
  "https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains",
38
38
  {
39
- params: { GroupId: groupId },
40
39
  headers: {
41
40
  Authorization: `Bearer ${token}`,
42
41
  Accept: "application/json",
@@ -71,6 +70,24 @@ function parseUsageData(apiData) {
71
70
  minute: "2-digit",
72
71
  });
73
72
 
73
+ // 周用量计算
74
+ const weeklyRemaining = m.current_weekly_usage_count;
75
+ const weeklyTotal = m.current_weekly_total_count;
76
+ const weeklyUsed = weeklyTotal - weeklyRemaining;
77
+ const weeklyPercentage = Math.floor((weeklyUsed / weeklyTotal) * 100);
78
+ const weeklyRemainingMs = m.weekly_remains_time;
79
+ const weeklyDays = Math.floor(weeklyRemainingMs / (1000 * 60 * 60 * 24));
80
+ const weeklyHours = Math.floor((weeklyRemainingMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
81
+
82
+ const weeklyResetTime = new Date(m.weekly_end_time).toLocaleString("zh-CN", {
83
+ timeZone: "Asia/Shanghai",
84
+ year: "numeric",
85
+ month: "2-digit",
86
+ day: "2-digit",
87
+ hour: "2-digit",
88
+ minute: "2-digit",
89
+ });
90
+
74
91
  return {
75
92
  modelName: m.model_name,
76
93
  used,
@@ -80,22 +97,35 @@ function parseUsageData(apiData) {
80
97
  resetTime,
81
98
  hours,
82
99
  minutes,
100
+ weeklyUsed,
101
+ weeklyTotal,
102
+ weeklyPercentage,
103
+ weeklyDays,
104
+ weeklyHours,
105
+ weeklyResetTime,
83
106
  };
84
107
  }
85
108
 
86
109
  function formatOutput(data) {
87
- const { modelName, used, total, remaining, percentage, resetTime, hours, minutes } = data;
88
-
110
+ const { modelName, used, total, remaining, percentage, resetTime, hours, minutes, weeklyUsed, weeklyTotal, weeklyPercentage, weeklyDays, weeklyHours, weeklyResetTime } = data;
111
+
89
112
  const bar = "█".repeat(Math.floor(percentage / 10)) + "░".repeat(10 - Math.floor(percentage / 10));
90
113
  const timeText = hours > 0 ? `${hours}小时${minutes}分钟` : `${minutes}分钟`;
91
114
 
115
+ const weeklyBar = "█".repeat(Math.floor(weeklyPercentage / 10)) + "░".repeat(10 - Math.floor(weeklyPercentage / 10));
116
+ const weeklyTimeText = weeklyDays > 0 ? `${weeklyDays}天${weeklyHours}小时` : `${weeklyHours}小时`;
117
+
92
118
  return `MiniMax Coding Plan 用量状态
93
119
  ----------------------------------------
94
120
  模型: ${modelName}
95
- 已用: ${used.toLocaleString()} / ${total.toLocaleString()}
121
+ 已用(5h): ${used.toLocaleString()} / ${total.toLocaleString()}
96
122
  进度: [${bar}] ${percentage}%
97
- 剩余: ${remaining.toLocaleString()} 次
123
+ 剩余(5h): ${remaining.toLocaleString()} 次
98
124
  重置: ${resetTime} (约${timeText})
125
+ ----------------------------------------
126
+ 周用量: ${weeklyUsed.toLocaleString()} / ${weeklyTotal.toLocaleString()}
127
+ 周进度: [${weeklyBar}] ${weeklyPercentage}%
128
+ 周重置: ${weeklyResetTime} (约${weeklyTimeText})
99
129
  ----------------------------------------`;
100
130
  }
101
131
 
@@ -111,29 +141,28 @@ export const MiniMaxStatusPlugin = async (ctx) => {
111
141
  try {
112
142
  const credentials = getCredentials();
113
143
 
114
- if (!credentials?.token || !credentials?.groupId) {
144
+ if (!credentials?.token) {
115
145
  return `请先配置认证信息!
116
146
 
117
147
  配置方式:
118
148
  1. 如果已安装 Claude Code 版 minimax-status,配置文件已自动共享,无需重复配置
119
149
  2. 或手动创建 ~/.minimax-config.json:
120
150
  {
121
- "token": "your-api-token",
122
- "groupId": "your-group-id"
151
+ "token": "your-api-token"
123
152
  }
124
153
 
125
- 获取 token 和 groupId:
154
+ 获取 token:
126
155
  1. 登录 https://platform.minimaxi.com/user-center/payment/coding-plan
127
- 2. 获取 API Key 和 Group ID`;
156
+ 2. 获取 API Key`;
128
157
  }
129
158
 
130
- const apiData = await fetchUsageStatus(credentials.token, credentials.groupId);
159
+ const apiData = await fetchUsageStatus(credentials.token);
131
160
  const usageData = parseUsageData(apiData);
132
161
 
133
162
  return formatOutput(usageData);
134
163
  } catch (error) {
135
164
  if (error.response?.status === 401) {
136
- return "认证失败,请检查 token 和 groupId 是否正确";
165
+ return "认证失败,请检查 token 是否正确";
137
166
  }
138
167
  if (error.code === "ECONNABORTED") {
139
168
  return "请求超时,请检查网络连接";
@@ -153,19 +182,18 @@ export const MiniMaxStatusPlugin = async (ctx) => {
153
182
  async execute(args, context) {
154
183
  if (args.action === "get") {
155
184
  const creds = getCredentials();
156
- if (!creds || !creds.token || !creds.groupId) {
157
- return "未配置认证信息。请使用 action=set 设置 token 和 groupId";
185
+ if (!creds || !creds.token) {
186
+ return "未配置认证信息。请使用 action=set 设置 token";
158
187
  }
159
188
  return `当前认证信息:
160
- - Token: ${creds.token ? "****" + creds.token.slice(-4) : "未设置"}
161
- - GroupID: ${creds.groupId || "未设置"}`;
189
+ - Token: ${creds.token ? "****" + creds.token.slice(-4) : "未设置"}`;
162
190
  }
163
-
191
+
164
192
  if (args.action === "set") {
165
- if (!args.token || !args.groupId) {
166
- return "设置认证需要提供 token 和 groupId 两个参数";
193
+ if (!args.token) {
194
+ return "设置认证需要提供 token 参数";
167
195
  }
168
- saveCredentials(args.token, args.groupId);
196
+ saveCredentials(args.token, args.groupId || null);
169
197
  return "认证信息已保存到 ~/.minimax-config.json";
170
198
  }
171
199
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miloya/oc-minimax-status",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "MiniMax Coding Plan 用量查询插件 for OpenCode - 一键安装自动配置",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -11,13 +11,13 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/JochenYang/oc-minimax-status"
13
13
  },
14
- "files": [
15
- "index.js",
16
- "bin/",
17
- "commands/",
18
- "README.md",
19
- "LICENSE"
20
- ],
14
+ "files": [
15
+ "index.js",
16
+ "bin/",
17
+ "commands/",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
21
  "dependencies": {
22
22
  "axios": "^1.6.0"
23
23
  },
@@ -34,6 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "bin": {
37
- "minimax-status-init": "./bin/init.js"
37
+ "minimax-status-init": "./bin/init.js",
38
+ "minimax-status-update": "./bin/update.js"
38
39
  }
39
40
  }