Skip to content

fix(llm): name the repository, not the worktree, in prompt {{ repo }} - #4908

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-45340530290
Nov 28, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-45340530290

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

{{ repo }} in commit and squash prompt templates now renders the repository's name in every worktree. Before, it rendered the current worktree's folder name, so a custom template run from a linked worktree at ~/code/myrepo.feature got myrepo.feature. A hook in the same worktree gets myrepo, and the LLM commits docs describe the variable as "Repository name".

The three prompt sites (build_commit_prompt, the squash preview, the squash run) each derived the name from wt.root(). They now share llm::prompt_repo_name, which reads Repository::repo_path(), the same source build_hook_context and the worktree-path template use. The default templates don't reference {{ repo }}, so only custom templates are affected.

One effect to know about: in a nested bare layout (project/.git with worktrees beside it), the prompt's repo changes from the worktree's folder name (e.g. main) to .git. That's the value hooks already get there. Naming bare repos better was discussed in #1281, #1544 and #1545, and this PR doesn't change that.

The new test test_prompt_repo_names_the_repository_from_a_linked_worktree covers commit --show-prompt, squash --show-prompt, squash --dry-run, and a real squash, all from a linked worktree. On main it fails with repo=repo.feature; with the fix it passes. The merge:: and bare_repository:: integration tests also pass locally, except test_merge_no_ff_signs_merge_commit, which fails the same way on main in this sandbox (ssh refuses the test's signing key because its file permissions are too open).

The commit and squash prompts set `{{ repo }}` from the current
worktree's folder name, so from a linked worktree at `myrepo.feature`
they rendered `myrepo.feature`. Hooks and the worktree-path template
read the repository path's name, and the docs describe `repo` as the
repository name, constant across worktrees.

All three prompt sites (commit prompt, squash preview, squash run) now
go through one helper that reads `Repository::repo_path()`.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Nov 24, 2026
@max-sixty
max-sixty merged commit 3114836 into main Nov 28, 2026
38 of 47 checks passed
@max-sixty
max-sixty deleted the nightly/clean-45340530290 branch November 28, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants