Skip to content

Commit bac36ae

Browse files
committed
Add models consolidation plan - Related to PR raycast#19485 - Addresses @one-data-cookie suggestion to simplify maintenance
1 parent c562071 commit bac36ae

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Models List Consolidation Plan
2+
3+
## Problem
4+
Currently, the models list is duplicated in 9 places:
5+
- 8 command preferences (summarize, rewrite, refine, custom, execute, preview, transform, transform_preview)
6+
- 1 global preferences section
7+
8+
This makes adding/removing models tedious and error-prone.
9+
10+
## Proposed Solution: Build Script Approach
11+
12+
### 1. Create Models Definition File
13+
```javascript
14+
// scripts/models.js
15+
const MODELS_LIST = [
16+
{ "title": "Follow global model", "value": "global" },
17+
{ "title": "GPT-4o", "value": "gpt-4o" },
18+
{ "title": "GPT-4o mini", "value": "gpt-4o-mini" },
19+
{ "title": "GPT-4.1", "value": "gpt-4.1" },
20+
{ "title": "GPT-4.1 mini", "value": "gpt-4.1-mini" },
21+
{ "title": "GPT-4.1 nano", "value": "gpt-4.1-nano" },
22+
{ "title": "o1", "value": "o1" },
23+
{ "title": "o1-mini", "value": "o1-mini" },
24+
{ "title": "o1-pro", "value": "o1-pro" },
25+
{ "title": "o3", "value": "o3" },
26+
{ "title": "o3-mini", "value": "o3-mini" },
27+
{ "title": "o4-mini", "value": "o4-mini" }
28+
];
29+
30+
const GLOBAL_MODELS_LIST = MODELS_LIST.slice(1); // Remove "Follow global model" for global preferences
31+
32+
module.exports = { MODELS_LIST, GLOBAL_MODELS_LIST };
33+
```
34+
35+
### 2. Create Package Template
36+
```json
37+
// package.template.json
38+
{
39+
"commands": [
40+
{
41+
"name": "summarize",
42+
"preferences": [
43+
{
44+
"name": "model_summarize",
45+
"data": "{{COMMAND_MODELS_LIST}}"
46+
}
47+
]
48+
}
49+
],
50+
"preferences": [
51+
{
52+
"name": "model",
53+
"data": "{{GLOBAL_MODELS_LIST}}"
54+
}
55+
]
56+
}
57+
```
58+
59+
### 3. Build Script
60+
```javascript
61+
// scripts/build-package.js
62+
const fs = require('fs');
63+
const { MODELS_LIST, GLOBAL_MODELS_LIST } = require('./models');
64+
65+
const template = require('../package.template.json');
66+
let packageContent = JSON.stringify(template, null, 2);
67+
68+
packageContent = packageContent.replace(/"{{COMMAND_MODELS_LIST}}"/g, JSON.stringify(MODELS_LIST, null, 8));
69+
packageContent = packageContent.replace(/"{{GLOBAL_MODELS_LIST}}"/g, JSON.stringify(GLOBAL_MODELS_LIST, null, 8));
70+
71+
fs.writeFileSync('package.json', packageContent);
72+
```
73+
74+
### 4. Update Build Process
75+
Add to package.json scripts:
76+
```json
77+
{
78+
"scripts": {
79+
"prebuild": "node scripts/build-package.js",
80+
"build": "ray build -e dist",
81+
"predev": "node scripts/build-package.js",
82+
"dev": "ray develop"
83+
}
84+
}
85+
```
86+
87+
## Benefits
88+
- ✅ Single source of truth for models list
89+
- ✅ Add/remove models in one place
90+
- ✅ Automatic consistency across all commands
91+
- ✅ No manual JSON duplication
92+
- ✅ Prevents copy-paste errors
93+
94+
## Implementation Steps
95+
1. Create `scripts/models.js` with models definition
96+
2. Create `package.template.json` with placeholders
97+
3. Create `scripts/build-package.js` build script
98+
4. Update npm scripts to run build-package before build/dev
99+
5. Test thoroughly in development mode
100+
6. Update documentation
101+
102+
## Related to
103+
- **Parent PR**: #19485 (Update to latest OpenAI models and pricing)
104+
- **Suggested by**: @one-data-cookie
105+
- **Goal**: Make future model maintenance much easier
106+
107+
## Next Steps
108+
This enhancement will be implemented after PR #19485 is merged to avoid conflicts and keep changes focused.

0 commit comments

Comments
 (0)