Repository navigation
refactor(config): stop supplying the deprecated template variables, migrating them on load - #4080
Conversation
`commit_details` is now the only commit list `build_prompt` passes to a squash template or to the user/project append fragments. The renderer no longer carries the deprecated `commits` list of bare subject strings. The rename moves into the layer that owns config deprecation: `DEPRECATED_VARS` keeps the four path variables whose old names are still supplied at runtime, and a new `RETIRED_VARS` holds `commits` -> `commit_details` under a `Structural` rule, so it is rewritten on every config load rather than only by `wt config update`. An unmigrated squash template therefore renders exactly what it did before instead of losing its commit list to minijinja's lenient undefined handling, and the existing warning still points at `wt config update`. Refs #2984
worktrunk-bot
left a comment
There was a problem hiding this comment.
Self-review. No functional issues: the UpdateOnly/Structural split is sound, and the unchanged test_step_squash_show_prompt_deprecated_commits_warns snapshot — still Squashing 2 commits from feature with nothing supplying commits — is real evidence the load-path rewrite carries the compatibility rather than an assertion that it does. Two comment corrections inline, plus one test-battery gap below.
rewrite_template_var_identifiers now runs on every config load instead of only when the user asks for wt config update, so an identifier that merely contains commits would be mangled in the user's in-memory config on every command rather than once, at their request. recent_commits is exactly that name, and it is a live variable in both prompt contexts and in DEFAULT_SQUASH_TEMPLATE. It is safe today — deprecated_vars_in_template gates on undeclared_variables and the rewrite matches whole identifiers — but nothing pins it: the untouched battery in test_warning_fires_iff_update_changes has no near-miss entry, and recent_commits appears nowhere in deprecation.rs. One line there (a [commit.generation] squash-template = "{{ recent_commits | length }}", asserting no warning and no rewrite) locks the boundary now that crossing it costs more.
…near-miss The DEPRECATED_VARS doc named build_template_vars, which exists nowhere; the runtime aliases come from build_hook_context. Fix a word slip in the build_prompt comment, and add the recent_commits case to the test_warning_fires_iff_update_changes untouched battery, since the retired-var rewrite now runs on every config load.
|
but if they've been deprecated for a while, can we just remove them? |
worktrunk-bot
left a comment
There was a problem hiding this comment.
but if they've been deprecated for a while, can we just remove them?
The answer splits in two, because the two groups of deprecated template variables fail differently when the name stops resolving.
The four path variables — yes, and the break is loud. repo_root, worktree, main_worktree, and main_worktree_path have been deprecated since v0.9.0 (2026-01-02, #369); we're on v0.77.0. They live in hook, alias, and --execute templates, which are the surfaces that validate: validate_template rejects any identifier outside vars_available_in(scope), and expansion renders through template_environment, which sets UndefinedBehavior::SemiStrict. So deleting them — the three map.insert calls under the // Deprecated aliases comment in build_hook_context, the main_worktree_path arm just below it, the DEPRECATED_TEMPLATE_VARS list in src/config/expansion.rs, and the DEPRECATED_VARS rows in src/config/deprecation.rs — turns {{ repo_root }} into a named error that lists the available variables, rather than an empty string. That is a clean removal with no migration layer left behind, and it is a separate concern from this PR; I'll open it on your word.
commits — this is the one case where removal is silent. Deprecated in v0.59.0 (2026-06-13, #2985), 18 minor releases. The prompt renderer is the only template surface in the codebase with neither a validation pass nor a strict environment: build_prompt builds a bare Environment::new(), so undefined behavior is Lenient, and {% for c in commits %} over an undefined value renders an empty loop instead of erroring. The warning doesn't survive the deletion either — it is produced by the same table row — so a user whose squash template still says commits would get a prompt with no commit list, no warning, and a plausible-looking message generated from the diff alone. That is the outcome #2984 opens by naming, and it is the whole reason the rewrite row is still here.
What would make commits deletable too: give prompt templates what every other template surface already has — a SemiStrict environment plus validation against a declared variable list. Then the row deletes cleanly, and every future prompt-variable retirement is loud by default instead of needing its own retirement check. That is much less machinery than #4066 carried, but it is still a product decision — a squash template with a typo would start erroring where it currently renders empty — so I haven't folded it into this PR.
`repo_root`, `worktree`, `main_worktree`, and `main_worktree_path` were still resolved at render time alongside the names that replaced them, eight months after v0.10.0 deprecated them. With `commits` already gone from the squash renderer, remove these four too: `build_hook_context` and `UserConfig::format_path` insert one name per value, and `vars_available_in` no longer appends `DEPRECATED_TEMPLATE_VARS`, so the constant goes and every undefined-variable error lists current names only. That collapses the config-deprecation layer's two template-variable tables into one. `DEPRECATED_VARS` (rewritten only by `wt config update`, because the old names still resolved) and `RETIRED_VARS` (rewritten on every load) differed only in when the rewrite applies, which nothing distinguishes now: one table, one `Structural` rule, all five renamed before serde parses. Keeping that rewrite is what keeps existing configs working, and it can't come out with the rest, because the failure it would expose isn't uniform. A hook, alias, or `worktree-path` template fails its `SemiStrict` expansion with an undefined-variable error naming the variable. A squash template renders under minijinja's `Lenient` default, so it would silently produce a prompt with no commit list — the outcome #2984 opens by calling out. A retired name typed on the command line rather than stored in config (`wt switch --execute 'code {{ worktree }}'`) now fails with that undefined-variable error; config files, `--config-set`, and `WORKTRUNK_*` overlays all migrate.
|
Yes — pushed as 2a04a85, so this no longer needs a separate PR. Nothing supplies any of the five now: One difference from the review that landed above. It proposed deleting the four path variables' That leaves the What breaks either way: a retired name typed on the command line, e.g. |
worktrunk-bot
left a comment
There was a problem hiding this comment.
Self-review of 2a04a85. Three points; the first one (inline, on the fixture change in approval_save.rs) is a decision rather than a fix I'd just push.
template_references_repo_name still branches on a retired name. In src/commands/worktree/resolve.rs the bare-repo worktree-path offer tests template_references_var(template, "repo") || template_references_var(template, "main_worktree"), and its unit test pins a "deprecated main_worktree alias" case as true. The template it inspects is config.worktree_path_for_project(…) — an already-migrated value — so the second arm can no longer match. The PR's premise is that nothing resolves these names any more, and this is the one production branch left that says otherwise. Same sweep: the styling demo in src/commands/configure_shell.rs still renders cp {{ repo_root }}/target {{ worktree }}/target as its sample shell snippet, which is user-visible output advertising two names that now error. Both are one-line deletions; say the word and I'll batch them into this PR.
--var <retired-name> now silently loses effect, and "What this does break" doesn't mention it. --var force-binds regardless of whether any template references the key, so wt hook pre-start --var main_worktree=/custom/path against a config saying {{ main_worktree }} used to render /custom/path. The load rewrite turns that template into {{ repo }}, the override binds a name nothing reads, and the hook runs against the real repo name — no error, which is the shape of failure the commits half of this PR exists to avoid. test_var_flag_deprecated_alias_works was the only coverage and it's deleted here. The config deprecation warning still fires on the template, so it isn't unsignalled, but it belongs in the break list beside the CLI-typed templates rather than being absent from it.
| # These comments should be preserved after saving | ||
|
|
||
| worktree-path = "../{{ main_worktree }}.{{ branch }}" # inline comment should also be preserved | ||
| worktree-path = "../{{ repo }}.{{ branch }}" # inline comment should also be preserved |
There was a problem hiding this comment.
Changing the fixture is what keeps this test green, and the green now covers over the case the test was written to catch.
With {{ main_worktree }} here, set_commit_generation_command → with_locked_mutation → reload_from parses the migrated content, so in-memory worktree_path is ../{{ repo }}.{{ branch }} while the file still says main_worktree. save_to's diff then takes the !items_equal branch in merge_tables and does *existing_item = desired_item.clone(), swapping in a freshly serialized item with default decor — so # inline comment should also be preserved is dropped and the assertion 32 lines below fails. That only became reachable when the template-variable rule moved from UpdateOnly to Structural; before this PR the reload left the line alone and there was no diff to apply.
The consequence outside the test: wt merge setting skip-commit-generation-prompt, or any other with_locked_mutation caller, now rewrites the user's worktree-path line and deletes whatever comment sat on it — a write to a user-owned file as a side effect of an unrelated command, which Data Safety in CLAUDE.md rules out ("never silently delete/overwrite as a side effect of an unrelated operation"). The rename itself the PR argues for and I don't think that's in question; the comment is collateral, and save_to's own contract is "Preserves comments and formatting in the existing file".
Two ways out, and which is right is a call I'd rather you make than guess at:
- Carry the existing value's decor across the replacement in
merge_tables, so a changed scalar keeps its comment. That matchessave_to's stated contract and helps everywt config set, not just this rule — but it changes behavior for value updates generally, where a stale comment surviving its value is arguably worse. - Accept the loss, put
{{ main_worktree }}back in this fixture, and assert that the inline comment goes — so the behavior is recorded in the suite rather than only in the PR body.
Either way the fixture should keep a retired name in it; as written, nothing in the suite exercises a mutation against an unmigrated config.
`template_references_repo_name` in the bare-repo `worktree-path` offer still
ORed `template_references_var(template, "main_worktree")`, and a unit case
pinned that arm as `true`. The template it inspects comes from the loaded
config, which the deprecation layer has already renamed, so the arm can no
longer match — dead logic that contradicts the premise of the change.
`wt config show-theme`'s shell-highlighting sample also still rendered
`cp {{ repo_root }}/target {{ worktree }}/target`, i.e. user-visible output
advertising two names that now fail expansion. Its snapshot moves with it.
Drop this PR's CHANGELOG.md entry. Changelog entries are written from the commits at release time (CLAUDE.md, Releases), so an open PR carrying an entry drops it rather than resolving a conflict on it.
…te parser (#4124) Deprecated template variables are found with MiniJinja but rewritten with a hand-rolled scanner, and the two disagreed on a closing delimiter inside a quoted string and on a name the template rebinds with `set`, `for`, or `with`. #4080 made that rewrite run on every config load, so both became visible in rendered output. The scanner now skips quoted strings when finding a tag's end, and drops a deprecated name from the replacement set wherever the template binds it. Note: we intend to remove much of this code — the hand-rolled template-variable scanner and the retired-variable migration it serves in src/config/deprecation.rs. This lands now because #4080's regression otherwise ships in 0.78.0, not because the scanner is meant to stay. Closes #4117.
#4139) Requested by @max-sixty in #2984 (comment) — "fix those references, add a TODO to remove the vars in 3 months". #4080 stopped supplying the retired template variables to any renderer and moved their renames into the load-path deprecation layer. Two docstrings still described the old behavior, and there was no record of when the rename rows themselves can go. ## Comment fixes - `format_path`'s argument doc said `main_worktree` "supplies both `{{ main_worktree }}` and `{{ repo }}`". #4080 deleted the `vars.insert("main_worktree", …)` line directly below it, so only `{{ repo }}` is supplied now. - `Command::template`'s doc offered `{{ worktree }}` as an example variable; it is retired to `worktree_path`. ## TODO on `RETIRED_VARS` Dates the removal at 2026-12-16, three months on from #4080, and records the constraint that makes the rows non-uniform: dropping a row stops the rename, so the old name has to fail loudly on its own first. A hook, alias, or `worktree-path` template already does, through `SemiStrict` expansion — but `commits` renders under minijinja's `Lenient`, which iterates an undefined value as an empty sequence, so dropping that row alone would silently empty a squash prompt's commit list. That row can only go once `build_prompt` rejects the name itself, which is the open question on #2984. Comments only — no behavior change, no `CHANGELOG.md` entry. `cargo clippy --lib --all-features`, `cargo fmt --check`, and `cargo test --lib config::` (550 tests) pass locally. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Co-authored-by: Worktrunk Bot <worktrunk-bot@users.noreply.github.com>
Version bump to 0.78.0 plus the changelog section for this release, a comment-preservation fix the release review turned up, a PTY test-filter fix, and merges of `main` (commits that landed during the review, including #4124, #4122, #4141, #4140 and #4145). **Bump level**: minor. `cargo semver-checks` reports 2 breaking library changes — a new `leftover_branch` field on the `GitError::WorktreeCreationFailed` struct variant, and `DEPRECATED_TEMPLATE_VARS` removed. Pre-1.0, so a breaking change takes a minor bump. ## Comment-preservation fix A config save — declining the commit-generation offer, say — dropped the trailing comment on every value it rewrote. That was already true in v0.77.0 for a line the save itself changed (`skip-commit-generation-prompt = false # note` → `true`, reproduced on the v0.77.0 binary). #4080 widened it to lines the command never touched: retired template variables now migrate on every load, so the next unrelated save rewrote any line naming one. #4080's own PR said this "needs a call before merge" and merged without one. - `replace_keeping_decor` keeps the value's decor (spacing after `=`, trailing comment) when `merge_tables` replaces a scalar. Comments *above* a line sit on the key and were never at risk. - `main`'s #4120 independently reworked the inline-table arm and moved a key's leading comment onto the rewritten header, but documented that a trailing comment after the closing brace "is still dropped". `replace_inline_with_table` now carries it after the header's `]`, so both of its callers keep it. - Tests: the existing comment-preservation test goes back to a retired name (the only fixture that exercises the replacement) and adds a comment on the mutated line; a new test snapshots and re-parses an inline `[projects]` entry. Each fails without its half of the fix. Not fixed, and identical on v0.77.0: a save deletes an explicitly written *default* value (e.g. `skip-commit-generation-prompt = false # note`) as a stale key, comment included. ## `--help` correction #4104 moved the OpenCode plugin path to etcetera's `Xdg` strategy, which uses `$XDG_CONFIG_HOME` only when absolute — a deliberate, documented choice — but `wt config plugins opencode --help` still said install mirrors OpenCode's precedence. OpenCode reads a relative value as-is, so the help now says an empty `$OPENCODE_CONFIG_DIR` and an empty or relative `$XDG_CONFIG_HOME` are ignored. ## Data-loss surface review Independent finders swept the full diff, including the five commits merged from `main`. Nothing holds the tag; candidates were adjudicated against v0.77.0 binaries: - **Fixed in this release, reproduced on v0.77.0**: #4104 stops `wt config shell install` (with Nushell) deleting a `nushell/vendor/autoload/wt.nu` under the current directory when `$XDG_CONFIG_HOME` is empty or relative; #4120 stops a save or migration from writing an inline section's comment inside `[commit]` brackets, which made the config unparseable, and from dropping unknown keys. - **`wt step prune --min-age` doesn't apply where no reflog exists** — pre-existing, proven by building the pre-#4077 binary. `git clone --bare` and `git fetch` into `refs/heads/*` write no reflog, so in the bare layout `tips-patterns.md` recommends every branch starts unprotected. Docstring corrected here; behavioral fix is follow-up. - **`wt config update --output <path>` replaces any named file whole**, no existence check or prompt — pre-existing, follow-up. - **`wt config shell install fish --yes` replaces a hand-written wrapper at the XDG path** — accepted ("ownership is the path", predates #3602), newly reachable only for users with `$XDG_CONFIG_HOME` set. The FAQ's delete inventory now cross-references it. - **`--var <retired-name>` binds a name nothing references** after #4080 — inert, no shipped usage; follow-up. - **#4135 migrates nothing**: an existing oh-my-pi hook stays put, `pi uninstall` points at `omp uninstall`. `PI_CODING_AGENT_DIR='~/x'` is used literally (Pi expands `~`) — creates a stray directory, deletes nothing; follow-up. ## Changelog 37 entries; each new or edited entry was re-verified against v0.77.0 until a pass came back clean (six passes in all). Passes caught, among others: the OpenCode `-x` recipe was wrong since 0.76.0, not 0.75.0; #4080's JSON reaches every hook, not just `pre-start`/`post-start`; a quoted git error string git never prints; a copy-button overlap that existed only inside this release; #4104's relative-`XDG_CONFIG_HOME` OpenCode change described as a fix when OpenCode reads that path as-is; and which commands a broken inline section stopped. **Fixed** leads with the data-loss entries. ## Open PRs checked against v0.77.0 - **#4124** fixed a bug new in this release, caused by #4080, and has landed and been merged in here. The hand-rolled template-variable scanner it extends is slated for removal; see its commit message. - **#4112** — no data-loss regression vs v0.77.0; two small non-safety regressions from #4111 (an uncapped auto-staging file list, a narrow `Nothing to commit` refusal under `status.showUntrackedFiles = no`). Not merged, by decision. - **#4122** (merged in) and **#4123** — pre-existing bugs, identical on v0.77.0. ## PTY filter fix `test (macos)` failed once on a shell's failed-`setpgid` diagnostic that landed straight after the capture's trailing `\x1b[0m`, with no newline between, so #4136's line-anchored filter missed it. The filter now also matches right after an SGR escape and keeps the escape; its test gains that shape and fails on the old pattern. ## Validation - `cargo run -- hook pre-merge --yes` — 4930 tests passed, 1 skipped; clippy, fmt, doc-sync, snapshot and lockfile checks green - Nightly on the original cut-from tip (https://github.com/max-sixty/worktrunk/actions/runs/35060617020): green across `full-tests` on linux/macos/windows, `feature-powerset`, all `release-target`s, `nix-flake`, `minimal-versions`, `link-check` > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
worktrunk 0.78.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **Hook scripts read renamed context keys**: the JSON piped to every hook drops `worktree`, `repo_root`, `main_worktree`, and `main_worktree_path` in favour of `worktree_path`, `repo_path`, `repo`, and `primary_worktree_path`. Config templates migrate on load, so hooks written with the old names keep working; scripts reading the JSON, `--execute` templates, and `--var` overrides need updating. (Breaking.) ([#4080](max-sixty/worktrunk#4080)) - **`wt config plugins pi` installs for Pi; oh-my-pi moves to `wt config plugins omp`**: `pi install` wrote an oh-my-pi hook, which Pi never loads; Pi users re-run it to get a Pi extension. Existing oh-my-pi hooks keep working, listed as outdated until `wt config plugins omp install`. (Breaking: scripts that run `wt config plugins pi` for oh-my-pi need `omp`.) [Docs](https://worktrunk.dev/claude-code/#oh-my-pi) ([#4135](max-sixty/worktrunk#4135), thanks @ashebanow) - **Interactive prompts no longer open with a blank line**: `wt config shell install`, `wt config plugins claude install`, and the commit-message setup offer in `wt merge` began with one. ([#4059](max-sixty/worktrunk#4059)) - **`wt config show` gives a single `wt config shell install` hint**: an outdated wrapper, a fish wrapper at the deprecated `conf.d` path, and missing fish completions each printed their own hint. The zsh `compinit` snippet is now syntax-highlighted. ([#4059](max-sixty/worktrunk#4059)) - **`wt config update --output <path>` confirms the write**: it now prints `✓ Wrote user config migration @ ~/migrated.toml` where it printed nothing. `--output=-` stays silent. ([#4053](max-sixty/worktrunk#4053)) ### Fixed - **Removal no longer discards untracked files hidden by `status.showUntrackedFiles = no`**: under that setting, a worktree holding only untracked files looked clean, so `wt remove`, `wt merge`, and `wt step prune` removed it without `--force`. Safety checks now always count untracked files, and auto-staging warnings list every file they stage. ([#4111](max-sixty/worktrunk#4111), thanks @Duang777) - **`wt remove` and `wt merge` check the right worktree under an inherited `GIT_DIR`**: run from a `!wt` git alias or a git hook, which pass `GIT_DIR` down, `wt remove` could delete a dirty worktree without `--force`, and `wt merge` could refuse a clean merge. Both now check the worktree they act on. ([#4082](max-sixty/worktrunk#4082), thanks @Duang777) - **`wt merge` no longer deletes a worktree locked with `git worktree lock`**: the merge completes and prints `Worktree preserved (locked)`. Every Worktrunk removal refuses a locked worktree, even with `--force`; run `git worktree unlock <path>` first. ([#4073](max-sixty/worktrunk#4073), thanks @Duang777) - **`wt config update` no longer overwrites a config edited while its prompt is open**: it wrote the pre-prompt snapshot over the newer file and reported success. It now fails with the path and leaves the newer file; re-running previews the current contents. ([#4127](max-sixty/worktrunk#4127), thanks @zach-hammad-vs for reporting) - **`wt step prune` no longer deletes a branch created minutes ago from an older commit**: `--min-age` aged a branch without a worktree by its commit's date, so a new branch off a day-old commit was pruned on the next run. Age now comes from the branch's oldest reflog entry. ([#4077](max-sixty/worktrunk#4077)) - **A comment or blank line above an inline config section no longer breaks the config**: a save or migration that rewrote `commit = { … }` as `[commit]` put that line inside the brackets. `wt switch`, `wt merge`, `wt remove`, and several `wt step` commands then failed with `Failed to load config`; `wt list` warned and ran without the config. Saves also dropped unrecognized keys from inline sections. ([#4120](max-sixty/worktrunk#4120), thanks @zach-hammad-vs for reporting) - **Config saves keep the trailing comment on a value they rewrite**: a save such as answering the commit-generation offer dropped the comment after each value it rewrote, including one after an inline section's closing brace. ([#4138](max-sixty/worktrunk#4138)) - **Ignored project-config keys warn from every worktree**: an unknown key in `.config/wt.toml`, or one that belongs in user config such as `[merge]`, warned only in the main worktree, so `wt merge` from a linked worktree ignored it silently. ([#4145](max-sixty/worktrunk#4145), thanks @ee-prog for reporting) - **`wt merge` skips `post-commit` when it removes that hook's worktree**: before, the hook ran in the primary worktree when the removed one sat inside the repository, and otherwise didn't run. The merge now prints `▲ Skipped post-commit`; move work that must finish there to `pre-remove`. ([#4049](max-sixty/worktrunk#4049)) - **`wt switch` recovers from a removed worktree in a bare repository**: `wt switch` and the picker surfaced git's raw `fatal: Unable to read current working directory` instead, and the removed-directory message lacked `wt switch ^`. ([#4067](max-sixty/worktrunk#4067)) - **`wt config shell install fish` puts the wrapper where fish reads it under a custom `$XDG_CONFIG_HOME`**: the wrapper always went to `~/.config/fish/functions/`, so install reported success while `wt switch` changed no directory. On Windows, the fish completion moves from `%APPDATA%\fish\completions` to the wrapper's directory. ([#4107](max-sixty/worktrunk#4107)) - **`wt config shell install zsh` honours `$ZDOTDIR` only when it is absolute**: an empty or relative value resolved against the current directory, so install appended to a `.zshrc` under the current directory and reported success while the file zsh reads went untouched. A non-absolute value now falls back to `$HOME`. ([#4085](max-sixty/worktrunk#4085)) - **`wt config shell install` for Nushell no longer deletes a `wt.nu` under the current directory**: an empty or relative `$XDG_CONFIG_HOME` resolved against it, so install removed a `nushell/vendor/autoload/wt.nu` beneath it unread, as a stale wrapper. It now falls back to `~/.config`, which also fixes unread `tea` logins that let `wt switch pr:<n>` treat a Gitea host as GitHub. ([#4104](max-sixty/worktrunk#4104)) - **`wt switch --create` names the branch a failed worktree add leaves behind**: `git worktree add -b` writes the branch ref before populating the worktree, so a failure in between left the branch with no worktree, and the next attempt reported a name collision. The error now says how to delete or reuse it. ([#4109](max-sixty/worktrunk#4109), thanks @technicalpickles for reporting) - **`wt config shell install` no longer tells an already-wrapped shell to restart**: reinstalling from a shell with the wrapper loaded, such as after a version bump, printed `↳ Restart shell to activate shell integration`. ([#4059](max-sixty/worktrunk#4059)) - **`wt config shell install` migrates a deprecated `conf.d` fish wrapper when `~/.config/fish/functions` is missing**: before, only `wt config shell install fish` migrated it. `wt config show` now reports that wrapper even when fish isn't on `PATH`. ([#4059](max-sixty/worktrunk#4059)) - **Plugin status and uninstall checks ask the agent CLIs**: `wt config show` could list an installed Claude Code plugin or Gemini CLI extension as not installed, and `wt config plugins claude|codex uninstall` could report success over a marketplace still configured. A repeat Claude uninstall now runs both removals instead of stopping at `Plugin not installed`. ([#4048](max-sixty/worktrunk#4048), [#4054](max-sixty/worktrunk#4054)) - **`wt config plugins opencode install` no longer writes the plugin into the current directory**: with `OPENCODE_CONFIG_DIR` set but empty, it wrote `plugins/worktrunk.ts` there, typically inside a repository, reporting success though OpenCode never saw it. An empty value now counts as unset. ([#4084](max-sixty/worktrunk#4084)) - **The OpenCode plugin clears its activity marker when OpenCode 1 disposes it**: only explicit session deletion cleared it, so a finished session kept its `💬` and `wt list` showed it as active until `wt config state marker clear` was run by hand. ([#4129](max-sixty/worktrunk#4129), thanks @drewdas for reporting) - **`wt config update` migrates `[ci] platform` into a `[forge]` section that only sets `hostname`**: that config, common with GitHub Enterprise and self-hosted GitLab, kept the deprecated key with no deprecation warning. ([#4061](max-sixty/worktrunk#4061)) - **Deprecated keys in an inline `[projects]` entry now migrate**: `"example.com/org/repo" = { merge = { no-ff = true } }` skipped the migration the section form got, so the per-project setting was ignored. ([#4122](max-sixty/worktrunk#4122), thanks @zach-hammad-vs for reporting) - **A deprecated config section the migration can't rewrite now warns**: `select = "not a table"`, or a `[select]` whose `[switch.picker]` destination is already set, was ignored without a message. It now reports `unknown field select (will be ignored)`. ([#4121](max-sixty/worktrunk#4121), thanks @zach-hammad-vs for reporting) - **`wt config update` no longer changes what a template renders**: it could rename `{{ repo_root }}` inside a quoted s See merge request: Harmonybrew/homebrew-core!20435
Implements #2984, extended per @max-sixty's ask on this PR — since these have been deprecated for a while, remove them rather than keep supplying them.
What changed
No renderer supplies a deprecated template variable any more. All five are gone from the code that builds template contexts:
repo_rootrepo_pathworktreeworktree_pathmain_worktreerepomain_worktree_pathprimary_worktree_pathcommitscommit_detailsbuild_promptpasses onlycommit_details, to the squash template and to the user/project append fragments;build_hook_contextinserts only the current names, and itsprimary_worktree_pathscope gate no longer has a second name to check;UserConfig::format_pathsuppliesrepoalone;vars_available_inno longer appendsDEPRECATED_TEMPLATE_VARS, so that constant is gone and the available-variables list every undefined-variable error prints now carries one name per value. None of the five appear in the docs or in--help, so nothing there moves. Two code sites that still named a retired variable are gone too: the bare-repoworktree-pathoffer'stemplate_references_repo_nameno longer ORs inmain_worktree(the template it reads is already migrated), andwt config show-theme's shell-highlighting sample no longer printscp {{ repo_root }}/target {{ worktree }}/target.What stays, and why
The config-file rename.
src/config/deprecation.rscarried two template-variable tables —DEPRECATED_VARS, rewritten only bywt config updatebecause the old names still resolved at runtime, andRETIRED_VARS, rewritten on every load. Nothing resolves at runtime now, so the distinction has nothing left to encode: one table, oneStructuralrule, all five renamed before serde parses. Detection was already a single shared predicate, so the warning text and whatwt config updatewrites are both unchanged.That rewrite is what keeps existing configs working, and it can't come out with the rest, because the failure it would expose isn't uniform. A hook, alias, or
worktree-pathtemplate fails itsSemiStrictexpansion with an undefined-variable error naming the variable — loud, and fixable from the message. A squash template renders under minijinja'sLenientdefault, which iterates an undefined value as an empty sequence, so it would silently produce a prompt with no commit list: the outcome #2984 opens by calling out. The existing end-to-end snapshot is the evidence that the rewrite carries the compatibility rather than an assertion that it does —test_step_squash_show_prompt_deprecated_commits_warnsrenderssquash-template = "Squashing {{ commits | length }} commits from {{ branch }}", and its snapshot is byte-identical on this branch (sameSquashing 2 commits from feature, same warning pair) with nothing supplyingcommits.What this does break
A retired name typed on the command line rather than stored in config —
wt switch --execute 'code {{ worktree }}', awt step for-eachbody — now fails with an undefined-variable error listing the current names. Config files migrate; a shell alias doesn't, so this is the loud half of the removal.--config-setfragments andWORKTRUNK_*env overlays both run through the same load-path migration, so they keep working.The other break is quiet, and it's the one worth a decision.
--varforce-binds a name whether or not a template references it, sowt hook pre-start --var main_worktree=/custom/pathagainst a config saying{{ main_worktree }}used to render/custom/path. The load rewrite turns that template into{{ repo }}, the override binds a name nothing reads, and the hook runs with the real repo name instead — no error. The config deprecation warning still fires on the template, so it isn't unsignalled, buttest_var_flag_deprecated_alias_workswas the only coverage and this PR deletes it.Moving the four into the load-path rewrite also means an unrelated config mutation materializes their rename, since
with_locked_mutationreloads throughmigrate_contentand then diffs against the file. That part is intended. What rides along with it is not:save_to's diff replaces the wholetoml_edititem for the changed line, so the line's inline comment is deleted as a side effect of a command that had nothing to do with it.test_saving_config_mutation_preserves_toml_commentscatches exactly that, and it currently passes only because its fixture was changed to a current variable name — so the suite no longer exercises a mutation against an unmigrated config. Eithermerge_tablesshould carry the existing value's decor across the replacement, or the fixture should keep the retired name and assert that the comment goes; this needs a call before merge.Tests
test_retired_vars_migrate_on_load_and_on_updatereplaces the old load-vs-update split test: both passes rewrite all five and leave no retired name behind, and detection reports the same pairs either way.test_warning_fires_iff_update_changesgains the remaining four asrewrittenentries, plus two near-missuntouchedentries. The near-misses matter more now that the rule runs on every load rather than on request:{{ worktree_path }}and{{ primary_worktree_path }}both contain the retiredworktree, and a substring match would mangle a live variable in every user's config on every command.recent_commits(added earlier in this PR) covers the same boundary forcommits, andmain_worktree_pathsits inrewrittenbecause it is the near-miss ofmain_worktreeand has to reach its own replacement.test_validate_template_validnow pins that a retired name is rejected in hook scope, where it previously pinned that it was accepted in every scope.test_var_flag_deprecated_alias_worksis deleted — its subject was the alias;test_var_flag_overrides_builtin_variablealready covers--varagainst a current name.-vdiagnostic shows the migratedworktree-pathsource.Validation
cargo test --lib --all-features— 1527 pass.cargo test --test integration— the failure set is identical to the same run on this branch's parent, except thatconfig_show::test_deprecated_template_variables_verbose_shows_contentis now fixed by the regenerated snapshot; the ~60 that fail in both are sandbox artifacts (a realnuon the runner's shell-detection path, and a umask/socket(AF_UNIX)difference understep_copy_ignored).pre-commit run --all-filespasses: fmt, clippy, typos, and the repo's custom hooks.Two gates can't run in the tend sandbox and are left to CI: the pre-merge hook's
instastep (cargo-insta/cargo-nextestresolve only inside the runner home, so--unreferenced rejectgoes unrun — the inline snapshot inuser_hooks.rswas hand-edited for the same reason), andcopy::tests::test_copy_dir_recursive_does_not_count_a_non_regular_file, which fails atUnixListener::bindwithPermissionDeniedbecause the sandbox blockssocket(AF_UNIX, …).