zusage 1.0.1 β†’ 1.0.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.
Files changed (3) hide show
  1. package/README.md +8 -8
  2. package/bin/index.js +24 -25
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ This tool connects to the Z.ai API to fetch and display your current token consu
11
11
  - Visual progress bar showing token usage percentage
12
12
  - Current tokens used, remaining, and total limit
13
13
  - Time remaining until next reset
14
- - Next reset date and time (Paris timezone)
14
+ - Next reset date and time
15
15
 
16
16
  ## Installation
17
17
 
@@ -47,17 +47,17 @@ zusage
47
47
 
48
48
  ```
49
49
  ==================================================
50
- πŸ“Š Z.AI - UTILISATION DES TOKENS
50
+ πŸ“Š Z.AI - TOKEN USAGE
51
51
  ==================================================
52
52
 
53
- Progression: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 72%
53
+ Progress: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 72%
54
54
 
55
- πŸ“ˆ UtilisΓ©: 145 000 tokens
56
- πŸ“‰ Restant: 55 000 tokens
57
- 🎯 Limite: 200 000 tokens
55
+ πŸ“ˆ Used: 145,000 tokens
56
+ πŸ“‰ Remaining: 55,000 tokens
57
+ 🎯 Limit: 200,000 tokens
58
58
 
59
- ⏱️ Reset dans: 2h 15min
60
- πŸ“… Prochain reset: lundi 11 janvier 2026 Γ  14:30
59
+ ⏱️ Reset in: 2h 15m
60
+ πŸ“… Next reset: Monday, January 11, 2026 at 2:30 PM
61
61
 
62
62
  ==================================================
63
63
  ```
package/bin/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Programme simple pour afficher l'utilisation des tokens Z.ai
3
+ * Simple program to display Z.ai token usage
4
4
  */
5
5
 
6
6
  const BASE_URL = 'https://api.z.ai';
7
7
  const AUTH_TOKEN = process.env.ANTHROPIC_AUTH_TOKEN;
8
8
 
9
9
  if (!AUTH_TOKEN) {
10
- console.error('❌ Erreur: La variable d\'environnement ANTHROPIC_AUTH_TOKEN n\'est pas définie');
10
+ console.error('❌ Error: ANTHROPIC_AUTH_TOKEN environment variable is not set');
11
11
  process.exit(1);
12
12
  }
13
13
 
14
14
  /**
15
- * Récupère les limites de tokens depuis l'API Z.ai
15
+ * Fetches token limits from Z.ai API
16
16
  */
