#!/usr/bin/env bash
# Bereitet ~/.config/ai-control auf einer frischen Maschine vor — dasselbe
# Layout, das die App anlegt:
#   settings.json   App-Settings (claudeCommand; poolSyncDir ungesetzt = lokal)
#   projects.json   Projekt-Registry (Name -> Pfad, ~-relativ)
#   icons/          gemeinsames Icon-Verzeichnis
#   pools/<pool>/   oauth-Pool: pool.json, settings.json, CLAUDE.md
# Vorhandene Dateien bleiben unangetastet.
#
# Aufruf: setup-config.sh [pool-id]   (Default: private)
set -euo pipefail

pool="${1:-private}"
config="$HOME/.config/ai-control"
pooldir="$config/pools/$pool"

mkdir -p "$config/icons" "$pooldir"

[ -f "$config/settings.json" ] || cat > "$config/settings.json" <<'EOF'
{
  "claudeCommand": "claude"
}
EOF

[ -f "$config/projects.json" ] || echo '{}' > "$config/projects.json"

[ -f "$pooldir/pool.json" ] || cat > "$pooldir/pool.json" <<EOF
{
  "name": "$pool",
  "credentialType": "oauth"
}
EOF

# UI-Defaults wie init_pool_config: Prompt-Vorschläge/Away-Summary aus
[ -f "$pooldir/settings.json" ] || cat > "$pooldir/settings.json" <<'EOF'
{
  "promptSuggestionEnabled": false,
  "awaySummaryEnabled": false
}
EOF

[ -f "$pooldir/CLAUDE.md" ] || : > "$pooldir/CLAUDE.md"

echo "fertig: $config (Pool: $pool)"
