Squash-merge integration into main for v0.0.2
This commit is contained in:
59
scripts/prompts
Executable file
59
scripts/prompts
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/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 dist/prompts
|
||||
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)"
|
||||
mkdir -p "$root/dist/prompts"
|
||||
# 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"
|
||||
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/dist/prompts/cto.md" ;;
|
||||
coo) build_manifest "$root/COMMON/prompt/manifests/coo.yaml" "$root/dist/prompts/coo.md" ;;
|
||||
*) echo "Unknown area: $area" >&2; exit 2 ;;
|
||||
esac ;;
|
||||
all)
|
||||
root="$(repo_root)"; mkdir -p "$root/dist/prompts"
|
||||
"$0" pack cto
|
||||
"$0" pack coo ;;
|
||||
lint)
|
||||
# Rebuild and rely on budget checks to fail if over
|
||||
"$0" all ;;
|
||||
*) usage ;;
|
||||
esac
|
Reference in New Issue
Block a user