#!/bin/bash

# omarchy:summary=Have an agent make a new theme, plugin, app, or game
# omarchy:args=[--agent <id> | --provider <id> | --local-model <model>] <theme|plugin|app|game>
# omarchy:examples=omarchy agent make theme | omarchy agent make --agent claude app | omarchy agent make --local-model qwen3.8-27b-gufo game

# A few ways into making Omarchy your own, shared by the agents panel's starter
# tiles and the make icons on each of its lines. The task goes to the default agent, or to the agent, provider, or
# local model named first.

target=()
case "${1:-}" in
--agent | --provider | --local-model)
  target=("$1" "${2:?$1 needs a value}")
  shift 2
  ;;
esac

case "${1:-}" in
theme) prompt="Make me a new Omarchy theme. Ask me what look or inspiration I have in mind, then build it following the omarchy-make-theme skill and switch to it." ;;
plugin) prompt="Make me a new Omarchy shell plugin. Ask me what I'd like it to do, then build it following the omarchy-make-plugin skill and enable it." ;;
app) prompt="Make me a new app for my Omarchy desktop. Ask me what it should do, then build it following the omarchy-make-app skill and install it so it shows up in the app launcher." ;;
game)
  # Launch straight into Game Vibes Studio's New Game deck for agents Studio
  # streams directly, with the requested agent and model pre-selected.
  studio_args=()
  if (( ${#target[@]} == 0 )); then
    studio_args=(--new)
  elif [[ ${target[0]} == "--local-model" ]]; then
    studio_args=(--new --agent local --model "${target[1]}")
  elif [[ ${target[0]} == "--agent" ]]; then
    case "${target[1]}" in
    agy | claude | codex | opencode | pi | local)
      studio_args=(--new --agent "${target[1]}")
      ;;
    esac
  fi
  if (( ${#studio_args[@]} > 0 )); then
    exec omarchy-games-vibes-launch "${studio_args[@]}"
  else
    prompt="Make me a new game for my Omarchy desktop. Ask me what kind of game I'd like, or which game in Game Vibes to keep working on, then build it following the omarchy-make-game skill and open it in Game Vibes."
  fi
  ;;
*)
  echo "Usage: omarchy-agent-make [--agent <id> | --provider <id> | --local-model <model>] <theme|plugin|app|game>" >&2
  exit 1
  ;;
esac

exec omarchy-agent "${target[@]}" --pick --prompt "$prompt"
