opencode-glm-quota 1.3.0 → 1.3.1

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
@@ -21,19 +21,17 @@ OpenCode plugin to query Z.ai GLM Coding Plan usage statistics with real-time qu
21
21
  ### Option 1: npm (Recommended)
22
22
 
23
23
  ```bash
24
- # Install the plugin
25
- npm install @opencode-glm-quota/plugin
24
+ # Install plugin
25
+ npm install opencode-glm-quota
26
26
 
27
- # Run the installer to configure OpenCode
28
- npx @opencode-glm-quota/plugin install
29
-
30
- # Add to your OpenCode config (~/.config/opencode/opencode.json)
31
- echo '"@opencode-glm-quota/plugin"' >> ~/.config/opencode/opencode.json
27
+ # Run installer to configure OpenCode
28
+ npx opencode-glm-quota install
32
29
  ```
33
30
 
34
31
  **What the installer does:**
35
32
  - Copies `/glm_quota` command to `~/.config/opencode/command/glm_quota.md`
36
- - Copies skill documentation to `~/.config/opencode/skill/glm-quota-skill.md`
33
+ - Copies skill documentation to `~/.config/opencode/skills/glm-quota/SKILL.md`
34
+ - Automatically adds plugin to your OpenCode config
37
35
  - Merges agent configuration into `~/.config/opencode/opencode.json`
38
36
  - Supports `--force` flag to overwrite existing files
39
37
 
@@ -227,7 +225,7 @@ npm run prepublishOnly
227
225
 
228
226
  ```
229
227
  src/
230
- index.ts # Main plugin entry point (463 lines)
228
+ index.ts # Main plugin entry point
231
229
  api/
232
230
  client.ts # HTTPS client with timeout and error handling
233
231
  endpoints.ts # Platform-specific API endpoints
@@ -236,16 +234,16 @@ src/
236
234
  date-formatter.ts # Date/time formatting utilities
237
235
  progress-bar.ts # ASCII progress bar rendering
238
236
  time-window.ts # Rolling window calculation
239
- integration/
240
- command/glm_quota.md # /glm_quota slash command
241
- skill/glm-quota-skill.md # Skill documentation
242
- opencode.jsonc # Agent configuration (JSONC)
243
- bin/
244
- install.js # Installation script
245
- dist/ # Compiled JavaScript (generated)
246
- tests/ # Test suite
247
- package.json # Dependencies and scripts
248
- tsconfig.json # TypeScript configuration
237
+ integration/
238
+ command/glm_quota.md # /glm_quota slash command
239
+ skills/glm-quota/SKILL.md # Skill documentation
240
+ opencode.jsonc # Agent configuration (JSONC)
241
+ bin/
242
+ install.js # Installation script
243
+ dist/ # Compiled JavaScript (generated)
244
+ tests/ # Test suite
245
+ package.json # Dependencies and scripts
246
+ tsconfig.json # TypeScript configuration
249
247
  ```
250
248
 
251
249
  ### Code Style Guidelines
package/bin/install.js CHANGED
@@ -24,12 +24,12 @@ const __filename = decodeURIComponent(new URL(import.meta.url).pathname)
24
24
  const __dirname = path.dirname(__filename)
25
25
  const SOURCE_DIR = path.join(__dirname, '..', 'integration')
26
26
  const COMMAND_FILE = path.join(SOURCE_DIR, 'command', 'glm_quota.md')
27
- const SKILL_FILE = path.join(SOURCE_DIR, 'skill', 'glm-quota-skill.md')
27
+ const SKILL_FILE = path.join(SOURCE_DIR, 'skills', 'glm-quota', 'SKILL.md')
28
28
  const AGENT_CONFIG = path.join(SOURCE_DIR, 'opencode.jsonc')
29
29
 
30
30
  const CONFIG_DIR = path.join(os.homedir(), '.config', 'opencode')
31
31
  const TARGET_COMMAND = path.join(CONFIG_DIR, 'command', 'glm_quota.md')
32
- const TARGET_SKILL = path.join(CONFIG_DIR, 'skill', 'glm-quota-skill.md')
32
+ const TARGET_SKILL = path.join(CONFIG_DIR, 'skills', 'glm-quota', 'SKILL.md')
33
33
 
34
34
  // Check which config file exists (opencode.json or opencode.jsonc)
35
35
  const TARGET_CONFIG_JSON = path.join(CONFIG_DIR, 'opencode.json')
