opencode-glm-quota 1.3.2 → 1.3.3

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,7 +249,87 @@ function formatToolUsage(data, quotaData) {
249
249
  * @returns Formatted line with box characters
250
250
  */
251
251
  function formatBoxLine(content, lineIndent) {
252
- return '║ ' + content.padEnd(lineIndent) + '║';
252
+ const trimmed = trimToDisplayWidth(content, lineIndent);
253
+ const padding = Math.max(lineIndent - getDisplayWidth(trimmed), 0);
254
+ return '║ ' + trimmed + ' '.repeat(padding) + '║';
255
+ }
256
+ function getDisplayWidth(text) {
257
+ let width = 0;
258
+ for (let i = 0; i < text.length; i += 1) {
259
+ const codePoint = text.codePointAt(i);
260
+ if (codePoint === undefined) {
261
+ continue;
262
+ }
263
+ if (codePoint > 0xffff) {
264
+ i += 1;
265
+ }
266
+ if (isControlCodePoint(codePoint) || isZeroWidthCodePoint(codePoint)) {
267
+ continue;
268
+ }
269
+ width += isEmojiCodePoint(codePoint) || isFullWidthCodePoint(codePoint) ? 2 : 1;
270
+ }
271
+ return width;
272
+ }
273
+ function trimToDisplayWidth(text, maxWidth) {
274
+ let width = 0;
275
+ let result = '';
276
+ for (let i = 0; i < text.length; i += 1) {
277
+ const codePoint = text.codePointAt(i);
278
+ if (codePoint === undefined) {
279
+ continue;
280
+ }
281
+ if (codePoint > 0xffff) {
282
+ i += 1;
283
+ }
284
+ if (isControlCodePoint(codePoint) || isZeroWidthCodePoint(codePoint)) {
285
+ continue;
286
+ }
287
+ const charWidth = isEmojiCodePoint(codePoint) || isFullWidthCodePoint(codePoint) ? 2 : 1;
288
+ if (width + charWidth > maxWidth) {
289
+ break;
290
+ }
291
+ result += String.fromCodePoint(codePoint);
292
+ width += charWidth;
293
+ }
294
+ return result;
295
+ }
296
+ function isControlCodePoint(codePoint) {
297
+ return codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f);
298
+ }
299
+ function isZeroWidthCodePoint(codePoint) {
300
+ return (codePoint === 0x200d ||
301
+ codePoint === 0xfe0f ||
302
+ (codePoint >= 0xfe00 && codePoint <= 0xfe0f));
303
+ }
304
+ function isEmojiCodePoint(codePoint) {
305
+ return ((codePoint >= 0x1f300 && codePoint <= 0x1f5ff) ||
306
+ (codePoint >= 0x1f600 && codePoint <= 0x1f64f) ||
307
+ (codePoint >= 0x1f680 && codePoint <= 0x1f6ff) ||
308
+ (codePoint >= 0x1f700 && codePoint <= 0x1f77f) ||
309
+ (codePoint >= 0x1f780 && codePoint <= 0x1f7ff) ||
310
+ (codePoint >= 0x1f800 && codePoint <= 0x1f8ff) ||
311
+ (codePoint >= 0x1f900 && codePoint <= 0x1f9ff) ||
312
+ (codePoint >= 0x1fa00 && codePoint <= 0x1faff) ||
313
+ (codePoint >= 0x2600 && codePoint <= 0x26ff) ||
314
+ (codePoint >= 0x2700 && codePoint <= 0x27bf));
315
+ }
316
+ function isFullWidthCodePoint(codePoint) {
317
+ return (codePoint >= 0x1100 && (codePoint <= 0x115f ||
318
+ codePoint === 0x2329 ||
319
+ codePoint === 0x232a ||
320
+ (codePoint >= 0x2e80 && codePoint <= 0x3247 && codePoint !== 0x303f) ||
321
+ (codePoint >= 0x3250 && codePoint <= 0x4dbf) ||
322
+ (codePoint >= 0x4e00 && codePoint <= 0xa4c6) ||
323
+ (codePoint >= 0xa960 && codePoint <= 0xa97c) ||
324
+ (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
325
+ (codePoint >= 0xf900 && codePoint <= 0xfaff) ||
326
+ (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
327
+ (codePoint >= 0xfe30 && codePoint <= 0xfe6b) ||
328
+ (codePoint >= 0xff01 && codePoint <= 0xff60) ||
329
+ (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
330
+ (codePoint >= 0x1b000 && codePoint <= 0x1b001) ||
331
+ (codePoint >= 0x1f200 && codePoint <= 0x1f251) ||
332
+ (codePoint >= 0x20000 && codePoint <= 0x3fffd)));
253
333
  }
254
334
  /**
255
335
  * Format header section
@@ -260,16 +340,16 @@ function formatBoxLine(content, lineIndent) {
260
340
  */
261
341
  function formatHeader(platformName, startTime, endTime) {
262
342
  const lines = [];
263
- const LINE_WIDTH = 60;
264
- lines.push('╔' + '═'.repeat(58) + '╗');
265
- lines.push('' + ' '.repeat(58) + '');
266
- lines.push('║' + ' Z.ai GLM Coding Plan Usage Statistics '.padStart(35).padEnd(58) + '║');
267
- lines.push('║' + ' '.repeat(58) + '║');
268
- lines.push('' + ''.repeat(58) + '');
269
- lines.push('║ Platform: ' + platformName.padEnd(LINE_WIDTH - 13 - 1) + '');
270
- const periodLine = '║ Period: ' + startTime + ' → ' + endTime;
271
- lines.push(periodLine.padEnd(LINE_WIDTH) + '║');
272
- lines.push('╠' + '═'.repeat(58) + '╣');
343
+ const LINE_CONTENT = 58;
344
+ const LINE_INDENT = 56;
345
+ lines.push('' + ''.repeat(LINE_CONTENT) + '');
346
+ lines.push('║' + ' '.repeat(LINE_CONTENT) + '║');
347
+ lines.push('║' + ' Z.ai GLM Coding Plan Usage Statistics '.padStart(35).padEnd(LINE_CONTENT) + '║');
348
+ lines.push('' + ' '.repeat(LINE_CONTENT) + '');
349
+ lines.push('' + '═'.repeat(LINE_CONTENT) + '');
350
+ lines.push(formatBoxLine(`Platform: ${platformName}`, LINE_INDENT));
351
+ lines.push(formatBoxLine(`Period: ${startTime} ${endTime}`, LINE_INDENT));
352
+ lines.push('╠' + '═'.repeat(LINE_CONTENT) + '╣');
273
353
  return lines;
274
354
  }
275
355
  /**
@@ -281,8 +361,8 @@ function formatQuotaLimits(quotaData) {
281
361
  const lines = [];
282
362
  const LINE_CONTENT = 58;
283
363
  const LINE_INDENT = 56;
284
- lines.push('║ 📊 QUOTA LIMITS' + ' '.repeat(LINE_CONTENT - 14) + '║');
285
- lines.push('╟' + '─'.repeat(58) + '╢');
364
+ lines.push(formatBoxLine('QUOTA LIMITS', LINE_INDENT));
365
+ lines.push('╟' + '─'.repeat(LINE_CONTENT) + '╢');
286
366
  const limits = quotaData?.limits;
287
367
  if (limits && Array.isArray(limits)) {
288
368
  for (const limit of limits) {
@@ -302,9 +382,9 @@ function formatQuotaLimits(quotaData) {
302
382
  }
303
383
  }
304
384
  else {
305
- lines.push('No quota data available' + ' '.repeat(LINE_INDENT - 21) + '║');
385
+ lines.push(formatBoxLine('No quota data available', LINE_INDENT));
306
386
  }
307
- lines.push('╠' + '═'.repeat(58) + '╣');
387
+ lines.push('╠' + '═'.repeat(LINE_CONTENT) + '╣');
308
388
  return lines;
309
389
  }
310
390
  /**
@@ -319,8 +399,8 @@ function formatQuotaLimits(quotaData) {
319
399
  function formatDataSection(title, data, formatter, quotaData, noDataMessage, LINE_INDENT) {
320
400
  const lines = [];
321
401
  const LINE_CONTENT = 58;
322
- lines.push('║ ' + title + ' '.repeat(LINE_CONTENT - title.length) + '║');
323
- lines.push('╟' + '─'.repeat(58) + '╢');
402
+ lines.push(formatBoxLine(title, LINE_INDENT));
403
+ lines.push('╟' + '─'.repeat(LINE_CONTENT) + '╢');
324
404
  if (data) {
325
405
  const formattedLines = formatter(data, quotaData);
326
406
  for (const line of formattedLines) {
@@ -328,9 +408,9 @@ function formatDataSection(title, data, formatter, quotaData, noDataMessage, LIN
328
408
  }
329
409
  }
330
410
  else {
331
- lines.push('║ ' + noDataMessage + ' '.repeat(LINE_INDENT - noDataMessage.length) + '║');
411
+ lines.push(formatBoxLine(noDataMessage, LINE_INDENT));
332
412
  }
333
- lines.push('╠' + '═'.repeat(58) + '╣');
413
+ lines.push('╠' + '═'.repeat(LINE_CONTENT) + '╣');
334
414
  return lines;
335
415
  }
336
416
  /**
@@ -356,8 +436,8 @@ function formatOutput(platform, startTime, endTime, quotaData, modelData, toolDa
356
436
  const LINE_INDENT = 56;
357
437
  lines.push(...formatHeader(platformName, startTime, endTime));
358
438
  lines.push(...formatQuotaLimits(quotaData));
359
- lines.push(...formatDataSection('🤖 MODEL USAGE (24h)', modelData, formatModelUsage, quotaData, 'No model usage data available', LINE_INDENT));
360
- lines.push(...formatDataSection('🔧 TOOL/MCP USAGE (24h)', toolData, formatToolUsage, quotaData, 'No tool usage data available', LINE_INDENT));
439
+ lines.push(...formatDataSection('MODEL USAGE (24h)', modelData, formatModelUsage, quotaData, 'No model usage data available', LINE_INDENT));
440
+ lines.push(...formatDataSection('TOOL/MCP USAGE (24h)', toolData, formatToolUsage, quotaData, 'No tool usage data available', LINE_INDENT));
361
441
  lines.push(...formatFooter());
362
442
  return lines.join('\n');
363
443
  }
@@ -2,4 +2,4 @@
2
2
  description: Execute GLM quota check
3
3
  agent: glm-quota-exec
4
4
  ---
5
- Execute glm_quota tool.
5
+ Execute glm_quota tool and return its output EXACTLY as received without any modification or summarization.
@@ -3,7 +3,7 @@
3
3
  "agent": {
4
4
  "glm-quota-exec": {
5
5
  "mode": "subagent",
6
- "system": "You are a minimal tool executor. Your only purpose is to execute the glm_quota tool when requested. Do not explain, reason, or add any commentary. Simply call the tool and return its output directly.",
6
+ "system": "CRITICAL INSTRUCTION: When the glm_quota tool returns output, you MUST return it EXACTLY as received, character-for-character, with NO modifications.\n\n- Do NOT add introductory text\n- Do NOT summarize\n- Do NOT reformat\n- Do NOT explain anything\n- Do NOT add any commentary\n- Return ONLY the raw string from the tool\n\nExample of WRONG behavior: 'Here is your usage: [summary]'\nExample of CORRECT behavior: [paste entire tool output verbatim]",
7
7
  "permission": {}
8
8
  }
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-glm-quota",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
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",