ai-speedometer 1.0.0 → 1.2.0

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- This document provides a comprehensive explanation of how the AI benchmark CLI integrates with models.dev to provide a rich, up-to-date provider and model ecosystem. The integration enables users to easily access verified AI providers and their models without manual configuration.
5
+ This document provides a comprehensive explanation of how the AI benchmark CLI integrates with models.dev to provide a rich, up-to-date provider and model ecosystem. The integration enables users to easily access verified AI providers and their models without manual configuration, while also supporting custom providers for complete flexibility.
6
6
 
7
7
  ## What is Models.dev?
8
8
 
@@ -25,17 +25,26 @@ This module handles all communication with the models.dev API and provides cachi
25
25
  - `getModelsForProvider(providerId)` - Get models for a specific provider
26
26
  - `refreshData()` - Force refresh from API (bypassing cache)
27
27
 
28
- #### 2. `opencode-integration.js` - Provider Management
29
- This module bridges the models.dev data with the opencode authentication system.
28
+ #### 2. `opencode-integration.js` - Verified Provider Management
29
+ This module handles **verified providers only** from models.dev and manages their authentication.
30
30
 
31
31
  **Key Functions:**
32
- - `getAuthenticatedProviders()` - Get providers with valid API keys
33
- - `getCustomProviders()` - Get user-defined custom providers
34
- - `getAllAvailableProviders()` - Combine both authenticated and custom providers
35
- - `addApiKey(providerId, apiKey)` - Store API keys securely
32
+ - `getAuthenticatedProviders()` - Get verified providers with valid API keys from auth.json
33
+ - `addApiKey(providerId, apiKey)` - Store API keys securely in auth.json
34
+ - `getAllAvailableProviders()` - Combine verified providers with custom providers
35
+ - `migrateFromOldConfig()` - Migrate data from old config format
36
36
 
37
- #### 3. `cli.js` - User Interface
38
- The main CLI interface uses the integrated provider data for model selection and benchmarking.
37
+ #### 3. `ai-config.js` - Custom Provider Management
38
+ This module handles **user-defined custom providers** and their models.
39
+
40
+ **Key Functions:**
41
+ - `addCustomProvider()` - Add new custom providers
42
+ - `addModelToCustomProvider()` - Add models to existing custom providers
43
+ - `getCustomProvidersFromConfig()` - Retrieve custom providers from config
44
+ - `readAIConfig()` / `writeAIConfig()` - Manage ai-benchmark-config.json
45
+
46
+ #### 4. `cli.js` - User Interface
47
+ The main CLI interface uses both provider systems for model selection and benchmarking.
39
48
 
40
49
  ## Data Flow
41
50
 
@@ -59,10 +68,13 @@ User Request → CLI → getAllProviders() → Models.dev API → Provider Data
59
68
  - **Format:** JSON with timestamp
60
69
  - **Fallback:** Built-in provider list for offline operation
61
70
 
62
- ### 2. Provider Authentication Flow
71
+ ### 2. Dual Provider System Flow
72
+
73
+ The system now manages two distinct provider types:
63
74
 
75
+ #### Verified Providers (models.dev integration)
64
76
  ```
65
- Provider Selection → API Key Input → Auth Storage → Provider Activation
77
+ Provider Selection → API Key Input → auth.json Storage → Provider Activation
66
78
  ```
67
79
 
68
80
  **Authentication Process:**
@@ -72,24 +84,81 @@ Provider Selection → API Key Input → Auth Storage → Provider Activation
72
84
  3. **Secure Storage:** Key is stored in `~/.local/share/opencode/auth.json`
73
85
  4. **Provider Activation:** Provider becomes available in model selection
74
86
 
75
- **Security Features:**
76
- - **File Permissions:** Auth files have 0o600 permissions (read/write for owner only)
77
- - **XDG Compliance:** Follows XDG Base Directory specification
78
- - **No Key Exposure:** Keys are never logged or displayed in plain text
87
+ #### Custom Providers (user-defined)
88
+ ```
89
+ Custom Provider Setup ai-benchmark-config.json Storage Direct Integration
90
+ ```
91
+
92
+ **Custom Provider Process:**
93
+
94
+ 1. **Provider Definition:** User defines custom provider with base URL and models
95
+ 2. **Config Storage:** Provider stored in `~/.config/ai-speedometer/ai-benchmark-config.json`
96
+ 3. **Model Management:** Users can add/remove models from custom providers
97
+ 4. **Direct Integration:** Available immediately in model selection
79
98
 
80
99
  ### 3. Model Loading and Filtering
81
100
 