17
17
  async function getTokenLimit() {
18
18
  const response = await fetch(`${BASE_URL}/api/monitor/usage/quota/limit`, {
@@ -34,36 +34,35 @@ async function getTokenLimit() {
34
34
  throw new Error(`API Error: ${data.msg}`);
35
35
  }
36
36
 
37
- // Trouver et retourner uniquement la partie TOKENS_LIMIT
37
+ // Find and return only the TOKENS_LIMIT part
38
38
  const tokensLimit = data.data.limits.find(limit => limit.type === 'TOKENS_LIMIT');
39
39
 
40
40
  if (!tokensLimit) {
41
- throw new Error('TOKENS_LIMIT non trouvΓ© dans la rΓ©ponse');
41
+ throw new Error('TOKENS_LIMIT not found in response');
42
42
  }
43
43
 
44
44
  return tokensLimit;
45
45
  }
46
46
 
47
47
  /**
48
- * Formate un nombre avec sΓ©parateur de milliers
48
+ * Formats a number with thousand separators
49
49
  */
50
50
  function formatNumber(num) {
51
- return new Intl.NumberFormat('fr-FR').format(num);
51
+ return new Intl.NumberFormat('en-US').format(num);
52
52
  }
53
53
 
54
54
  /**
55
- * Formette un timestamp en date lisible
55
+ * Formats a timestamp into a readable date
56
56
  */
57
57
  function formatDate(timestamp) {
58
- return new Date(timestamp).toLocaleString('fr-FR', {
59
- timeZone: 'Europe/Paris',
58
+ return new Date(timestamp).toLocaleString('en-US', {
60
59
  dateStyle: 'full',
61
60
  timeStyle: 'short',
62
61
  });
63
62
  }
64
63
 
65
64
  /**
66
- * Calcule le temps restant jusqu'au reset
65
+ * Calculates time remaining until reset
67
66
  */
68
67
  function getTimeRemaining(nextResetTime) {
69
68
  const now = Date.now();
@@ -74,47 +73,47 @@ function getTimeRemaining(nextResetTime) {
74
73
  const minutes = Math.floor((remaining % (1000 * 60 * 60)) / (1000 * 60));
75
74
 
76
75
  if (days > 0) {
77
- return `${days}j ${hours}h ${minutes}min`;
76
+ return `${days}d ${hours}h ${minutes}m`;
78
77
  } else if (hours > 0) {
79
- return `${hours}h ${minutes}min`;
78
+ return `${hours}h ${minutes}m`;
80
79
  } else {
81
- return `${minutes}min`;
80
+ return `${minutes}m`;
82
81
  }
83
82
  }
84
83
 
85
84
  /**
86
- * Affiche les infos de manière stylisée
85
+ * Displays token info in a stylized manner
87
86
  */
88
87
  function displayTokenInfo(info) {
89
88
  console.log('\n' + '='.repeat(50));
90
- console.log(' πŸ“Š Z.AI - UTILISATION DES TOKENS');
89
+ console.log(' πŸ“Š Z.AI - TOKEN USAGE');
91
90
  console.log('='.repeat(50));
92
91
 
93
- // Barre de progression visuelle
92
+ // Visual progress bar
94
93
  const barLength = 30;
95
94
  const filled = Math.round((info.percentage / 100) * barLength);
96
95
  const empty = barLength - filled;
97
96
  const bar = 'β–ˆ'.repeat(filled) + 'β–‘'.repeat(empty);
98
97
 
99
- console.log(`\n Progression: [${bar}] ${info.percentage}%`);
100
- console.log(`\n πŸ“ˆ UtilisΓ©: ${formatNumber(info.currentValue)} tokens`);
101
- console.log(` πŸ“‰ Restant: ${formatNumber(info.remaining)} tokens`);
102
- console.log(` 🎯 Limite: ${formatNumber(info.usage)} tokens`);
98
+ console.log(`\n Progress: [${bar}] ${info.percentage}%`);
99
+ console.log(`\n πŸ“ˆ Used: ${formatNumber(info.currentValue)} tokens`);
100
+ console.log(` πŸ“‰ Remaining: ${formatNumber(info.remaining)} tokens`);
101
+ console.log(` 🎯 Limit: ${formatNumber(info.usage)} tokens`);
103
102
 
104
103
  const timeRemaining = getTimeRemaining(info.nextResetTime);
105
- console.log(`\n ⏱️ Reset dans: ${timeRemaining}`);
106
- console.log(` πŸ“… Prochain reset: ${formatDate(info.nextResetTime)}`);
104
+ console.log(`\n ⏱️ Reset in: ${timeRemaining}`);
105
+ console.log(` πŸ“… Next reset: ${formatDate(info.nextResetTime)}`);
107
106
 
108
107
  console.log('\n' + '='.repeat(50) + '\n');
109
108
  }
110
109
 
111
- // Point d'entrΓ©e
110
+ // Entry point
112
111
  async function main() {
113
112
  try {
114
113
  const tokenInfo = await getTokenLimit();
115
114
  displayTokenInfo(tokenInfo);
116
115
  } catch (error) {
117
- console.error('❌ Erreur:', error.message);
116
+ console.error('❌ Error:', error.message);
118
117
  process.exit(1);
119
118
  }
120
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zusage",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "CLI tool to monitor Z.ai token usage for Claude Code coding plans",
5
5
  "type": "module",
6
6
  "bin": {