Files
LLMScaffolding/scripts/prompts
ReachableCEO d9c0402981
Some checks are pending
Release / tag-and-notes (push) Waiting to run
docs: point RESUME to COMMON/questions; clarify prompts output locations
2025-09-11 07:18:10 -05:00

60 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
usage() {
cat >&2 <<'USAGE'
Usage: scripts/prompts <command> [args]
Commands:
build <manifest> <output> Build a flattened prompt from a manifest
pack <area> 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" </dev/null
}
build_manifest() {
local manifest=$1 out=$2 root
root="$(repo_root)"
# Write on host to avoid ownership issues; container prints to stdout.
TMP_OUT=$(mktemp)
trap '[[ -n "${TMP_OUT:-}" ]] && rm -f "$TMP_OUT"' EXIT
ci_run "python3 scripts/prompt_build.py '$manifest' -" >"$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