@bongos/core 1.19.1049 → 1.19.1051

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,149 +0,0 @@
1
- #!/usr/bin/env bash
2
- # post-create.sh — first-run provisioning for the Example Dev Box.
3
- #
4
- # Runs once, as the `vscode` user, after the container is created and the repo is
5
- # mounted at /workspace (devcontainer.json: postCreateCommand). This is where
6
- # ADR 0031 §3's "fold setup-builder.sh into the container's first-run step"
7
- # actually happens:
8
- #
9
- # 1. scripts/setup-builder.sh --no-auth --skip-keys
10
- # → verifies the toolchain, runs `npm ci`, seeds .env.local from the
11
- # (secret-free) example. The --no-auth flag skips the interactive
12
- # GitHub Device Flow, which can't run in a non-interactive postCreate —
13
- # the builder authenticates on first attach instead (see the banner).
14
- # 2. pip install the pinned art-pipeline deps INTO the venv the image created.
15
- # → setup-builder.sh doesn't touch Python deps; the container layer owns
16
- # that, installing from the repo's manifest so it stays reproducible.
17
- # 3. A full-stack verification (sharp loads, art libs import) so a green
18
- # first-run means the box is genuinely ready, not just "built".
19
- #
20
- # No secrets are written here (ADR 0022): .env.local is copied from the example
21
- # with blank placeholders; the per-builder Gemini key and GDS session arrive at
22
- # runtime via the mounted ~/.config/otb volume and /builder-setup.
23
-
24
- set -uo pipefail
25
-
26
- cd /workspace 2>/dev/null || cd "$(git rev-parse --show-toplevel 2>/dev/null || echo .)"
27
-
28
- bold=$'\033[1m'; green=$'\033[32m'; yellow=$'\033[33m'; dim=$'\033[2m'; reset=$'\033[0m'
29
- say() { echo "${bold}$*${reset}"; }
30
-
31
- say "Example Dev Box — first-run provisioning"
32
- echo
33
-
34
- # git trusts the mounted workspace even though its owner differs from the
35
- # container user (avoids "detected dubious ownership" on every git command).
36
- git config --global --add safe.directory /workspace 2>/dev/null || true
37
-
38
- # node_modules is a container-isolated named volume (see devcontainer.json). A
39
- # fresh volume mounts root-owned, so hand it to the runtime user before the
40
- # npm ci inside setup-builder.sh tries to populate it.
41
- if [ -d node_modules ]; then
42
- sudo chown vscode:vscode node_modules 2>/dev/null || true
43
- fi
44
-
45
- # --- 1. Bring up the firewall BEFORE installing dependencies ------------------
46
- # postStartCommand also runs the firewall on every start, but that's AFTER this
47
- # postCreate step — which would leave `npm ci` + `pip install` below running with
48
- # unrestricted egress on first create, a window a malicious (post)install script
49
- # could exfiltrate through. Apply default-deny up front so dependency installs
50
- # happen behind the allow-list (npm + PyPI + GitHub are allow-listed, so they
51
- # still work). Non-fatal: if it can't apply (e.g. a laptop without NET_ADMIN),
52
- # postStart will report it; we don't block provisioning here.
53
- say "1/4 Securing egress (default-deny firewall, before dependency installs)"
54
- if sudo /usr/local/bin/otb-init-firewall.sh; then
55
- echo " ${green}ok${reset} firewall active — installs run behind the allow-list"
56
- else
57
- echo " ${yellow}!!${reset} firewall did not apply (see above); dependency installs will run with open egress this once"
58
- fi
59
- echo
60
-
61
- # --- 2. Fold in setup-builder.sh (toolchain + npm ci + .env.local) ------------
62
- say "2/4 Toolchain + dependencies (scripts/setup-builder.sh --no-auth)"
63
- if [ -x scripts/setup-builder.sh ]; then
64
- if bash scripts/setup-builder.sh --no-auth --skip-keys; then
65
- echo " ${green}ok${reset} setup-builder.sh completed"
66
- else
67
- echo " ${yellow}!!${reset} setup-builder.sh reported a problem — review the output above"
68
- fi
69
- else
70
- echo " ${yellow}!!${reset} scripts/setup-builder.sh not found/executable — running npm ci directly"
71
- npm ci --no-audit --no-fund || echo " ${yellow}!!${reset} npm ci failed"
72
- fi
73
- echo
74
-
75
- # --- 2. Art pipeline Python deps into the venv --------------------------------
76
- # Non-fatal: a box without art deps is still fully usable for game/GDS work.
77
- # Retry a few times — on a macOS Docker Desktop bind mount, VirtioFS can
78
- # transiently return EDEADLK ("Resource deadlock avoided") reading repo files;
79
- # a retry (and a fresh container) usually clears it. The DO box (#598) has no
80
- # bind mount, so this never bites there.
81
- say "3/4 Art-pipeline Python deps (into ${OTB_VENV:-venv})"
82
- if [ -f modules/art-pipeline/pipeline/requirements.txt ]; then
83
- art_ok=0
84
- for attempt in 1 2 3; do
85
- if pip install --no-cache-dir -r modules/art-pipeline/pipeline/requirements.txt; then
86
- echo " ${green}ok${reset} art deps installed"
87
- art_ok=1
88
- break
89
- fi
90
- echo " ${dim}--${reset} attempt ${attempt} failed; retrying…"
91
- done
92
- if [ "$art_ok" -eq 0 ]; then
93
- echo " ${yellow}!!${reset} pip install failed after retries — the art pipeline won't run until resolved."
94
- echo " On a macOS laptop this is usually Docker Desktop's VirtioFS (EDEADLK):"
95
- echo " rebuild the container, or switch Docker Desktop → Settings → General →"
96
- echo " file sharing to 'gRPC FUSE'. (The box is otherwise ready.)"
97
- fi
98
- else
99
- echo " ${dim}--${reset} no modules/art-pipeline/pipeline/requirements.txt; skipping"
100
- fi
101
- echo
102
-
103
- # --- 3. Full-stack verification -----------------------------------------------
104
- say "4/4 Verifying the box is ready"
105
- # sharp was verified here as "the native image dep". Task 1003207 removed it: its
106
- # only consumers were the game-era snapshot renderers and an art-pipeline test,
107
- # all of which left this core with the game. Nothing native remains to prove.
108
- # The five art libs must import in the venv.
109
- if python3 -c "import PIL, numpy, scipy, sklearn, certifi" >/dev/null 2>&1; then
110
- echo " ${green}ok${reset} art libs import (Pillow, numpy, scipy, scikit-learn, certifi)"
111
- else
112
- echo " ${yellow}!!${reset} one or more art libs failed to import"
113
- fi
114
- echo
115
-
116
- # --- Claude Code default permission mode (task 1251) --------------------------
117
- # Match the host (infra/box-source-fetch.sh): default this container's interactive
118
- # Claude Code to bypassPermissions so `claude` never stops for a prompt on the
119
- # (isolated, often unattended) dev box. USER-level (~/.claude/settings.json — the
120
- # persisted otb-claude-config volume), NEVER the repo's project .claude/settings.json,
121
- # so laptops / local clones are unaffected; it merges with the project settings
122
- # (which set no defaultMode). Idempotent — only sets the one key, preserving the rest.
123
- say "Defaulting Claude Code to bypassPermissions (box-only ~/.claude/settings.json)"
124
- if mkdir -p "$HOME/.claude" 2>/dev/null && node -e '
125
- const fs = require("fs"), p = process.argv[1];
126
- let s = {}; try { s = JSON.parse(fs.readFileSync(p, "utf8")) || {}; } catch (e) {}
127
- if (typeof s !== "object" || s === null || Array.isArray(s)) s = {};
128
- s.permissions = (s.permissions && typeof s.permissions === "object") ? s.permissions : {};
129
- s.permissions.defaultMode = "bypassPermissions";
130
- fs.writeFileSync(p, JSON.stringify(s, null, 2) + "\n");
131
- ' "$HOME/.claude/settings.json" 2>/dev/null; then
132
- echo " ${green}ok${reset} defaultMode=bypassPermissions written"
133
- else
134
- echo " ${yellow}!!${reset} could not write ~/.claude/settings.json (claude will prompt normally)"
135
- fi
136
- echo
137
-
138
- say "${green}Box provisioned.${reset}"
139
- cat <<'BANNER'
140
-
141
- Next, on first connect:
142
- 1. Authenticate the GDS CLI: node scripts/gds/setup.js (or /builder-setup)
143
- 2. See what you can claim: /builder-start
144
-
145
- The pixel-art pipeline needs a Google AI Studio key in ~/.config/otb/env
146
- (that path is a persisted volume, so it survives box rebuilds). Skip if you
147
- are not running the art pipeline.
148
-
149
- BANNER