opencode icon indicating copy to clipboard operation
opencode copied to clipboard

site: product capture writes fresh-assets one directory above its documented location

Open caseclose opened this issue 5 days ago • 1 comments

Description

The product screenshot generator promises a fresh-assets directory next to the checkout. After the site moved to services/site, the default goes up one directory too far. The generated manifest also names the old script under packages/console/app.

Steps to reproduce

  1. In a temporary checkout at projects/opencode, run OPENCODE_BIN=false bun services/site/script/capture-assets.ts with no output override. Using false stops before VHS runs, just after the output directory is created.
  2. Inspect the directory. It is fresh-assets alongside projects; the documented location is projects/fresh-assets.

OpenCode version

dev at 88b03b91

Operating System

macOS (arm64), Bun 1.4.4

caseclose avatar Nov 30 '26 11:11 caseclose

Thanks for the precise report. I reproduced this at 88b03b91, which is also the latest dev right now.

I cloned the checkout to <tmp>/projects/opencode and ran OPENCODE_BIN=false bun services/site/script/capture-assets.ts with FRESH_ASSETS_DIR unset. The output folder was created at <tmp>/fresh-assets, and <tmp>/projects/fresh-assets did not exist. That doesn't match the script's own comment or services/site/script/assets/README.md, which both say fresh-assets/ goes next to the checkout.

The cause looks like the default at line 22, path.join(import.meta.dir, "../../../../../fresh-assets"). From services/site/script, that is one .. more than it needs. The manifest's script field (line 73) and the header comment also still point at packages/console/app.

The script below reproduces it. I found no other issue or open pull request about this.

Reproduction script (repro.sh)
#!/bin/sh
# Reproduces anomalyco/opencode#67323: capture-assets.ts default --out lands one directory too high.
# Usage: REPO=/path/to/opencode/checkout sh repro.sh
set -u
REPO=${REPO:-/workspace/repo}
TMP=$(mktemp -d)
mkdir -p "$TMP/projects"
git clone -q --shared "$REPO" "$TMP/projects/opencode"
git -C "$TMP/projects/opencode" checkout -q --detach "$(git -C "$REPO" rev-parse HEAD)"
cd "$TMP/projects/opencode"
echo "commit: $(git rev-parse HEAD)"
unset FRESH_ASSETS_DIR
OPENCODE_BIN=false bun services/site/script/capture-assets.ts 2>&1 | tail -3
echo "--- $TMP/fresh-assets exists?"; ls -d "$TMP/fresh-assets" 2>&1
echo "--- $TMP/projects/fresh-assets (documented) exists?"; ls -d "$TMP/projects/fresh-assets" 2>&1
echo "--- manifest script path in source:"; grep -n 'script: "' services/site/script/capture-assets.ts

Run it: sh repro.sh

opencodejr[bot] avatar Nov 30 '26 11:11 opencodejr[bot]