61 lines
1.4 KiB
Bash
61 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
script_path="$(readlink -f -- "${BASH_SOURCE[0]}")"
|
|
script_dir="$(cd -- "$(dirname -- "${script_path}")" && pwd)"
|
|
deploy_dir="$(cd -- "${script_dir}/.." && pwd)"
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage:
|
|
./scripts/ai <tool> [project] [tool arguments...]
|
|
|
|
Tools:
|
|
codex, claude, codebuddy, kimi, opencode, qwen, dsh
|
|
cc-switch, multica (management commands; no project argument)
|
|
|
|
Examples:
|
|
./scripts/ai codex my-project
|
|
./scripts/ai claude my-project
|
|
./scripts/ai kimi my-project -p "explain this project"
|
|
./scripts/ai dsh my-project --profile headless "run the tests"
|
|
./scripts/ai cc-switch
|
|
./scripts/ai multica daemon status
|
|
EOF
|
|
}
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
tool="$1"
|
|
shift
|
|
|
|
case "${tool}" in
|
|
codex|claude|codebuddy|kimi|opencode|qwen|dsh|cc-switch|multica) ;;
|
|
*)
|
|
printf 'Unsupported tool: %s\n\n' "${tool}" >&2
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
if [[ "${tool}" == "cc-switch" || "${tool}" == "multica" ]]; then
|
|
exec docker compose --project-directory "${deploy_dir}" exec ai-tools "${tool}" "$@"
|
|
fi
|
|
|
|
project="."
|
|
if [[ $# -gt 0 && "$1" != -* ]]; then
|
|
project="$1"
|
|
shift
|
|
fi
|
|
|
|
if [[ "${project}" == /* || "${project}" == *".."* ]]; then
|
|
printf 'Project must be a path below /workspace.\n' >&2
|
|
exit 2
|
|
fi
|
|
|
|
exec docker compose --project-directory "${deploy_dir}" exec \
|
|
--workdir "/workspace/${project}" ai-tools "${tool}" "$@"
|