Skip to content

chore(.dev): run wrapper from REPO_ROOT to survive stale-PR checkouts#55

Merged
jrphilo merged 1 commit into
mainfrom
chore/loop-stable-cwd
May 13, 2026
Merged

chore(.dev): run wrapper from REPO_ROOT to survive stale-PR checkouts#55
jrphilo merged 1 commit into
mainfrom
chore/loop-stable-cwd

Conversation

@jrphilo
Copy link
Copy Markdown
Collaborator

@jrphilo jrphilo commented May 13, 2026

Summary

Root-causes the "Unable to read current working directory" failure exposed by #54's better error reporting.

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 fails — `git` errors with the message above, `gh pr list` fails through it, the queue check exits.

Fix: cd into `REPO_ROOT` at startup instead of `SCRIPT_DIR`. Reference prompt files via `$SCRIPT_DIR/` absolute paths. `REPO_ROOT` is stable across any branch switch.

This also fixes the agent's own bash cwd (it inherits the wrapper's cwd via the `claude` subprocess) — so the workaround where the agent spawned a worktree subagent after its own shell broke goes away too. Faster sessions, no orphan worktrees.

Test plan

  • `bash -n .dev/dependency.sh`
  • After merge: `./.dev/dependency.sh --upgrade-only --max-deps 7` and watch it process the remaining queue without the cwd-dead error.

🤖 Generated with Claude Code

When the agent does `gh pr checkout <stale-PR>` 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) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
docs-preview dfe909d Commit Preview URL

Branch Preview URL
May 13 2026, 02:44 PM

@jrphilo jrphilo enabled auto-merge (squash) May 13, 2026 14:57
@jrphilo jrphilo merged commit 1aea4bb into main May 13, 2026
8 checks passed
@jrphilo jrphilo deleted the chore/loop-stable-cwd branch May 13, 2026 14:58
jrphilo added a commit that referenced this pull request May 13, 2026
Combines #52 and #53 into a single PR off main, avoiding the
rebase cascade after #44/#42/#54/#55 churn. Both are mechanical
pnpm.overrides additions:

- protobufjs ^7.5.6 — clears alerts #7-14
  (GHSA-q6x5-8v7m-xcrf, GHSA-jvwf-75h9-cwgg, GHSA-75px-5xx7-5xc7,
   GHSA-fx83-v9x8-x52w, GHSA-2pr8-phx7-x9h3, GHSA-66ff-xgx4-vchm,
   GHSA-685m-2w69-288q). Reached via posthog-js OTLP exporter;
   not directly imported by our app.

- fast-xml-builder ^1.1.7 — clears alerts #3, #4
  (GHSA-5wm8-gmm8-39j9, GHSA-45c6-75p6-83cc). Reached via
   @opennextjs/cloudflare → AWS SDK build/deploy tooling; not
   directly used.

Replaces #52, #53.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jrphilo added a commit that referenced this pull request May 13, 2026
…er (#57)

Combines #52 and #53 into a single PR off main, avoiding the
rebase cascade after #44/#42/#54/#55 churn. Both are mechanical
pnpm.overrides additions:

- protobufjs ^7.5.6 — clears alerts #7-14
  (GHSA-q6x5-8v7m-xcrf, GHSA-jvwf-75h9-cwgg, GHSA-75px-5xx7-5xc7,
   GHSA-fx83-v9x8-x52w, GHSA-2pr8-phx7-x9h3, GHSA-66ff-xgx4-vchm,
   GHSA-685m-2w69-288q). Reached via posthog-js OTLP exporter;
   not directly imported by our app.

- fast-xml-builder ^1.1.7 — clears alerts #3, #4
  (GHSA-5wm8-gmm8-39j9, GHSA-45c6-75p6-83cc). Reached via
   @opennextjs/cloudflare → AWS SDK build/deploy tooling; not
   directly used.

Replaces #52, #53.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant