@yakumoryo/minimax-plan-usage 0.2.5 → 0.2.6

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
@@ -1,25 +1,36 @@
1
1
  # MiniMax Plan Usage
2
2
 
3
- Query MiniMax Coding Plan usage statistics.
3
+ Query MiniMax Coding Plan usage statistics via CLI.
4
4
 
5
- ## Usage
5
+ ## Installation
6
6
 
7
- After installation, run:
8
- ```
9
- /minimax-plan-usage:usage-query
7
+ ```bash
8
+ npm install -g @yakumoryo/minimax-plan-usage
10
9
  ```
11
10
 
12
- ## How it works
11
+ ## Usage
13
12
 
14
- The plugin uses the same `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL` that Claude Code uses. Based on the base URL, it determines the correct MiniMax API endpoint:
13
+ ```bash
14
+ minimax-plan-usage
15
+ ```
15
16
 
16
- - If `ANTHROPIC_BASE_URL` contains `minimax.io` → uses `https://minimax.io`
17
- - Otherwise → uses `https://api.minimaxi.com` (default)
17
+ Or with npx:
18
+
19
+ ```bash
20
+ npx @yakumoryo/minimax-plan-usage
21
+ ```
18
22
 
19
23
  ## Requirements
20
24
 
21
- - Node.js installed
25
+ - Node.js >= 18
22
26
  - `ANTHROPIC_AUTH_TOKEN` environment variable set
23
27
  - `ANTHROPIC_BASE_URL` environment variable set
24
28
 
25
29
  These are typically already configured in your Claude Code settings.
