Files
AI-ART/promote-manifest.sh

51 lines
1.1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROMPT_JSON="$ROOT_DIR/output/prompt.json"
MANIFEST_JSON="$ROOT_DIR/manifest.json"
if [ ! -f "$PROMPT_JSON" ]; then
echo "[ERROR] prompt.json not found."
exit 1
fi
if ! command -v jq >/dev/null 2>&1; then
echo "[ERROR] jq not found. Install jq first."
exit 1
fi
WORLD_ID=$(jq -r '.meta.world_id' "$PROMPT_JSON")
WORLD_VERSION=$(jq -r '.meta.world_version' "$PROMPT_JSON")
STYLE_ID=$(jq -r '.meta.style_id' "$PROMPT_JSON")
SCENE_ID=$(jq -r '.meta.scene_id' "$PROMPT_JSON")
TASK_TYPE=$(jq -r '.meta.task_type' "$PROMPT_JSON")
if [[ "$WORLD_ID" == "null" || "$STYLE_ID" == "null" || "$TASK_TYPE" == "null" ]]; then
echo "[ERROR] Invalid meta fields in prompt.json"
exit 1
fi
cat > "$MANIFEST_JSON" <<EOF
{
"version": "1.0",
"world": {
"id": "$WORLD_ID",
"version": "$WORLD_VERSION"
},
"style": {
"id": "$STYLE_ID"
},
"scene": {
"id": "$SCENE_ID"
},
"task": {
"type": "$TASK_TYPE",
"prompt_ref": "output/prompt.json"
}
}
EOF
echo "[OK] manifest.json generated successfully."
echo "[DONE] $MANIFEST_JSON"