File size: 1,174 Bytes
1dbc34b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import json
import sys

def main():
    if len(sys.argv) < 3:
        print("Usage: python3 update_settings.py <DATA_DIR> <MODEL>")
        sys.exit(1)

    data_dir = sys.argv[1]
    model = sys.argv[2]
    settings_file = os.path.join(data_dir, "settings.json")

    settings = {}
    if os.path.exists(settings_file):
        try:
            with open(settings_file, "r") as f:
                settings = json.load(f)
        except Exception as e:
            print(f"Error reading settings: {e}")

    # Set enhancement model
    settings["enhancementModel"] = model
    # Set default feature model
    settings["defaultFeatureModel"] = {"model": model, "provider": "opencode"}
    
    # Update active model in profiles if they exist
    if "profiles" in settings:
        for profile in settings["profiles"]:
            profile["model"] = model

    try:
        os.makedirs(data_dir, exist_ok=True)
        with open(settings_file, "w") as f:
            json.dump(settings, f, indent=2)
        print(f"Updated settings with model {model}")
    except Exception as e:
        print(f"Error writing settings: {e}")

if __name__ == "__main__":
    main()