#!/usr/bin/env python3
"""Autonomie für Natiris aktivieren"""

import json
import os

CONFIG_PATH = os.path.expanduser("~/natiris/config/character_genesis.json")

def load_json(path):
    try:
        with open(path, "r", encoding="utf-8") as f:
            return json.load(f)
    except (FileNotFoundError, json.JSONDecodeError):
        return {}

def save_json(path, data):
    os.makedirs(os.path.dirname(path), exist_ok=True)
    with open(path, "w", encoding="utf-8") as f:
        json.dump(data, f, indent=2)

def main():
    cfg = load_json(CONFIG_PATH)
    cfg["autonomy"]["enabled"] = True
    save_json(CONFIG_PATH, cfg)
    print("✅ Autonomie aktiviert in", CONFIG_PATH)
    print(json.dumps(cfg["autonomy"], indent=2))

if __name__ == "__main__":
    main()