82
101
  ```
83
- All Providers → Filter by Auth → Combine with Custom → Present to User
102
+ Verified Providers → Custom Providers → Combine → Present to User
84
103
  ```
85
104
 
86
105
  **Model Assembly Process:**
87
106
 
88
- 1. **Authenticated Models:** Load models from providers with valid API keys
89
- 2. **Custom Models:** Load user-defined models from opencode.json
107
+ 1. **Verified Models:** Load models from authenticated providers in auth.json
108
+ 2. **Custom Models:** Load user-defined models from ai-benchmark-config.json
90
109
  3. **Deduplication:** Ensure no duplicate models in final list
91
110
  4. **Presentation:** Display combined list in model selection interface
92
111
 
112
+ ## Configuration Files and Locations
113
+
114
+ ### File Locations
115
+
116
+ #### OpenCode Integration (Verified Providers)
117
+ - **auth.json:** `~/.local/share/opencode/auth.json` (API keys for verified providers)
118
+ - **opencode.json:** `~/.config/opencode/opencode.json` (deprecated, no longer used)
119
+
120
+ #### AI Speedometer Config (Custom Providers)
121
+ - **ai-benchmark-config.json:** `~/.config/ai-speedometer/ai-benchmark-config.json` (custom providers)
122
+ - **Cache:** `~/.cache/ai-speedometer/models.json` (models.dev API cache)
123
+
124
+ ### Configuration Structures
125
+
126
+ #### Verified Providers (auth.json)
127
+ ```json
128
+ {
129
+ "openai": {
130
+ "type": "api",
131
+ "key": "sk-..."
132
+ },
133
+ "anthropic": {
134
+ "type": "api",
135
+ "key": "sk-ant-..."
136
+ }
137
+ }
138
+ ```
139
+
140
+ #### Custom Providers (ai-benchmark-config.json)
141
+ ```json
142
+ {
143
+ "verifiedProviders": {},
144
+ "customProviders": [
145
+ {
146
+ "id": "my-custom-provider",
147
+ "name": "My Custom Provider",
148
+ "type": "openai-compatible",
149
+ "baseUrl": "https://api.custom.com/v1",
150
+ "apiKey": "custom-api-key",
151
+ "models": [
152
+ {
153
+ "name": "Custom Model 1",
154
+ "id": "custom-model-1"
155
+ }
156
+ ]
157
+ }
158
+ ]
159
+ }
160
+ ```
161
+
93
162
  ## Provider Types and SDK Integration
94
163
 
95
164
  ### Supported Provider Types
@@ -131,66 +200,92 @@ if (providerConfig.npm === '@ai-sdk/anthropic') {
131
200
  }
132
201
  ```
133
202
 
134
- ## Configuration and Customization
203
+ ## User Interface Improvements
135
204
 
136
- ### Adding Custom Providers
205
+ ### Search Bar Visibility
206
+ - **Enhanced Visibility:** Search bar now includes 🔍 emoji indicator for clear visual identification
207
+ - **Proper Sizing:** Header height calculations correctly account for search interface
208
+ - **Consistent Implementation:** Search functionality works across all provider selection interfaces
137
209
 
138
- Users can extend the models.dev ecosystem with custom providers:
210
+ ### Screen Rendering Optimization
211
+ - **Double Buffering:** Screen content built in memory before display to eliminate flickering
212
+ - **Optimized Clearing:** Single screen clear operation per render cycle
213
+ - **Smooth Navigation:** Pagination and scrolling work without visual artifacts
214
+
215
+ ### Menu Structure
216
+ The CLI now follows the structure defined in `plan/models.md`:
139
217
 
140
- 1. **Custom Provider Setup:**
141
- ```json
142
- {
143
- "provider": {
144
- "my-custom-provider": {
145
- "name": "My Custom Provider",
146
- "npm": "@ai-sdk/openai-compatible",
147
- "options": {
148
- "apiKey": "your-api-key",
149
- "baseURL": "https://api.custom.com/v1"
150
- },
151
- "models": {
152
- "custom-model-1": {
153
- "name": "Custom Model 1"
154
- }
155
- }
156
- }
157
- }
158
- }
218
+ ```
219
+ Main Menu
220
+ ├── Set Model
221
+ │ ├── Add Verified Provider (models.dev)
222
+ │ ├── Add Custom Models
223
+ │ │ ├── Add Models to Existing Provider
224
+ │ │ ├── Add Custom Provider
225
+ │ │ └── Back to Model Management
226
+ │ ├── List Existing Providers
227
+ │ ├── Debug Info
228
+ │ └── Back to Main Menu
229
+ ├── Run Benchmark (AI SDK)
230
+ ├── Run Benchmark (REST API)
231
+ └── Exit
159
232
  ```
