#!/usr/bin/env bash set -euo pipefail usage() { cat >&2 <<'USAGE' Usage: scripts/prompts [args] Commands: build Build a flattened prompt from a manifest pack Build known area pack (cto|coo) into area dist/ all Build all known area packs lint Lint prompts (budgets and includes) USAGE exit 2 } repo_root() { git rev-parse --show-toplevel 2>/dev/null || pwd; } ci_run() { local root; root="$(repo_root)" # Ensure ci image is available by invoking a no-op build via scripts/ci # Use compose to run with current uid:gid to avoid file ownership issues docker compose -f "$root/docker/ci.compose.yml" run --rm \ --user "$(id -u):$(id -g)" \ -e IN_CI_CONTAINER=1 ci bash -lc "cd /workspace && $1" "$TMP_OUT" mkdir -p "$(dirname "$out")" mv "$TMP_OUT" "$out" } cmd=${1:-} case "$cmd" in build) shift; [[ $# -eq 2 ]] || usage build_manifest "$1" "$2" ;; pack) shift; area=${1:-}; root="$(repo_root)" case "$area" in cto) build_manifest "$root/COMMON/prompt/manifests/cto.yaml" "$root/CTO/dist/prompts/cto.md" ;; coo) build_manifest "$root/COMMON/prompt/manifests/coo.yaml" "$root/COO/dist/prompts/coo.md" ;; *) echo "Unknown area: $area" >&2; exit 2 ;; esac ;; all) root="$(repo_root)" "$0" pack cto "$0" pack coo ;; lint) # Rebuild and rely on budget checks to fail if over "$0" all ;; *) usage ;; esac