-
Notifications
You must be signed in to change notification settings - Fork 656
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·155 lines (133 loc) · 4.44 KB
/
Copy pathpublish.sh
File metadata and controls
executable file
·155 lines (133 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
# Publish Godogen runtime files into a target game repo.
#
# Usage:
# ./publish.sh --engine godot|bevy|babylon --agent claude|codex --out <dir> [--force]
# ./publish.sh --engine godot|bevy|babylon --agent claude|codex <dir> [--force]
#
# A published repo carries only docs: the runtime manifest (CLAUDE.md / AGENTS.md),
# a per-engine guide (<engine>.md), and the asset-gen skill. The agent scaffolds
# the game itself from the engine guide — no project scaffold is shipped.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
HELPERS="$REPO_ROOT/scripts"
ENGINE=""
AGENT=""
OUT=""
FORCE=0
usage() {
sed -n '1,10p' "$0" >&2
}
while [ $# -gt 0 ]; do
case "$1" in
--engine) ENGINE="${2:-}"; shift 2 ;;
--agent) AGENT="${2:-}"; shift 2 ;;
--out) OUT="${2:-}"; shift 2 ;;
--force) FORCE=1; shift ;;
-h|--help) usage; exit 0 ;;
-*) echo "error: unknown option $1" >&2; usage; exit 1 ;;
*)
if [ -n "$OUT" ]; then
echo "error: target specified more than once" >&2
exit 1
fi
OUT="$1"
shift
;;
esac
done
case "$ENGINE" in
godot) ENGINE_DISPLAY="Godot" ;;
bevy) ENGINE_DISPLAY="Bevy" ;;
babylon) ENGINE_DISPLAY="Babylon.js" ;;
*) echo "error: --engine must be godot, bevy, or babylon" >&2; usage; exit 1 ;;
esac
# Root for runtime-loaded generated assets, substituted into the asset docs.
case "$ENGINE" in
babylon) RUNTIME_ASSET_DIR="src/assets" ;;
*) RUNTIME_ASSET_DIR="assets" ;;
esac
case "$AGENT" in
claude)
MANIFEST="CLAUDE.md"
SKILLS_DIR_REL=".claude/skills"
AGENT_NAME="Claude"
ASSET_SKILL_COMMAND="/asset-gen"
;;
codex)
MANIFEST="AGENTS.md"
SKILLS_DIR_REL=".agents/skills"
AGENT_NAME="Codex"
ASSET_SKILL_COMMAND="\$asset-gen"
;;
*) echo "error: --agent must be claude or codex" >&2; usage; exit 1 ;;
esac
ASSET_GEN_SKILL_DIR="$SKILLS_DIR_REL/asset-gen"
ENGINE_GUIDE_FILE="$ENGINE.md"
if [ -z "$OUT" ]; then
echo "error: --out <target_dir> is required" >&2
usage
exit 1
fi
TARGET="$(cd "$OUT" 2>/dev/null && pwd || (mkdir -p "$OUT" && cd "$OUT" && pwd))"
if [ "$FORCE" -eq 1 ] && [ -d "$TARGET" ]; then
echo "Force: cleaning $TARGET"
rm -rf "${TARGET:?}"
mkdir -p "$TARGET"
fi
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
echo "Publishing $ENGINE/$AGENT to: $TARGET"
# --- Skills: only the asset-gen skill ---
mkdir -p "$TMP/skills/asset-gen"
rsync -a --delete --exclude='__pycache__/' "$REPO_ROOT/asset-gen/" "$TMP/skills/asset-gen/"
python3 "$HELPERS/render_dir.py" "$TMP/skills" \
"AGENT_NAME=$AGENT_NAME" \
"ASSET_GEN_SKILL_DIR=$ASSET_GEN_SKILL_DIR" \
"ASSET_SKILL_COMMAND=$ASSET_SKILL_COMMAND" \
"RUNTIME_ASSET_DIR=$RUNTIME_ASSET_DIR"
if [ "$AGENT" = "codex" ]; then
python3 "$HELPERS/generate_codex_metadata.py" "$TMP/skills"
fi
mkdir -p "$TARGET/$SKILLS_DIR_REL"
rsync -a --delete "$TMP/skills/" "$TARGET/$SKILLS_DIR_REL/"
echo "Installed asset-gen skill"
# --- Manifest: the runtime process doc ---
MANIFEST_TMP="$TMP/manifest"
mkdir -p "$MANIFEST_TMP"
cp "$REPO_ROOT/prompts/runtime.md" "$MANIFEST_TMP/$MANIFEST"
python3 "$HELPERS/render_dir.py" "$MANIFEST_TMP" \
"ENGINE_NAME=$ENGINE_DISPLAY" \
"ENGINE_GUIDE_FILE=$ENGINE_GUIDE_FILE" \
"ASSET_SKILL_COMMAND=$ASSET_SKILL_COMMAND"
cp "$MANIFEST_TMP/$MANIFEST" "$TARGET/$MANIFEST"
echo "Created $MANIFEST"
# --- Per-engine guide (literal markdown) ---
cp "$REPO_ROOT/engines/$ENGINE.md" "$TARGET/$ENGINE_GUIDE_FILE"
echo "Created $ENGINE_GUIDE_FILE"
# --- .gitignore (published instruction files are regenerated by publish.sh) ---
if [ ! -f "$TARGET/.gitignore" ]; then
{
if [ "$AGENT" = "claude" ]; then
printf '.claude\nCLAUDE.md\n'
else
printf '.agents\nAGENTS.md\n.codex\n'
fi
printf '%s\n' "$ENGINE_GUIDE_FILE"
printf '/tripo-out\n'
case "$ENGINE" in
godot)
printf 'assets\nscreenshots\n.godot\n*.import\nbin/\nobj/\n'
;;
bevy)
printf '/target\n/screenshots\n'
;;
babylon)
printf '/node_modules\n/dist\n/screenshots\n'
;;
esac
} > "$TARGET/.gitignore"
echo "Created .gitignore"
fi
git -C "$TARGET" init -q 2>/dev/null || true
echo "Done."