Repository navigation
Name the unconfigured source when a hook filter matches nothing - #3997
Conversation
…ilter #11: `wt hook pre-merge user:` in a repo whose hooks all live in project config failed with `No command named user: (hook has no named commands)` — the miss was routed through the misspelled-name error even though `user:` names no command at all. A bare source filter asks for every hook from one source, so a miss means that source configures no hooks of this hook type. That is a different failure with a different fix, so it gets its own error: ✗ No user pre-merge hooks configured ↳ To run the project hooks, run wt hook pre-merge project: The hint appears only when the other source has hooks of this type to run. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…, and the vars preview #57: `wt hook show --help` advertised `❓ = needs approval`; the binary prints `❯ … (requires approval)`. Quote the marker it actually uses. `--no-hooks` was listed twice as though `wt hook` took it — the two mentions collapse into one that names the commands that do accept it (`wt switch`, `wt merge`, `wt remove`, `wt step commit`, `wt step squash`). The `pre-commit` row claimed it only fires during `wt merge`'s squash; it runs before any Worktrunk commit. `--foreground` — the answer to "how do I watch a post-hook run" — was absent from the page; it now sits with the background/logging sentence. #39: the page's two `worktree-path` recipes were byte-identical to the config page's, which also name the resulting path. Cut them and link `/config/#worktree-path-template`; the filter table and the `hash_port` hook example stay. #61: the preview note undersold what a `vars` expression loses — `{{ vars.thing | default('none') }}` previews as `{{ vars.thing }}`, filter chain and all. Say the whole expression is left as a bare placeholder. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…, and prune's branches #60: `wt step copy-ignored`'s `--from`/`--to` appeared only in the generated flag list, though the command's own summary is "Copy gitignored files to another worktree" — a "Choosing source and destination" section now covers copying between two named worktrees. `--from`'s help said "Defaults to main worktree" while the code uses `primary_worktree()`. `wt step commit --branch` was undocumented while `wt step diff` gives its equivalent a whole section; it gets the parallel one. Neither the commit nor the squash guide said hooks fire, or that a missing `[commit.generation]` falls back to a message built from the change rather than failing. #61: the `wt step eval -v` example showed two of the fifteen variables the real block prints — it now says so and elides the rest. The enum ordering comment called eval, for-each and prune experimental; only the three marked `[experimental]` are. `step prune`'s one-liner and its min-age sentence both said "worktrees" where branch-only rows are candidates and are age-guarded too — they now match the Operations wording. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
worktrunk-bot
left a comment
There was a problem hiding this comment.
One inaccuracy in the new vars-preview paragraph, plus a minor note on the multi-filter error path.
Everything else checks out against the code. I verified wt hook <type> --foreground, the --no-hooks command list (exactly the four HookFlags flatten sites plus wt merge's own declaration — and wt hook really doesn't take it), the ❯ marker in hook_commands.rs, copy-ignored's primary_worktree() default and require_worktree on both endpoints, prune's min-age guard reaching branch-only candidates via CheckSource::Orphan → orphan_branch_age, both fallback commit-message shapes in llm.rs, the /config/#worktree-path-template anchor and that both recipes live under it, and the abridged wt step eval -v block (cwd really is the last variable in scope). test_docs_are_in_sync and the four new user_hooks tests pass locally.
Mixed filters in no_matching_commands_error — the new branch takes the first bare-source filter it finds, so a list mixing one with a named miss reports only the bare one:
$ wt hook pre-merge user: project:nope # project configures `demo`, user configures nothing
✗ No user pre-merge hooks configured
↳ To run the project hooks, run wt hook pre-merge project:project:nope is never mentioned, and the hint offers an invocation the user didn't ask for. Gating the new branch on parsed_filters.iter().all(|f| f.name.is_empty()) would fall through to HookCommandNotFound in that case. Exotic input — worth what you think it's worth.
`GitError` is reached as `worktrunk::git::GitError` in this file and never imported, so the two intra-doc links had no item to resolve against. Plain `cargo doc` passes them; the `-Dwarnings` gate does not. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
… error
The new paragraph claimed a preview reduces any `vars` expression to a bare
placeholder, filter chain and all. It doesn't: `LiteralVars` is a defined
object, so only a filter that passes a defined value straight through —
`default`, the documented idiom — drops out. One that transforms its input
still runs, against the placeholder's rendered text, and
`{{ vars.thing | upper }}` previews as `{{ VARS.THING }}`, which is not a
reference anyone can paste back. Retiring drifted claims is the point of this
branch, so it shouldn't add one.
`HookSourceNotConfigured` also took the first bare source filter out of a mixed
list, so `wt hook pre-merge user: project:nope` reported the unconfigured
source and never mentioned `nope`, offering an invocation the user hadn't asked
for. It now fires only when every filter is a bare source; a list that names a
command falls through to `HookCommandNotFound`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
worktrunk-bot
left a comment
There was a problem hiding this comment.
Both earlier findings are applied and check out: I rebuilt the branch and reproduced echo {{ vars.thing }} / '{{ VARS.OTHER }}' / 0 for the preview paragraph, and the mixed-filter gate now behaves as described — wt hook pre-merge user: project:nope gives No command named user:, project:nope (available: project:demo), while a list of only bare sources still gets HookSourceNotConfigured.
One inaccuracy left, in the new wt step commit --branch section — the same drift class the rest of the PR is retiring.
--branch does not re-root --dry-run — step_commit returns into preview_commit before it ever reads branch:
if show_prompt || dry_run {
preview_commit(stage, dry_run, yes)?;
return Ok(None);
}and preview_commit builds its env with CommandEnv::for_action(...), never for_selector. There is no conflicts_with between the two args, so the flag is silently ignored rather than rejected. Against a build of this branch, from main with a feature worktree checked out:
$ wt step commit --branch feature --show-prompt
...
<context>
Branch: main--show-prompt is hidden, but it shares the identical early return, so --dry-run previews the current worktree too. The inline suggestion scopes the sentence; the alternative is to make it true instead — conflicts_with = "dry_run" on branch would turn the silent no-op into an error, at the cost of a new rejected flag combination. Your call which one the section should describe.
Minor, and only if you think it's worth a fourth case: nothing pins the mixed-filter fall-through the last commit added. Deleting the all_bare line passes the whole suite — a snapshot alongside the three new ones, on ["pre-merge", "user:", "project:nope", "--yes"], would hold it.
Everything else in this push verified against the code: the pre-commit claim (commands/commit.rs, step/squash.rs, and merge.rs's will_create_commit gate all push PreCommit), --branch re-rooting staging/hooks/commit on the real commit path, both [commit.generation] fallback shapes (Changes to {} and Squash commits from {} in llm.rs), the StepCommand enum order against the reordering comment, and the three new snapshots' error/hint shapes.
`all_bare` already guarantees every filter's name is empty, so the match's `_ => None` arm couldn't be taken — it existed only to make the match exhaustive. Selecting on `f.source` says the same thing without it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
`--branch` re-roots the real commit path but not the preview: `step_commit` returns into `preview_commit` before it reads `branch`, and `preview_commit` builds its env with `for_action`. With no `conflicts_with` between the args the flag is silently ignored, so the section shouldn't say it re-roots the whole command without qualification — that is the drift class this branch is retiring. Also add the fourth snapshot the mixed-filter fall-through was missing; deleting the `all_bare` line passed the whole suite before it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
| /// The mirror of the above: `project:` against a repo whose hooks are all in | ||
| /// user config. |
There was a problem hiding this comment.
"The mirror of the above" pointed at test_hook_bare_source_filter_reports_unconfigured_source when both tests landed together; the new mixed-filter test now sits between them, so "the above" names a test this one isn't a mirror of. Naming it directly survives the next insertion:
| /// The mirror of the above: `project:` against a repo whose hooks are all in | |
| /// user config. | |
| /// The mirror of `test_hook_bare_source_filter_reports_unconfigured_source`: | |
| /// `project:` against a repo whose hooks are all in user config. |
Seven conflicts, all from #3997 editing the same hook and step help text. Took main's for six: the `vars`-preview paragraph (main's is the corrected one — a filter that transforms its input still runs against the placeholder, which this branch's wording denied), the `codename` recipe pointer, the `StepCommand` ordering comment, the `wt step eval -v` lead and sample block (main's names it abridged and uses the settled myproject / feature-auth names), and the `--min-age` flag description, which is read standalone in `--help` where "candidates" has no antecedent. Kept this branch's min-age prose, which carries both facts main's does plus where each kind of candidate gets its age from. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
#3997 landed "It has no effect on `--dry-run`, which always previews the current worktree" — true of main at the time, and false once this branch makes `preview_commit` resolve `--branch` through the same `resolve_env` the real commit path uses. Verified against a build of this branch: from the source worktree, `wt step commit --branch feature --dry-run` renders the feature worktree's diff and reports `Branch: feature`, leaving both worktrees untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb
worktrunk 0.77.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 - **`wt list` sizes and aligns its columns to the terminal width**: one long branch name no longer sizes the Branch column for every row — it caps at 32 characters and elides, so a narrow terminal keeps its other columns instead of degenerating into a branch list. `Remote⇅` stops holding blank space open in a repo with no remote, and alignment now follows the value type. `--format=json` still carries the whole name. ([#3998](max-sixty/worktrunk#3998)) - **`wt list` names what it hid and marks detached worktrees**: the summary reads `hidden: Path, Commit` instead of counting columns, a detached worktree shows `⊘` rather than borrowing `⚑`, and a prunable row leaves its cells blank instead of showing loading dots that never resolve. ([#3998](max-sixty/worktrunk#3998)) - **`wt list --format=json` gains a `marker` field and stops reporting `detached` twice**: the branch marker set by `wt config state marker` is now readable without parsing it out of `symbols`, and `state` no longer reports a detached worktree as `branch_worktree_mismatch` — the sibling `detached` boolean carries it. ([#3998](max-sixty/worktrunk#3998)) - **`wt list --format=json` now defaults to schema 2**: callers get the envelope with repository metadata and orthogonal per-item facts without configuring `[list] json-schema`. `wt list statusline --format=json` follows the same key. Set `json-schema = 1` to retain the original bare-array format. (Breaking.) ([#4038](max-sixty/worktrunk#4038)) - **`wt config show` fails on a broken config**: it exits 1 on an unreadable or invalid config, an invalid `[list] columns`, or an invalid `approvals.toml`. Unknown keys and deprecations stay warnings and still exit 0. A new `APPROVALS` section counts project commands awaiting approval. (Breaking: it always exited 0 before.) ([#3999](max-sixty/worktrunk#3999)) - **Config migration output names its destination**: `wt config update --output <path>` writes the migration artifact to that file instead of applying it in place, and `--output=-` writes it to stdout. Output mode includes project config when run from a linked worktree. (Breaking: `--print` was removed.) ([#4021](max-sixty/worktrunk#4021)) - **Pi joins the agent integrations**: `wt config plugins pi install` writes an activity hook to `~/.omp/agent/hooks/pre/worktrunk.ts`, so Pi sessions show 🤖/💬 markers in `wt list` like Claude Code, Codex, OpenCode, and Gemini. `$PI_CONFIG_DIR`, `$PI_CODING_AGENT_DIR`, and named `$OMP_PROFILE`/`$PI_PROFILE` profiles are honored. [Docs](https://worktrunk.dev/claude-code/) ([#3594](max-sixty/worktrunk#3594), thanks @adity982, and @ortonomy for the request) - **`wt config plugins codex install` installs the plugin too**: it previously registered the marketplace and left you to run `/plugins` in Codex yourself. Uninstall follows for both Codex and Claude Code, removing the plugin and then the marketplace, so the two commands are inverses. (Breaking: Codex uninstall previously left an installed plugin alone; Claude uninstall now also removes the marketplace.) ([#4019](max-sixty/worktrunk#4019)) - **`wt step copy-ignored` says whether it reflinked or copied**: the summary now reads `(reflinked, no extra disk)`, `(full copy)`, or a partial count, so the same `29.5 GB` line distinguishes a free copy from one that actually wrote the bytes. `--format=json` gains `reflinked` and `written`; a `--dry-run` plan no longer reports `files`/`bytes`. ([#4025](max-sixty/worktrunk#4025)) - **`wt config update` removes keys its destination cannot hold**: migrating `[select]` or `[commit-generation]` drops keys the new section has no field for, reporting each one. Otherwise the key landed at a path the user never typed and warned on every command, with no way to clear it. ([#3994](max-sixty/worktrunk#3994)) ### Fixed - **A failed `wt switch pr:<n>` against a fork no longer deletes a branch it didn't create**: the rollback force-deleted the branch on any setup error, including the one case where the branch wasn't its own — a `pre-switch` hook or a concurrent session claiming the name in the window after the forge answered. Branch and worktree are now created in one `git worktree add -b`, which writes nothing when the name is taken. ([#3984](max-sixty/worktrunk#3984)) - **Codex on Windows: the activity hooks no longer fail on every event**: each hook led with a bare `bash`, which `cmd.exe` resolves to the WSL launcher rather than Git Bash, so every event raised a `Hook failed` banner. Hooks now run `wt.sh` through a shim that finds Git Bash by path. ([#4008](max-sixty/worktrunk#4008), fixes [#4007](max-sixty/worktrunk#4007), thanks @McNultyyy for reporting and diagnosing) - **Templates leave `branch` unset in a detached worktree**: aliases and hooks rendered `{{ branch }}` as the literal `HEAD`, which git resolves, so an unguarded template ran against the wrong ref — the reported case ended in `git push origin --delete HEAD`, which git refused. `base` and `target` follow. (Breaking: an unguarded `{{ branch }}` now errors.) ([#4010](max-sixty/worktrunk#4010), fixes [#4009](max-sixty/worktrunk#4009)) - **The OpenCode plugin loads under OpenCode 2**: OpenCode 2's loader dropped the old bare-function export silently, so activity markers stopped appearing. The plugin now exports one object carrying both the v2 `setup` and v1 `server` entry points, and spawns `wt` through `node:child_process` rather than the Bun shell. Re-run `wt config plugins opencode install` to pick it up; the one file covers OpenCode 2 and OpenCode 1.16 or later. ([#4018](max-sixty/worktrunk#4018), thanks @pragmaticivan for the request) - **`wt step commit --branch` builds its prompt from the worktree being committed**: prompt-building git plumbing ran in the invoking worktree, so with nothing staged there the generated message described none of the changes it committed. `wt step relocate --commit` had the same bug, and `--dry-run`/`--show-prompt` now preview the worktree `--branch` names. ([#3996](max-sixty/worktrunk#3996)) - **LLM commit messages keep diffs for quoted paths**: a file whose name git quotes in the `diff --git` header — any non-ASCII name under the default `core.quotePath` — had its whole diff section dropped from the prompt once the diff exceeded the 100 KB budget. ([#4041](max-sixty/worktrunk#4041)) - **An unparsable user config is reported, not a panic**: `wt config show --format=json` and `--full`, plus `wt step prune`, `relocate`, `eval`, and `for-each`, panicked on a debug build and printed a bare `✗ Command failed` on a release one. They now report `✗ Failed to load config` with the parser's caret diagram. ([#4002](max-sixty/worktrunk#4002)) - **`wt switch --execute` names the directory the program actually starts in**: the `Executing (--execute) @ …` header rendered the worktree the background hooks run in, not the program's own directory — which differs under `--no-cd` or a switch from a subdirectory. The path is omitted when the shell already stands there. ([#4043](max-sixty/worktrunk#4043), fixes [#4042](max-sixty/worktrunk#4042), thanks @yajo for reporting) - **`wt config plugins claude|codex uninstall` is safe to re-run**: removing an already-absent marketplace reported a failure, and a Claude uninstall that removed the plugin and then failed left the marketplace with no way to clear it. Both now finish a half-done uninstall and succeed when there is nothing left to remove. ([#4033](max-sixty/worktrunk#4033), [#4034](max-sixty/worktrunk#4034)) - **`wt config state marker` set and clear no-op outside a git repository**: they exited 1 with a git error, so an agent plugin running outside a repository printed one every turn (the hook's `|| true` kept the session going). ([#3981](max-sixty/worktrunk#3981), thanks @mahirhir) - **`wt list` produces output in a bare repo with no worktrees**: it printed nothing at all and exited 0. It now reports `○ No worktrees` with a hint, `--branches` lists the branches, and `--format json` emits the envelope with an empty `items`. ([#3992](max-sixty/worktrunk#3992)) - **`wt list` warns when it can't parse the project config** rather than ignoring it silently; the listing still succeeds. ([#3993](max-sixty/worktrunk#3993)) - **Relayed command output no longer prints ahead of the delayed-stream progress line**, and delayed-stream output routes through anstream so color is stripped consistently when redirected. ([#4037](max-sixty/worktrunk#4037), [#3995](max-sixty/worktrunk#3995)) - **A hook filter that matches nothing names the unconfigured source**, rather than reporting no match without saying which source was empty. ([#3997](max-sixty/worktrunk#3997)) ### Documentation - **`wt hook` says that `post-*` hooks from the two sources run concurrently**, so dependent commands belong in one source; `wt merge` records that `post-commit` can't run when the merge removes the worktree it anchors on. ([#4020](max-sixty/worktrunk#4020), [#4026](max-sixty/worktrunk#4026)) - **`wt step` help pages describe what the commands actually do**: `wt step prune` says it removes br See merge request: Harmonybrew/homebrew-core!18763
A source filter with no command name (
wt hook pre-merge user:) asks for every hook from one source. When that source configured none, it fell through toHookCommandNotFoundand reportedNo command named user: (hook has no named commands)— a message about a name the user never gave, offering a fix that doesn't apply.That case now gets its own error, which says what is actually true and points at the source that does have hooks:
The hint appears only when the other source has hooks of this type; with neither configured, the error stands alone.
HookCommandNotFoundkeeps the naming case, where correcting the name is the fix.The rest is corrections to the hook and step reference pages, all of them claims that had drifted from the code:
Hook page
post-*hooks:wt hook <type> --foregroundruns one inline, which the page didn't mention.pre-commitran "duringwt mergebefore the squash commit". It runs before any Worktrunk commit —wt step commit,wt step squash, and the onewt mergemakes.--no-hooksis accepted by the commands that run hooks (wt switch,wt merge,wt remove,wt step commit,wt step squash), not bywt hook. The page said it twice and was wrong the second time.varsexpression alone, filter chain included:{{ vars.thing | default('none') }}previews as{{ vars.thing }}. The page described only the bare variable.wt hook showmarks project commands needing approval with❯, not❓.worktree-pathrecipes are dropped in favor of a link to theworktree-pathtemplate section in the config page, which already carries both.Step page
wt step commit --branch <b>was undocumented; the page now says it re-roots staging, hooks, and the commit into that worktree.wt step commitandwt step squash, which the page didn't say.[commit.generation]command the commit still happens, with a message built from the staged file names.wt step copy-ignored's endpoints:--from/--toname either end by branch, so a copy can run between two named worktrees from anywhere.--from's default is the primary worktree, not the "main worktree".wt step pruneremoves branches as well as worktrees, and--min-ageguards both. The summary and the min-age section both said worktrees only.wt step squashwithout a[commit.generation]command still squashes, listing the squashed subjects.wt step eval -vsample block is marked abridged; the real one prints every variable in scope.StepCommandordering comment called the tail "experimentals"; not all of them are.UX survey items:
#11,#57,#39,#61,#60.Reviewable files:
src/commands/hooks.rs,src/git/error.rs,src/cli/mod.rs(hook section),src/cli/step.rs,src/cli/hook.rs,tests/integration_tests/user_hooks.rs. Generated mirrors and snapshots are regenerated.🤖 Generated with Claude Code
https://claude.ai/code/session_01XAUYWFN9d9oh6jyoQiouHb