#!/usr/bin/env bash # Usage: tasks/lanes/setup-lane.sh [base-ref] # LANE lane letter (B, D, ...) -> worktree $LANES_DIR//wt on branch lane/ # INT* names make a detached worktree for integration checks # base-ref defaults to fix/maturity-review-2026-09-25; an existing lane/ # branch is checked out as is instead of created # LANES_DIR defaults to /../-lanes. # node_modules is a real directory of per-entry symlinks into the repo's own # node_modules; pnpm's state files are copied and retargeted so `corepack pnpm` # in the worktree does not start an install through the shared packages. set -euo pipefail LANE="$1" BASE="${2:-fix/maturity-review-2026-09-25}" R="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)" LANES_DIR="${LANES_DIR:-$(dirname "$R")/$(basename "$R")-lanes}" W="$LANES_DIR/$LANE/wt" mkdir -p "$(dirname "$W")" if [[ "$LANE" == INT* ]]; then git -C "$R" worktree add --detach "$W" "$BASE" elif git -C "$R" show-ref --verify --quiet "refs/heads/lane/$LANE"; then git -C "$R" worktree add "$W" "lane/$LANE" else git -C "$R" worktree add -b "lane/$LANE" "$W" "$BASE" fi mkdir "$W/node_modules" for e in $(ls -A "$R/node_modules"); do case "$e" in .pnpm-workspace-state-v1.json|.modules.yaml|.package-map.json) cp "$R/node_modules/$e" "$W/node_modules/$e" ;; .vite) ;; *) ln -s "$R/node_modules/$e" "$W/node_modules/$e" ;; esac done node -e ' const fs = require("fs"); const f = process.argv[1] + "/node_modules/.pnpm-workspace-state-v1.json"; const s = JSON.parse(fs.readFileSync(f, "utf8")); const v = Object.values(s.projects)[0]; s.projects = { [process.argv[1]]: v }; s.lastValidatedTimestamp = Date.now(); fs.writeFileSync(f, JSON.stringify(s, null, 2)); ' "$W" echo "$W"