30
+
31
+ ## How it works
32
+
33
+ The CLI uses the same `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL` that Claude Code uses. Based on the base URL, it determines the correct MiniMax API endpoint:
34
+
35
+ - If `ANTHROPIC_BASE_URL` contains `minimax.io` → uses `https://minimax.io`
36
+ - Otherwise → uses `https://api.minimaxi.com` (default)
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
3
+ "name": "minimax-plan-usage",
4
+ "version": "0.2.5",
5
+ "description": "Query quota and usage statistics for MiniMax Coding Plan service",
6
+ "owner": { "name": "yakumo96" },
7
+ "plugins": [{
8
+ "name": "minimax-plan-usage",
9
+ "source": "./",
10
+ "category": "development",
11
+ "description": "Query quota and usage statistics for MiniMax Coding Plan service. Uses ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL from your Claude Code settings."
12
+ }]
13
+ }
package/package.json CHANGED
@@ -1,18 +1,10 @@
1
1
  {
2
2
  "name": "@yakumoryo/minimax-plan-usage",
3
- "version": "0.2.5",
4
- "description": "MiniMax Coding Plan setup helper and usage query tool",
3
+ "version": "0.2.6",
4
+ "description": "MiniMax Coding Plan usage query CLI tool",
5
5
  "type": "module",
6
6
  "keywords": [
7
- "minimax",
8
- "claude-code"
9
- ],
10
- "files": [
11
- "commands",
12
- "agents",
13
- "skills",
14
- ".claude-plugin",
15
- "query.js"
7
+ "minimax"
16
8
  ],
17
9
  "engines": {
18
10
  "node": ">=18"
@@ -1,17 +0,0 @@
1
- {
2
- "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
3
- "name": "@yakumoryo/minimax-plan-usage",
4
- "version": "0.1.0",
5
- "description": "Query quota and usage statistics for MiniMax Coding Plan service",
6
- "owner": {
7
- "name": "User"
8
- },
9
- "plugins": [
10
- {
11
- "name": "@yakumoryo/minimax-plan-usage",
12
- "source": ".",
13
- "category": "development",
14
- "description": "Query quota and usage statistics for MiniMax Coding Plan service. Uses ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL from your Claude Code settings."
15
- }
16
- ]
17
- }
@@ -1,6 +0,0 @@
1
- {
2
- "name": "minimax-plan-usage",
3
- "description": "Query MiniMax Coding Plan usage statistics",
4
- "version": "0.2.5",
5
- "owner": "user"
6
- }
@@ -1,32 +0,0 @@
1
- ---
2
- name: usage-query-agent
3
- description: Query MiniMax Coding Plan usage statistics for the current account. Triggered by the /minimax-plan-usage:usage-query command.
4
- tools: Bash, Read, Skill, Glob, Grep
5
- ---
6
-
7
- # Usage Query Agent
8
-
9
- You are responsible for querying the user's current usage information.
10
-
11
- ## Critical constraint
12
-
13
- **Run the query exactly once.** Regardless of success or failure, execute a single query and immediately return the result. No retries, no loops.
14
-
15
- ## Execution
16
-
17
- ### Invoke the skill
18
-
19
- Call @minimax-plan-usage:usage-query-skill to perform the usage query.
20
-
21
- The skill will run query-usage.mjs automatically, then return the result.
22
-
23
- ### Report the outcome
24
-
25
- Based on the skill output, respond to the user in Chinese.
26
-
27
- ## Prohibited actions
28
-
29
- - Do not run multiple queries
30
- - Do not retry automatically after failure
31
- - Do not ask the user whether to retry
32
- - Do not modify files
@@ -1,13 +0,0 @@
1
- ---
2
- name: usage-query
3
- allowed-tools: all
4
- description: Query MiniMax Coding Plan usage statistics
5
- ---
6
-
7
- # Usage Query
8
-
9
- Invoke @minimax-plan-usage:usage-query-agent to retrieve the usage information for the current account.
10
-
11
- ## Critical constraint
12
-
13
- **Run the query exactly once** — regardless of success or failure, execute a single query and return the result immediately.
@@ -1,29 +0,0 @@
1
- ---
2
- name: usage-query-skill
3
- description: Run the usage query script to retrieve account usage information for MiniMax Coding Plan. Only use when invoked by usage-query-agent.
4
- allowed-tools: Bash, Read
5
- ---
6
-
7
- # MiniMax Usage Query Skill
8
-
9
- Execute the usage query script and return the result.
10
-
11
- ## Critical constraint
12
-
13
- **Run the script exactly once** — regardless of success or failure, execute it once and return the outcome.
14
-
15
- ## Execution
16
-
17
- ### Run the query
18
-
19
- Use Node.js to execute the bundled script:
20
-
21
- ```bash
22
- node skills/usage-query-skill/scripts/query-usage.mjs
23
- ```
24
-
25
- ### Return the result
26
-
27
- After execution, return the result to the caller:
28
- - **Success**: display the usage information in Chinese
29
- - **Failure**: show the error details and likely cause
@@ -1,146 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * MiniMax Usage Query Script
5
- * Reads ANTHROPIC_BASE_URL to determine API endpoint
6
- * Uses ANTHROPIC_AUTH_TOKEN as the API key
7
- */
8
-
9
- import https from 'https';
10
-
11
- const baseUrl = process.env.ANTHROPIC_BASE_URL || '';
12
- const authToken = process.env.ANTHROPIC_AUTH_TOKEN || '';
13
-
14
- if (!authToken) {
15
- console.error('Error: ANTHROPIC_AUTH_TOKEN is not set');
16
- console.error('');
17
- console.error('Set the environment variable and retry:');
18
- console.error(' export ANTHROPIC_AUTH_TOKEN="your-token-here"');
19
- process.exit(1);
20
- }
21
-
22
- let apiHost = 'https://api.minimaxi.com';
23
-
24
- if (baseUrl.includes('minimax.io')) {
25
- apiHost = 'https://minimax.io';
26
- } else {
27
- apiHost = 'https://api.minimaxi.com';
28
- }
29
-
30
- const apiUrl = `${apiHost}/v1/api/openplatform/coding_plan/remains`;
31
-
32
- console.log(`MiniMax API Host: ${apiHost}`);
33
- console.log('');
34
-
35
- const queryUsage = () => {
36
- return new Promise((resolve, reject) => {
37
- const parsedUrl = new URL(apiUrl);
38
- const options = {
39
- hostname: parsedUrl.hostname,
40
- port: 443,
41
- path: parsedUrl.pathname,
42
- method: 'GET',
43
- headers: {
44
- 'Authorization': `Bearer ${authToken}`,
45
- 'Accept': 'application/json'
46
- }
47
- };
48
-
49
- const req = https.request(options, (res) => {
50
- let data = '';
51
-
52
- res.on('data', (chunk) => {
53
- data += chunk;
54
- });
55
-
56
- res.on('end', () => {
57
- if (res.statusCode !== 200) {
58
- if (res.statusCode === 401) {
59
- return reject(new Error('认证失败,请检查 ANTHROPIC_AUTH_TOKEN 是否正确'));
60
- }
61
- return reject(new Error(`HTTP ${res.statusCode}: ${data}`));
62
- }
63
-
64
- try {
65
- const json = JSON.parse(data);
66
- if (!json.model_remains || json.model_remains.length === 0) {
67
- console.log('无可用用量数据');
68
- return resolve();
69
- }
70
-
71
- const m = json.model_remains[0];
72
- const remaining = m.current_interval_remaining_count;
73
- const total = m.current_interval_total_count;
74
- const used = total - remaining;
75
- const percentage = Math.round((used / total) * 100);
76
-
77
- const remainingMs = m.remains_time;
78
- const hours = Math.floor(remainingMs / (1000 * 60 * 60));
79
- const minutes = Math.floor((remainingMs % (1000 * 60 * 60)) / (1000 * 60));
80
-
81
- const resetTime = new Date(m.end_time).toLocaleString('zh-CN', {
82
- timeZone: 'Asia/Shanghai',
83
- year: 'numeric',
84
- month: '2-digit',
85
- day: '2-digit',
86
- hour: '2-digit',
87
- minute: '2-digit',
88
- });
89
-
90
- const weeklyRemaining = m.current_weekly_remaining_count;
91
- const weeklyTotal = m.current_weekly_total_count;
92
- const weeklyUsed = weeklyTotal - weeklyRemaining;
93
- const weeklyPercentage = Math.floor((weeklyUsed / weeklyTotal) * 100);
94
- const weeklyRemainingMs = m.weekly_remains_time;
95
- const weeklyDays = Math.floor(weeklyRemainingMs / (1000 * 60 * 60 * 24));
96
- const weeklyHours = Math.floor((weeklyRemainingMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
97
-
98
- const weeklyResetTime = new Date(m.weekly_end_time).toLocaleString('zh-CN', {
99
- timeZone: 'Asia/Shanghai',
100
- year: 'numeric',
101
- month: '2-digit',
102
- day: '2-digit',
103
- hour: '2-digit',
104
- minute: '2-digit',
105
- });
106
-
107
- const bar = '█'.repeat(Math.floor(percentage / 10)) + '░'.repeat(10 - Math.floor(percentage / 10));
108
- const timeText = hours > 0 ? `${hours}小时${minutes}分钟` : `${minutes}分钟`;
109
- const weeklyBar = '█'.repeat(Math.floor(weeklyPercentage / 10)) + '░'.repeat(10 - Math.floor(weeklyPercentage / 10));
110
- const weeklyTimeText = weeklyDays > 0 ? `${weeklyDays}天${weeklyHours}小时` : `${weeklyHours}小时`;
111
-
112
- console.log('MiniMax Coding Plan 用量状态');
113
- console.log('----------------------------------------');
114
- console.log(`模型: ${m.model_name}`);
115
- console.log(`已用(5h): ${used.toLocaleString()} / ${total.toLocaleString()}`);
116
- console.log(`进度: [${bar}] ${percentage}%`);
117
- console.log(`剩余(5h): ${remaining.toLocaleString()} 次`);
118
- console.log(`重置: ${resetTime} (约${timeText})`);
119
- console.log('----------------------------------------');
120
- console.log(`周用量: ${weeklyUsed.toLocaleString()} / ${weeklyTotal.toLocaleString()}`);
121
- console.log(`周进度: [${weeklyBar}] ${weeklyPercentage}%`);
122
- console.log(`周重置: ${weeklyResetTime} (约${weeklyTimeText})`);
123
- console.log('----------------------------------------');
124
-
125
- } catch (e) {
126
- return reject(new Error(`解析响应失败: ${e.message}`));
127
- }
128
- resolve();
129
- });
130
- });
131
-
132
- req.on('error', (error) => {
133
- if (error.code === 'ECONNABORTED') {
134
- return reject(new Error('请求超时,请检查网络连接'));
135
- }
136
- reject(error);
137
- });
138
-
139
- req.end();
140
- });
141
- };
142
-
143
- queryUsage().catch((error) => {
144
- console.error('查询失败:', error.message);
145
- process.exit(1);
146
- });