160
233
 
161
- 2. **Custom Provider Location:** `~/.config/opencode/opencode.json`
234
+ ## Adding Custom Providers
162
235
 
163
- ### Provider Configuration Structure
236
+ ### Custom Provider Setup Process
164
237
 
165
- #### Verified Providers (from models.dev)
166
- ```json
167
- {
168
- "providerId": {
169
- "type": "api",
170
- "key": "api-key-here"
171
- }
172
- }
173
- ```
238
+ 1. **Navigate to Add Custom Models** from Model Management menu
239
+ 2. **Choose "Add Custom Provider"** option
240
+ 3. **Select Provider Type:** OpenAI Compatible or Anthropic
241
+ 4. **Enter Provider Details:**
242
+ - Provider ID (e.g., my-openai)
243
+ - Provider Name (e.g., MyOpenAI)
244
+ - Base URL (e.g., https://api.openai.com/v1)
245
+ - API Key
246
+ 5. **Add Models:** Choose single or multiple model mode
247
+ 6. **Automatic Save:** Provider saved to ai-benchmark-config.json
248
+
249
+ ### Example Custom Provider Configuration
174
250
 
175
- #### Custom Providers (user-defined)
176
251
  ```json
177
252
  {
178
- "providerId": {
179
- "name": "Provider Name",
180
- "npm": "@ai-sdk/package-name",
181
- "options": {
182
- "apiKey": "api-key",
183
- "baseURL": "https://api.example.com/v1"
253
+ "id": "my-custom-openai",
254
+ "name": "My Custom OpenAI",
255
+ "type": "openai-compatible",
256
+ "baseUrl": "https://api.custom.com/v1",
257
+ "apiKey": "your-api-key",
258
+ "models": [
259
+ {
260
+ "name": "gpt-4",
261
+ "id": "gpt-4_1234567890"
184
262
  },
185
- "models": {
186
- "modelId": {
187
- "name": "Model Name"
188
- }
263
+ {
264
+ "name": "gpt-3.5-turbo",
265
+ "id": "gpt-3-5-turbo_1234567891"
189
266
  }
190
- }
267
+ ]
191
268
  }
192
269
  ```
193
270
 
271
+ ## Migration System
272
+
273
+ ### Automatic Migration
274
+ The system includes migration functionality for users transitioning from the old config format:
275
+
276
+ - **Detection:** Automatically detects old `ai-benchmark-config.json` in current directory
277
+ - **Migration:** Splits verified providers to auth.json and custom providers to new config location
278
+ - **Backup:** Creates backup of old config file
279
+ - **Reporting:** Shows migration results and any errors encountered
280
+
281
+ ### Migration Process
282
+ 1. **Old Config Detection:** Checks for `./ai-benchmark-config.json`
283
+ 2. **Data Splitting:**
284
+ - Verified providers → `~/.local/share/opencode/auth.json`
285
+ - Custom providers → `~/.config/ai-speedometer/ai-benchmark-config.json`
286
+ 3. **Backup:** Renames old file to `ai-benchmark-config.json.backup`
287
+ 4. **Confirmation:** Shows migration summary to user
288
+
194
289
  ## Error Handling and Resilience
195
290
 
196
291
  ### Cache Management
@@ -211,32 +306,13 @@ Users can extend the models.dev ecosystem with custom providers:
211
306
  - **Model Validation:** Verify model data integrity
212
307
  - **URL Validation:** Confirm base URLs are properly formatted
213
308
 
214
- ## Performance Optimization
215
-
216
- ### Caching Strategy
217
- - **Local Cache:** Reduces API calls and improves load times
218
- - **Conditional Updates:** Only fetch when data is stale
219
- - **Memory Efficiency:** Cache data is compactly stored
220
- - **Fast Access:** In-memory filtering and searching
221
-
222
- ### Search Optimization
223
- - **Debounced Input:** 50ms delay reduces unnecessary filtering
224
- - **Efficient Algorithms:** Optimized search across multiple fields
225
- - **Partial Results:** Show results immediately during typing
226
- - **Memory Management:** Clean up unused search timeouts
227
-
228
- ### Concurrent Loading
229
- - **Parallel Requests:** Fetch authenticated and custom providers concurrently
230
- - **Non-blocking UI:** Interface remains responsive during data loading
231
- - **Progressive Enhancement:** Show available data while loading more
232
-
233
309
  ## Security Considerations
234
310
 
235
311
  ### API Key Storage
236
312
  - **Secure File Permissions:** Auth files restricted to owner (0o600)
237
313
  - **XDG Compliance:** Follows system standards for config locations
238
314
  - **No Key Logging:** API keys never appear in logs or output
239
- - **Environment Variables:** Support for environment-based configuration
315
+ - **Separation of Concerns:** Verified and custom provider keys stored separately
240
316
 
241
317
  ### Network Security
242
318
  - **HTTPS Only:** All API communications use HTTPS
@@ -254,7 +330,19 @@ Users can extend the models.dev ecosystem with custom providers:
254
330
 
255
331
  ### Common Issues
256
332
 
257
- #### 1. Models Not Loading
333
+ #### 1. Search Bar Not Visible
334
+ **Symptoms:** Search interface missing from provider selection
335
+ **Solution:**
336
+ - This is now fixed with 🔍 emoji indicator and proper header calculations
337
+ - Ensure you're using the updated CLI version
338
+
339
+ #### 2. Screen Flickering During Navigation
340
+ **Symptoms:** Visual artifacts during scrolling or pagination
341
+ **Solution:**
342
+ - This has been resolved with double buffering implementation
343
+ - Update to latest CLI version if experiencing issues
344
+
345
+ #### 3. Models Not Loading
258
346
  **Symptoms:** Model selection shows empty or outdated list
259
347
  **Solution:**
260
348
  ```bash
@@ -262,7 +350,7 @@ Users can extend the models.dev ecosystem with custom providers:
262
350
  node -e "import('./models-dev.js').then(m => m.clearCache())"
263
351
  ```
264
352
 
265
- #### 2. Authentication Issues
353
+ #### 4. Authentication Issues
266
354
  **Symptoms:** Provider appears but models fail during benchmark
267
355
  **Solution:**
268
356
  ```bash
@@ -272,12 +360,16 @@ cat ~/.local/share/opencode/auth.json
272
360
  # Verify API key format and permissions
273
361
  ```
274
362
 
275
- #### 3. Search Performance Issues
276
- **Symptoms:** Lag or flickering during search typing
363
+ #### 5. Custom Provider Issues
364
+ **Symptoms:** Custom providers not appearing or models not working
277
365
  **Solution:**
278
- - Ensure cache directory exists and is writable
279
- - Check for large model lists (1000+ models)
280
- - Verify system resources are adequate
366
+ ```bash
367
+ # Check custom provider config
368
+ cat ~/.config/ai-speedometer/ai-benchmark-config.json
369
+
370
+ # Verify config directory exists
371
+ ls -la ~/.config/ai-speedometer/
372
+ ```
281
373
 
282
374
  ### Debugging Commands
283
375
 
@@ -285,11 +377,15 @@ cat ~/.local/share/opencode/auth.json
285
377
  # View cache status
286
378
  ls -la ~/.cache/ai-speedometer/
287
379
 
288
- # View auth configuration
380
+ # View verified provider configuration
289
381
  cat ~/.local/share/opencode/auth.json
290
382
 
291
383
  # View custom providers
292
- cat ~/.config/opencode/opencode.json
384
+ cat ~/.config/ai-speedometer/ai-benchmark-config.json
385
+
386
+ # View all config locations
387
+ node cli.js
388
+ # Then select "Debug Info" from the menu
293
389
 
294
390
  # Clear all caches
295
391
  rm -rf ~/.cache/ai-speedometer/
@@ -307,6 +403,32 @@ This creates detailed logs in `debug.log` including:
307
403
  - Cache operations
308
404
  - Provider loading process
309
405
  - Authentication flow
406
+ - Config system operations
407
+
408
+ ## Performance Optimization
409
+
410
+ ### Caching Strategy
411
+ - **Local Cache:** Reduces API calls and improves load times
412
+ - **Conditional Updates:** Only fetch when data is stale
413
+ - **Memory Efficiency:** Cache data is compactly stored
414
+ - **Fast Access:** In-memory filtering and searching
415
+
416
+ ### Search Optimization
417
+ - **Debounced Input:** 50ms delay reduces unnecessary filtering
418
+ - **Efficient Algorithms:** Optimized search across multiple fields
419
+ - **Partial Results:** Show results immediately during typing
420
+ - **Memory Management:** Clean up unused search timeouts
421
+
422
+ ### Screen Rendering
423
+ - **Double Buffering:** Eliminates screen flickering
424
+ - **Optimized Clearing:** Single screen clear per render cycle
425
+ - **Memory Efficient:** Screen content built in memory
426
+ - **Responsive:** Immediate feedback for user interactions
427
+
428
+ ### Concurrent Loading
429
+ - **Parallel Requests:** Fetch verified and custom providers concurrently
430
+ - **Non-blocking UI:** Interface remains responsive during data loading
431
+ - **Progressive Enhancement:** Show available data while loading more
310
432
 
311
433
  ## Future Enhancements
312
434
 
@@ -326,6 +448,7 @@ This creates detailed logs in `debug.log` including:
326
448
  - Provider favorite/bookmarking
327
449
  - Model capability filtering
328
450
  - Advanced search options
451
+ - Visual provider status indicators
329
452
 
330
453
  4. **Integration Enhancements:**
331
454
  - Real-time provider updates
@@ -341,4 +464,6 @@ This creates detailed logs in `debug.log` including:
341
464
 
342
465
  ## Conclusion
343
466
 
344
- The models.dev integration provides a powerful, extensible foundation for AI provider and model management. By combining centralized provider data with local authentication and customization, the system offers both convenience and flexibility. The caching, performance optimizations, and security features ensure a reliable and user-friendly experience for benchmarking AI models across multiple providers.
467
+ The models.dev integration provides a powerful, extensible foundation for AI provider and model management. The new dual-system architecture separates verified providers (from models.dev) from custom providers (user-defined), providing both convenience and flexibility. The recent improvements in search visibility, screen rendering, and configuration management ensure a reliable and user-friendly experience for benchmarking AI models across multiple providers.
468
+
469
+ The separation of concerns between verified and custom providers, combined with the robust migration system and optimized user interface, makes this integration both powerful and approachable for users at all levels of expertise.
@@ -0,0 +1,68 @@
1
+ # AI Speedometer - Publishing Guide
2
+
3
+ ## Table of Contents
4
+ 1. [Publishing to npm](#publishing-to-npm)
5
+ 2. [Building the Binary](#building-the-binary)
6
+
7
+ ## Publishing to npm
8
+
9
+ ### Current Setup
10
+ The AI Speedometer CLI is now published as a global npm package with the following configuration:
11
+
12
+ ### Package.json Configuration
13
+ ```json
14
+ {
15
+ "name": "ai-speedometer",
16
+ "version": "1.0.0",
17
+ "bin": {
18
+ "ai-speedometer": "./dist/cli.js",
19
+ "aispeed": "./dist/cli.js"
20
+ },
21
+ "files": ["dist/"],
22
+ "scripts": {
23
+ "build": "esbuild cli.js --bundle --platform=node --outfile=dist/cli.js",
24
+ "prepublishOnly": "npm run build"
25
+ }
26
+ }
27
+ ```
28
+
29
+ ### Publishing Process
30
+ 1. **Build Step**: Run `npm run build` to bundle the CLI using esbuild
31
+ 2. **Publish**: Run `npm publish` to publish to npm registry
32
+ 3. **Global Installation**: Users install with `npm install -g ai-speedometer`
33
+ 4. **Usage**: Users can run `ai-speedometer` or `aispeed` from anywhere
34
+
35
+ ### Key Files Modified
36
+ - `package.json` - Added esbuild config, binary commands, and npm metadata
37
+ - `cli.js` - Fixed entry point detection and interactive mode
38
+ - `benchmark-rest.js` - Fixed main function execution conflicts
39
+ - `.gitignore` - Added `dist/` to exclude bundled binaries
40
+
41
+ ## Building the Binary
42
+
43
+ ### Why Use esbuild?
44
+ - **Single File**: Bundles all dependencies into one executable file
45
+ - **Performance**: Faster startup time compared to Node.js module resolution
46
+ - **Distribution**: Easy to distribute as a global npm binary
47
+ - **Compatibility**: Works across different Node.js versions
48
+
49
+ ### Build Configuration
50
+ ```bash
51
+ esbuild cli.js --bundle --platform=node --outfile=dist/cli.js
52
+ ```
53
+
54
+ ### Build Process
55
+ 1. **Entry Point**: `cli.js` is the main entry point
56
+ 2. **Bundling**: All required modules are bundled into `dist/cli.js`
57
+ 3. **Platform**: Targeted for Node.js platform
58
+ 4. **Output**: Single executable file in `dist/` directory
59
+
60
+ ### Git Strategy
61
+ - `dist/` directory is in `.gitignore`
62
+ - Binary is generated during npm build process
63
+ - Only source code is tracked in git
64
+ - Built binary is distributed via npm
65
+
66
+
67
+
68
+ This documentation covers the complete publishing process for the AI Speedometer CLI, including npm configuration, esbuild bundling, and distribution setup.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-speedometer",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "A comprehensive CLI tool for benchmarking AI models across multiple providers with parallel execution and professional metrics",
5
5
  "main": "cli.js",
6
6
  "bin": {