opencode-glm-quota 1.3.3 → 1.3.4

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/dist/index.js CHANGED
@@ -249,10 +249,17 @@ function formatToolUsage(data, quotaData) {
249
249
  * @returns Formatted line with box characters
250
250
  */
251
251
  function formatBoxLine(content, lineIndent) {
252
- const trimmed = trimToDisplayWidth(content, lineIndent);
252
+ const trimmed = trimToDisplayWidth(content, lineIndent, 0);
253
253
  const padding = Math.max(lineIndent - getDisplayWidth(trimmed), 0);
254
254
  return '║ ' + trimmed + ' '.repeat(padding) + '║';
255
255
  }
256
+ function formatProgressBoxLine(content, lineIndent) {
257
+ const gap = 2;
258
+ const contentWidth = Math.max(lineIndent - gap, 0);
259
+ const trimmed = trimToDisplayWidth(content, contentWidth, 0);
260
+ const padding = Math.max(contentWidth - getDisplayWidth(trimmed), 0);
261
+ return '║ ' + trimmed + ' '.repeat(padding + gap) + '║';
262
+ }
256
263
  function getDisplayWidth(text) {
257
264
  let width = 0;
258
265
  for (let i = 0; i < text.length; i += 1) {
@@ -270,9 +277,10 @@ function getDisplayWidth(text) {
270
277
  }
271
278
  return width;
272
279
  }
273
- function trimToDisplayWidth(text, maxWidth) {
280
+ function trimToDisplayWidth(text, maxWidth, reserveRightPadding) {
274
281
  let width = 0;
275
282
  let result = '';
283
+ const allowedWidth = Math.max(maxWidth - reserveRightPadding, 0);
276
284
  for (let i = 0; i < text.length; i += 1) {
277
285
  const codePoint = text.codePointAt(i);
278
286
  if (codePoint === undefined) {
@@ -285,7 +293,7 @@ function trimToDisplayWidth(text, maxWidth) {
285
293
  continue;
286
294
  }
287
295
  const charWidth = isEmojiCodePoint(codePoint) || isFullWidthCodePoint(codePoint) ? 2 : 1;
288
- if (width + charWidth > maxWidth) {
296
+ if (width + charWidth > allowedWidth) {
289
297
  break;
290
298
  }
291
299
  result += String.fromCodePoint(codePoint);
@@ -368,7 +376,7 @@ function formatQuotaLimits(quotaData) {
368
376
  for (const limit of limits) {
369
377
  const pct = typeof limit.percentage === 'number' ? limit.percentage : 0;
370
378
  const line = formatProgressLine(limit.type || 'Unknown', pct);
371
- lines.push(formatBoxLine(line, LINE_INDENT));
379
+ lines.push(formatProgressBoxLine(line, LINE_INDENT));
372
380
  if (limit.nextResetTime !== undefined) {
373
381
  const resetMsg = formatTimeUntilReset(limit.nextResetTime);
374
382
  if (resetMsg) {
@@ -34,8 +34,8 @@ export function formatPercentage(percentage, decimals = 1) {
34
34
  * @returns Formatted progress bar line
35
35
  */
36
36
  export function formatProgressLine(label, percentage) {
37
- const bar = createProgressBar(percentage, { width: 26 });
37
+ const bar = createProgressBar(percentage, { width: 11 });
38
38
  const pctStr = formatPercentage(percentage).padStart(6);
39
39
  const labelStr = label.slice(0, 20).padEnd(20);
40
- return `${labelStr} [${bar}] ${pctStr}`;
40
+ return `${labelStr} [${bar}] ${pctStr}`;
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-glm-quota",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin to query Z.ai GLM Coding Plan usage statistics including quota limits, model usage, and MCP tool usage",
6
6
  "main": "dist/index.js",