Skip to content

Commit 8358f07

Browse files
committed
fix: bake support utils and allowScripts into image, drop first-run patches
install-browser/install-openspec/validate.sh/browser-state-cleanup are immutable user tools — created at build time as symlinks in ~/.local/bin so they survive rebuilds (previously first-run-only, lost whenever the writable image layer was recreated). pi-coding-agent allowScripts is now declared upstream in the lpb fork (localpibox/pi packages/coding-agent/package.json), so the build just verifies it via a FATAL grep guard instead of patching post-install.
1 parent a2b67ce commit 8358f07

2 files changed

Lines changed: 13 additions & 40 deletions

File tree

Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ RUN set -eux; \
145145
|| (echo "FATAL: Case 4 patch missing from pi-ai" && exit 1); \
146146
grep -rq 'qwen-chat-template' /home/lpb/.npm-global/lib/node_modules/@earendil-works/pi-ai/dist/ \
147147
|| (echo "FATAL: Qwen reasoning_effort patch missing" && exit 1); \
148+
grep -rq 'allowScripts' /home/lpb/.npm-global/lib/node_modules/@earendil-works/pi-coding-agent/package.json \
149+
|| (echo "FATAL: pi-coding-agent allowScripts missing (regression in pi fork)" && exit 1); \
148150
ls -la /home/lpb/.npm-global/bin/; \
149151
rm -rf /opt/pi-src/.git /opt/pi-src/src /opt/pi-src/test /opt/pi-src/tests
150152

@@ -178,8 +180,18 @@ COPY lpb.conf.env /opt/devstack/lpb.conf.env
178180
COPY lpb.stack.env /opt/devstack/lpb.stack.env
179181
COPY --chmod=755 support/entrypoint-cli.sh /opt/devstack/entrypoint-cli.sh
180182

183+
# ── User-facing support utilities (baked, not first-run) ────────────────
184+
# These are immutable tools users invoke from PATH; they live in the image
185+
# layer so they survive rebuilds/recreates. Symlinks are created here (as
186+
# lpb) rather than at container first-run — ~/.local/bin is not a mount, so
187+
# a first-run-only ln would vanish on the next rebuild.
188+
RUN mkdir -p /home/lpb/.local/bin \
189+
&& ln -sf /opt/devstack/install-browser.sh /home/lpb/.local/bin/install-browser.sh \
190+
&& ln -sf /opt/devstack/validate.sh /home/lpb/.local/bin/validate.sh \
191+
&& ln -sf /opt/pi-support/install-openspec.sh /home/lpb/.local/bin/install-openspec.sh \
192+
&& ln -sf /opt/pi-support/browser-state-cleanup.sh /home/lpb/.local/bin/browser-state-cleanup.sh
193+
181194
# ── Shell PATH helper ───────────────────────────────────────────────────────
182-
RUN mkdir -p /home/lpb/.local/bin
183195
COPY --chmod=755 support/lpb-config /home/lpb/.local/bin/lpb-config
184196

185197
# ── Root operations: ownership + gitconfig + shell PATH ─────────────────────

support/start.sh

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -334,26 +334,6 @@ if [[ "$FIRST_RUN" = "true" ]]; then
334334
printf 'allow-scripts=better-sqlite3\nallow-scripts=agent-browser\nallow-scripts=esbuild\nallow-scripts=protobufjs\nallow-scripts=@google/genai\n' > "${AGENT_DIR}/git/.npmrc" 2>/dev/null || true
335335
printf 'allow-scripts=better-sqlite3\nallow-scripts=agent-browser\nallow-scripts=esbuild\nallow-scripts=protobufjs\nallow-scripts=@google/genai\n' > "${HOME_DIR}/.npmrc" 2>/dev/null || true
336336

337-
# Fix pi-coding-agent package.json to include allowScripts
338-
# so native addon npm install scripts are not blocked
339-
PI_PKG="${HOME_DIR}/.npm-global/lib/node_modules/@earendil-works/pi-coding-agent/package.json"
340-
if [[ -f "$PI_PKG" ]]; then
341-
# Try jq first, fallback to python
342-
if command -v jq &>/dev/null; then
343-
jq '. += {"allowScripts": {"better-sqlite3": true, "agent-browser": true, "esbuild": true, "protobufjs": true, "@google/genai": true}}' "$PI_PKG" > "${PI_PKG}.tmp" && mv "${PI_PKG}.tmp" "$PI_PKG"
344-
else
345-
python3 -c "
346-
import json, sys
347-
with open(sys.argv[1]) as f: pkg = json.load(f)
348-
pkg.setdefault('allowScripts', {})
349-
for p in ['better-sqlite3','agent-browser','esbuild','protobufjs','@google/genai']:
350-
pkg['allowScripts'][p] = True
351-
with open(sys.argv[1], 'w') as f: json.dump(pkg, f, indent=2)
352-
" "$PI_PKG"
353-
fi
354-
info "Patched pi-coding-agent package.json with allowScripts."
355-
fi
356-
357337
# ── Config repo: clone/fetch into ~/.pi/agent/ (runs every boot — see §4a)
358338
touch "${HOME_DIR}/.pi/.initialized"
359339

@@ -382,25 +362,6 @@ with open(sys.argv[1], 'w') as f: json.dump(pkg, f, indent=2)
382362
fi
383363
fi
384364

385-
# ── Symlink user-facing support utilities to ~/.local/bin/ ────────────
386-
# These scripts are installed into the image at build time but need to
387-
# be accessible from the user's PATH. ~/.local/bin/ is already in PATH
388-
# (see line 77), so symlinks here make them available as commands.
389-
LOCAL_BIN="${HOME_DIR}/.local/bin"
390-
mkdir -p "$LOCAL_BIN"
391-
for _src in \
392-
/opt/devstack/install-browser.sh \
393-
/opt/devstack/validate.sh \
394-
/opt/pi-support/install-openspec.sh \
395-
/opt/pi-support/browser-state-cleanup.sh \
396-
; do
397-
if [[ -f "$_src" ]]; then
398-
_name="$(basename "$_src")"
399-
ln -sf "$_src" "${LOCAL_BIN}/${_name}"
400-
info "Linked utility: ${_name}${_src}"
401-
fi
402-
done
403-
404365
info "First run bootstrap complete."
405366
fi
406367

0 commit comments

Comments
 (0)