#!/bin/bash
# omarchy:summary=Set the default AI profile
# omarchy:args=<name>
# omarchy:examples=omarchycn ai profile use work

set -euo pipefail

source "$OMARCHY_PATH/cn/lib/ai.sh"

name="${1:?usage: omarchycn ai profile use <name>}"

if [[ ! -f $CN_AI_PROFILE_DIR/$name.toml ]]; then
  echo "No such profile: $name (see: omarchycn ai profile list)" >&2
  exit 1
fi

mkdir -p "${CN_AI_CURRENT%/*}"
echo "$name" > "$CN_AI_CURRENT"
echo "Default AI profile: $name"
