From dfe909dcf9f27d9806d3ff5242e8e2f4730fa651 Mon Sep 17 00:00:00 2001 From: jrphilo Date: Wed, 13 May 2026 10:41:17 -0400 Subject: [PATCH] chore(.dev): run wrapper from REPO_ROOT, not .dev/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the agent does `gh pr checkout ` on a Dependabot branch forked before `.dev/` was merged to main, `.dev/` is unlinked from disk. If the wrapper's cwd is `.dev/`, the shell's $PWD becomes a dead inode and every subsequent command — including the queue's `gh pr list` — fails with "Unable to read current working directory." Switch the wrapper to cd into REPO_ROOT at startup and reference prompt files via $SCRIPT_DIR/. REPO_ROOT survives any branch switch the agent makes inside its session. This also fixes the agent's own bash cwd (it inherits the wrapper's cwd via the claude subprocess), so the dance where the agent had to spawn a worktree subagent as a workaround goes away. Co-Authored-By: Claude Opus 4.7 (1M context) --- .dev/dependency.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.dev/dependency.sh b/.dev/dependency.sh index 94a0ef5..f18988b 100755 --- a/.dev/dependency.sh +++ b/.dev/dependency.sh @@ -76,14 +76,21 @@ if [ -n "$OVERRIDE" ] && [ -z "$SINGLE_PR" ]; then fi SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -cd "$SCRIPT_DIR" || exit 1 # ── Base branch resolution ── # Single-checkout setup (no isolated worktree). The hard-reset a few lines # down operates on the maintainer's primary docs checkout — the # uncommitted-changes guard below is the only thing standing between a stray # edit and `git reset --hard origin/main`. Don't relax it. -REPO_ROOT="$(git rev-parse --show-toplevel)" +REPO_ROOT="$(cd "$SCRIPT_DIR" && git rev-parse --show-toplevel)" + +# Operate from REPO_ROOT, not SCRIPT_DIR (.dev/). Reason: when the agent +# does `gh pr checkout ` on a branch forked before `.dev/` was +# merged to main, `.dev/` gets unlinked from disk. If the wrapper's cwd +# is `.dev/`, the shell's $PWD becomes a dead inode and every subsequent +# command — including the queue's `gh pr list` — fails with "Unable to +# read current working directory." REPO_ROOT survives any branch switch. +cd "$REPO_ROOT" || exit 1 case "$REPO_ROOT" in */docs) BASE_BRANCH="main" @@ -134,7 +141,9 @@ else fi run_session() { - local prompt_file="$1" + # Prompt file is named relative to SCRIPT_DIR; resolve to absolute so + # this works regardless of the wrapper's cwd (REPO_ROOT). + local prompt_file="$SCRIPT_DIR/$1" local label="$2" echo -e "\n ${DIM}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"