@miloya/oc-minimax-status 0.1.6 → 0.3.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 +33 -28
- package/bin/update.js +82 -0
- package/commands/minimax-update.md +9 -0
- package/index.js +35 -52
- package/package.json +10 -9
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
|
|
|
@@ -58,20 +59,20 @@ npm install -g @miloya/oc-minimax-status
|
|
|
58
59
|
|
|
59
60
|
在 OpenCode 对话框中直接说**自然语言**即可(不是命令行),插件会自动识别并调用对应功能:
|
|
60
61
|
|
|
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
|
-
```
|
|
62
|
+
### 查询用量(自然语言或命令)
|
|
63
|
+
```
|
|
64
|
+
查看 minimax 用量
|
|
65
|
+
我的用量还有多少
|
|
66
|
+
minimax 状态
|
|
67
|
+
/minimax
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 管理认证(自然语言或命令)
|
|
71
|
+
```
|
|
72
|
+
查看 minimax 认证
|
|
73
|
+
设置 minimax 认证 tokenxxx groupIdxxx
|
|
74
|
+
/minimax set tokenxxx groupIdxxx
|
|
75
|
+
```
|
|
75
76
|
|
|
76
77
|
### 直接调用工具名
|
|
77
78
|
```
|
|
@@ -85,14 +86,18 @@ minimax_auth action=set token=xxx groupId=xxx
|
|
|
85
86
|
### 用量查询成功
|
|
86
87
|
|
|
87
88
|
```
|
|
88
|
-
MiniMax
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
进度: [
|
|
93
|
-
|
|
94
|
-
重置: 2026/
|
|
95
|
-
|
|
89
|
+
MiniMax Coding Plan 用量状态
|
|
90
|
+
----------------------------------------
|
|
91
|
+
模型: MiniMax-M2
|
|
92
|
+
已用(5h): 191 / 4,500
|
|
93
|
+
进度: [█░░░░░░░░] 4%
|
|
94
|
+
剩余(5h): 4,309 次
|
|
95
|
+
重置: 2026/03/19 00:00 (约3小时后)
|
|
96
|
+
----------------------------------------
|
|
97
|
+
周用量: 2,091 / 157,500
|
|
98
|
+
周进度: [█░░░░░░░░] 1%
|
|
99
|
+
周重置: 2026/03/23 00:00 (约4天2小时后)
|
|
100
|
+
----------------------------------------
|
|
96
101
|
```
|
|
97
102
|
|
|
98
103
|
### 未配置认证
|
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
|
@@ -10,60 +10,12 @@ import { tool } from "@opencode-ai/plugin";
|
|
|
10
10
|
import axios from "axios";
|
|
11
11
|
import fs from "fs";
|
|
12
12
|
import path from "path";
|
|
13
|
-
import { fileURLToPath } from "url";
|
|
14
13
|
|
|
15
14
|
const CONFIG_PATH = path.join(
|
|
16
15
|
process.env.HOME || process.env.USERPROFILE,
|
|
17
16
|
".minimax-config.json"
|
|
18
17
|
);
|
|
19
18
|
|
|
20
|
-
function syncPluginFiles() {
|
|
21
|
-
try {
|
|
22
|
-
let pkgDir;
|
|
23
|
-
const home = process.env.HOME || process.env.USERPROFILE;
|
|
24
|
-
|
|
25
|
-
// Try multiple ways to find package directory
|
|
26
|
-
if (process.env.BUN_INSTALL_CACHE_DIR) {
|
|
27
|
-
pkgDir = path.join(process.env.BUN_INSTALL_CACHE_DIR, "node_modules", "@miloya", "oc-minimax-status");
|
|
28
|
-
} else if (process.env.npm_package_json) {
|
|
29
|
-
pkgDir = path.dirname(process.env.npm_package_json);
|
|
30
|
-
} else if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
31
|
-
pkgDir = path.dirname(fileURLToPath(import.meta.url));
|
|
32
|
-
} else {
|
|
33
|
-
pkgDir = path.join(home, ".cache", "opencode", "node_modules", "@miloya", "oc-minimax-status");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
console.log("[minimax-status] Syncing from:", pkgDir);
|
|
37
|
-
|
|
38
|
-
const plugins = path.join(home, ".config", "opencode", "plugins");
|
|
39
|
-
const commands = path.join(home, ".config", "opencode", "commands");
|
|
40
|
-
|
|
41
|
-
const srcIndex = path.join(pkgDir, "index.js");
|
|
42
|
-
const destIndex = path.join(plugins, "oc-minimax-status.js");
|
|
43
|
-
if (fs.existsSync(srcIndex)) {
|
|
44
|
-
if (!fs.existsSync(plugins)) fs.mkdirSync(plugins, { recursive: true });
|
|
45
|
-
fs.copyFileSync(srcIndex, destIndex);
|
|
46
|
-
console.log("[minimax-status] Copied index.js");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const srcCmdDir = path.join(pkgDir, "commands");
|
|
50
|
-
if (fs.existsSync(srcCmdDir)) {
|
|
51
|
-
if (!fs.existsSync(commands)) fs.mkdirSync(commands, { recursive: true });
|
|
52
|
-
const files = fs.readdirSync(srcCmdDir);
|
|
53
|
-
for (const file of files) {
|
|
54
|
-
if (file.endsWith(".md")) {
|
|
55
|
-
fs.copyFileSync(path.join(srcCmdDir, file), path.join(commands, file));
|
|
56
|
-
console.log("[minimax-status] Copied", file);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} catch (e) {
|
|
61
|
-
console.log("[minimax-status] Sync error:", e.message);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
syncPluginFiles();
|
|
66
|
-
|
|
67
19
|
function getCredentials() {
|
|
68
20
|
try {
|
|
69
21
|
if (fs.existsSync(CONFIG_PATH)) {
|
|
@@ -119,6 +71,24 @@ function parseUsageData(apiData) {
|
|
|
119
71
|
minute: "2-digit",
|
|
120
72
|
});
|
|
121
73
|
|
|
74
|
+
// 周用量计算
|
|
75
|
+
const weeklyRemaining = m.current_weekly_usage_count;
|
|
76
|
+
const weeklyTotal = m.current_weekly_total_count;
|
|
77
|
+
const weeklyUsed = weeklyTotal - weeklyRemaining;
|
|
78
|
+
const weeklyPercentage = Math.floor((weeklyUsed / weeklyTotal) * 100);
|
|
79
|
+
const weeklyRemainingMs = m.weekly_remains_time;
|
|
80
|
+
const weeklyDays = Math.floor(weeklyRemainingMs / (1000 * 60 * 60 * 24));
|
|
81
|
+
const weeklyHours = Math.floor((weeklyRemainingMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
82
|
+
|
|
83
|
+
const weeklyResetTime = new Date(m.weekly_end_time).toLocaleString("zh-CN", {
|
|
84
|
+
timeZone: "Asia/Shanghai",
|
|
85
|
+
year: "numeric",
|
|
86
|
+
month: "2-digit",
|
|
87
|
+
day: "2-digit",
|
|
88
|
+
hour: "2-digit",
|
|
89
|
+
minute: "2-digit",
|
|
90
|
+
});
|
|
91
|
+
|
|
122
92
|
return {
|
|
123
93
|
modelName: m.model_name,
|
|
124
94
|
used,
|
|
@@ -128,22 +98,35 @@ function parseUsageData(apiData) {
|
|
|
128
98
|
resetTime,
|
|
129
99
|
hours,
|
|
130
100
|
minutes,
|
|
101
|
+
weeklyUsed,
|
|
102
|
+
weeklyTotal,
|
|
103
|
+
weeklyPercentage,
|
|
104
|
+
weeklyDays,
|
|
105
|
+
weeklyHours,
|
|
106
|
+
weeklyResetTime,
|
|
131
107
|
};
|
|
132
108
|
}
|
|
133
109
|
|
|
134
110
|
function formatOutput(data) {
|
|
135
|
-
const { modelName, used, total, remaining, percentage, resetTime, hours, minutes } = data;
|
|
136
|
-
|
|
111
|
+
const { modelName, used, total, remaining, percentage, resetTime, hours, minutes, weeklyUsed, weeklyTotal, weeklyPercentage, weeklyDays, weeklyHours, weeklyResetTime } = data;
|
|
112
|
+
|
|
137
113
|
const bar = "█".repeat(Math.floor(percentage / 10)) + "░".repeat(10 - Math.floor(percentage / 10));
|
|
138
114
|
const timeText = hours > 0 ? `${hours}小时${minutes}分钟` : `${minutes}分钟`;
|
|
139
115
|
|
|
116
|
+
const weeklyBar = "█".repeat(Math.floor(weeklyPercentage / 10)) + "░".repeat(10 - Math.floor(weeklyPercentage / 10));
|
|
117
|
+
const weeklyTimeText = weeklyDays > 0 ? `${weeklyDays}天${weeklyHours}小时` : `${weeklyHours}小时`;
|
|
118
|
+
|
|
140
119
|
return `MiniMax Coding Plan 用量状态
|
|
141
120
|
----------------------------------------
|
|
142
121
|
模型: ${modelName}
|
|
143
|
-
|
|
122
|
+
已用(5h): ${used.toLocaleString()} / ${total.toLocaleString()}
|
|
144
123
|
进度: [${bar}] ${percentage}%
|
|
145
|
-
|
|
124
|
+
剩余(5h): ${remaining.toLocaleString()} 次
|
|
146
125
|
重置: ${resetTime} (约${timeText})
|
|
126
|
+
----------------------------------------
|
|
127
|
+
周用量: ${weeklyUsed.toLocaleString()} / ${weeklyTotal.toLocaleString()}
|
|
128
|
+
周进度: [${weeklyBar}] ${weeklyPercentage}%
|
|
129
|
+
周重置: ${weeklyResetTime} (约${weeklyTimeText})
|
|
147
130
|
----------------------------------------`;
|
|
148
131
|
}
|
|
149
132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miloya/oc-minimax-status",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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
|
}
|