Fix cwd-changing worktree shims stranding the caller; self-repair disabled rc blocks#46
Merged
Merged
Conversation
cdd-worktree-done (and cdd-worktree/-resume) `cd` the caller's shell, so they only work as sourced functions. The install shims dispatched into a subshell, whose `cd` can't reach the parent — when the command resolved to the shim (function not loaded, e.g. a commented-out rc block) the caller was silently left in the just-removed worktree while the shim printed success. - Ship a refuse-shim for the three cwd-changing commands: reaching it means the function isn't loaded, so it fails loudly with guidance instead of dispatching. cdd-worktree-list keeps its source-and-dispatch shim (it changes no cwd). - Make install self-repairing: key the idempotency guard on the active source line, not a bare marker match, so a present-but-disabled (commented-out) block is rewritten as an active one instead of skipped. Same fix in cdd-state.sh. - Fix the shim-loop comment that omitted cdd-worktree-done from the cwd-sensitive commands. - Extend install-smoke-assert.sh: disabled block is repaired on re-install (both helpers), and a cwd-changing shim fails loudly rather than silently no-op'ing. - Document the refuse-shim behavior and self-repair in process doc §2.8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a checked Phase 8 bug-fix entry for the cwd-changing shim regression and the installer self-repair, reconciling the roadmap with what landed in this branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
drabaioli
commented
Jul 4, 2026
…mments (PR #46 review) Addresses review feedback on PR #46: - roadmap.md: collapse the verbose worktree-shim fix entry to a one-liner. - claude-driven-development.md §2.8: trim the worktree-helper paragraph back to a high-level description, dropping the shim internals this PR had added. - cdd-worktree.sh / cdd-state.sh: shorten the rc self-repair and PATH-shim comment blocks, keeping the load-bearing "why" without the repetition. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
~/.local/binPATH shims for the three cwd-changing worktree commands (cdd-worktree,cdd-worktree-resume,cdd-worktree-done) previously didsource-and-dispatch. But a shim runs in a subshell, whosecdcannot reach the caller's shell — socdd-worktree-done, invoked via the shim (e.g. from a non-interactive shell where the sourced function isn't loaded), silently stranded the user in the just-removed worktree while printing success.exit 1instead of dispatching. Onlycdd-worktree-list, which changes no cwd, keeps a real source+dispatch shim (as doescdd-state).cdd-worktree.sh,cdd-state.sh) now key "already wired" on the active source line — a regex anchored to line-start, so a commented-out block can't match — rather than a bare marker grep. Re-runninginstalltherefore re-enables a disabled/mangled rc block instead of skipping it.Testing
scripts/install-smoke-assert.shextended to cover both behaviors:cdd-worktree-done) fails loudly rather than silently no-op'ing thecd;installself-repairs a disabled managed block back to a single active source line, for both the worktree and state helpers.All pre-PR gates pass:
bash -n, shellcheck, command-set drift, prompt-seam, install smoke, worktree-resume, e2e bootstrap smoke, demo seed-overlay.Docs
Process doc §2.8 (worktree helper) updated to describe refuse-loudly + self-repair; roadmap Phase 8 records the fix.
🤖 Generated with Claude Code