@@ -144,14 +144,14 @@ function installCommand(force) {
144
144
  */
145
145
  function installSkill(force) {
146
146
  if (fileExists(TARGET_SKILL) && !force) {
147
- if (!promptConfirm(`Skill file exists: ${TARGET_SKILL}\nOverwrite?`)) {
147
+ if (!promptConfirm(`Skill directory exists: ${path.dirname(TARGET_SKILL)}\nOverwrite?`)) {
148
148
  console.log(` ⊘ Skipped ${TARGET_SKILL}`)
149
149
  return
150
150
  }
151
151
  }
152
152
 
153
153
  copyFile(SKILL_FILE, TARGET_SKILL)
154
- console.log(` ✓ Created ${TARGET_SKILL}`)
154
+ console.log(` ✓ Created ${path.join(path.basename(path.dirname(TARGET_SKILL)), path.basename(TARGET_SKILL))}`)
155
155
  }
156
156
 
157
157
  /**
@@ -162,33 +162,49 @@ function mergeConfig() {
162
162
  let existingConfig = {}
163
163
  if (fileExists(TARGET_CONFIG)) {
164
164
  existingConfig = parseConfig(TARGET_CONFIG)
165
+ // REMOVE old 'options' field to prevent verbose agent output
166
+ if (existingConfig.agent?.['glm-quota-exec']?.options) {
167
+ delete existingConfig.agent['glm-quota-exec'].options
168
+ }
165
169
  }
166
170
 
167
171
  // Parse new agent config from integration
168
172
  const newConfig = parseConfig(AGENT_CONFIG)
169
173
 
170
- // Merge agent definitions first
171
- const mergedConfig = deepMerge(existingConfig, newConfig)
174
+ const PLUGIN_NAME = 'opencode-glm-quota'
175
+
176
+ // Handle both "plugin" array and "agent" section
177
+ // Check for "plugin" array first (user's config uses this)
178
+ const pluginArrayName = existingConfig.plugin ? 'plugin' : 'plugins'
172
179
 
173
- // Ensure plugins array exists and add our plugin
174
- if (!mergedConfig.plugins) {
175
- mergedConfig.plugins = []
180
+ // Only ensure that array we're going to use exists, not both!
181
+ if (!existingConfig[pluginArrayName]) {
182
+ existingConfig[pluginArrayName] = []
176
183
  }
177
184
 
178
- const PLUGIN_NAME = '@opencode-glm-quota/plugin'
179
- const plugins = Array.isArray(mergedConfig.plugins) ? mergedConfig.plugins : []
185
+ const plugins = Array.isArray(existingConfig[pluginArrayName]) ? existingConfig[pluginArrayName] : []
186
+
187
+ // REPLACE entire glm-quota-exec agent (not merge, to remove old redundant fields)
188
+ if (newConfig.agent && newConfig.agent['glm-quota-exec']) {
189
+ if (!existingConfig.agent) {
190
+ existingConfig.agent = {}
191
+ }
192
+ existingConfig.agent['glm-quota-exec'] = newConfig.agent['glm-quota-exec']
193
+ } else if (!existingConfig.agent && newConfig.agent) {
194
+ existingConfig.agent = newConfig.agent
195
+ }
180
196
 
181
197
  // Only add if not already present
182
198
  if (!plugins.includes(PLUGIN_NAME)) {
183
199
  plugins.push(PLUGIN_NAME)
184
- mergedConfig.plugins = plugins
185
- console.log(` ✓ Added ${PLUGIN_NAME} to plugins array`)
200
+ existingConfig[pluginArrayName] = plugins
201
+ console.log(` ✓ Added ${PLUGIN_NAME} to ${pluginArrayName} array`)
186
202
  } else {
187
- console.log(` ⊙ Plugin ${PLUGIN_NAME} already in plugins array`)
203
+ console.log(` ⊙ Plugin ${PLUGIN_NAME} already in ${pluginArrayName} array`)
188
204
  }
189
205
 
190
- // Write merged config back to the same file (opencode.json or opencode.jsonc)
191
- writeConfig(TARGET_CONFIG, mergedConfig)
206
+ // Write merged config back to same file (opencode.json or opencode.jsonc)
207
+ writeConfig(TARGET_CONFIG, existingConfig)
192
208
  console.log(` ✓ Merged configuration into ${path.basename(TARGET_CONFIG)}`)
193
209
  }
194
210
 
@@ -224,6 +240,4 @@ function main() {
224
240
  }
225
241
 
226
242
  // Run installer
227
- if (import.meta.url === `file://${process.argv[1]}`) {
228
- main()
229
- }
243
+ main()
@@ -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);
37
+ const bar = createProgressBar(percentage, { width: 26 });
38
38
  const pctStr = formatPercentage(percentage).padStart(6);
39
- const labelStr = label.padEnd(20);
39
+ const labelStr = label.slice(0, 20).padEnd(20);
40
40
  return `${labelStr} [${bar}] ${pctStr}`;
41
41
  }
@@ -4,14 +4,7 @@
4
4
  "glm-quota-exec": {
5
5
  "mode": "subagent",
6
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.",
7
- "provider": "opencode",
8
- "options": {
9
- "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.",
10
- "provider": "opencode"
11
- },
12
7
  "permission": {}
13
8
  }
14
9
  }
15
- // Note: This agent definition is merged into user's existing OpenCode config
16
- // by the installer script to avoid overwriting their custom configurations
17
10
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "opencode-glm-quota",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
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",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "opencode-glm-quota-install": "./bin/install.js"
9
+ "opencode-glm-quota": "./bin/install.js"
10
10
  },
11
11
  "files": [
12
12
  "dist",
@@ -61,7 +61,7 @@
61
61
  "@types/node": "^20.0.0",
62
62
  "@typescript-eslint/eslint-plugin": "^6.0.0",
63
63
  "@typescript-eslint/parser": "^6.0.0",
64
- "baseline-browser-mapping": "^2.9.17",
64
+ "baseline-browser-mapping": "^2.9.18",
65
65
  "c8": "^10.1.3",
66
66
  "eslint": "^8.0.0",
67
67
  "tsx": "^4.0.0",