import os import json import sys def main(): if len(sys.argv) < 3: print("Usage: python3 update_settings.py ") 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()