Repository navigation
Conversation
…follow them Anthropic's plugin directory refuses a hook command whose path the shell computes or that carries an inline program, which blocked submitting plugins/worktrunk. Each Claude hook now runs one script under hooks/ by a literal $CLAUDE_PLUGIN_ROOT path; the scripts keep the old commands' behavior and the #2939, #3545, #3754, and #3921 guards, now pinned against the script text. Also fills in the listing metadata the directory reads (license, homepage, repository, keywords, icon), discloses in the plugin README what each hook runs, and pins the hook scripts to LF so a CRLF checkout can't drop pipefail. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The plugin directory scanner reads `$PWD` in the bundled skill reference as a credential read and holds the plugin for review. direnv's own `expand_path` resolves the path the same way, relative to the .envrc. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
One hidden subcommand reads Claude Code's hook payload and acts on its event: activity markers, the EnterWorktree approval, and WorktreeCreate / WorktreeRemove. Moving the plugin's hooks.json onto it leaves each hook command a literal path, which Anthropic's plugin directory requires, and drops the jq dependency. hooks.json keeps its current commands here: the marketplace serves the plugin from main, so switching it before a release ships `hook` would break worktree creation for every installed wt. The switch follows the next release. `approve-enter-worktree` stays for plugin copies installed before `hook`, since marketplace installs don't update on their own. Also fills in the plugin listing metadata (license, homepage, repository, keywords, icon) and documents in the plugin README what each hook runs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
codecov/patch fails on this head. Six of its seven missed lines are the PermissionRequest arm of handle_claude_hook plus the no-path early return in approves_enter_worktree. The existing PermissionRequest test in config_show.rs runs the command out of hooks.json, which still calls approve-enter-worktree. Nothing exercises the hook arm, and that arm has its own logic: unwrap_or(false) in place of ?, and setting the marker in-process where the old command relied on ||. #4305 would cover it indirectly once it switches hooks.json, but this PR lands first. The suggested test covers the allow path, a non-EnterWorktree decline, and an EnterWorktree without a path. It passes locally and is rustfmt-clean.
That leaves one miss, the current_dir() fallback used when CLAUDE_PROJECT_DIR is unset. run_hook always sets that variable, so covering the fallback would need an env_remove variant of the helper.
I dismissed my earlier approval until coverage is addressed, since AGENTS.md requires explicit approval before merging with codecov/patch red. I can push this test if you'd like.
codecov/patch failed — the PermissionRequest arm of the new hook is untested
…lback Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… hook` (#4305) Routes all eight Claude Code hook events through the existing Rust dispatcher added in #4304. Hook commands become literal invocations that pass the plugin directory validator, and the plugin no longer requires `jq`. The README requires `wt` v0.81.0 or later. On `wt` v0.80.0 or earlier, worktree creation and removal fail, and activity markers and EnterWorktree auto-approval stop working. The latter hooks retain `|| true`, so the failures stay nonblocking and EnterWorktree falls back to a permission prompt. The dispatcher preserves existing-branch reopening and safe removal of unmerged work. Updates the hook layout assertions and the skill's create-or-reopen guidance, and removes the obsolete shell pipeline explanation. Local validation: the project gate passed for the corrected skills at `1a9ebd12c` in an isolated target directory (5,392 tests passed, one skipped, plus Clippy, formatting, docs, and snapshots). Docs mirror sync and all five dispatcher integration tests pass. The later documentation-only follow-ups clarify the README's attribution of payload parsing and the measured cleanup behavior. `claude plugin validate plugins/worktrunk` passed its directory checks with the existing missing-version warning; it excludes the catalog's safety scan and policy review. Independent Opus 5.5 review found no code defects and verified the older-version failure. Further passes reviewed the corrected skills, mirrors and live cleanup evidence with no remaining findings. Cleanup was verified live on Claude Code 2.1.308 in an isolated repository: reopening an existing worktree through both `claude --worktree` and `EnterWorktree({name})`, then `/exit`, shows Keep / Remove with Keep selected. Keep leaves its branch and checkout intact and emits no `WorktreeRemove`. A fresh CLI-created worktree shows the same prompt; choosing Remove emits `WorktreeRemove` and removes the synthetic checkout and merged branch. The rationale now reflects that confirmation instead of claiming automatic cleanup. Reopening is already present in the [base create hook](https://github.com/max-sixty/worktrunk/blob/d965d819f226ad7ac853efed8b2a996bb0c880a6/plugins/worktrunk/hooks/hooks.json#L72): it clears `--create` for an existing local branch. Both the [base remove hook](https://github.com/max-sixty/worktrunk/blob/d965d819f226ad7ac853efed8b2a996bb0c880a6/plugins/worktrunk/hooks/hooks.json#L82) and the dispatcher check for `.git` and invoke `wt -C <path> remove --foreground <path>`, with no force flags. This cutover preserves that deletion scope and its safeguards. > _This was written by Codex on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Adds a hidden
wt config plugins claude hooksubcommand that reads Claude Code's hook payload from stdin and acts on itshook_event_name: activity markers, theEnterWorktreeapproval, andWorktreeCreate/WorktreeRemove. This is the first half of getting the Claude Code plugin into Anthropic's plugin directory, whose validator blocks our currenthooks/hooks.jsonbecause its commands compute paths (-C "$CLAUDE_PROJECT_DIR") and carry inline programs (bash -c '…$(jq …)…'). Oncehooks.jsonruns this subcommand, every hook command is the same literal line and the plugin no longer needsjq.hooks.jsonitself is unchanged here. The marketplace serves the plugin frommain, so switching it before a release shipshookwould break worktree creation for everyone on v0.79. The switch is a separate draft PR, to merge a few weeks after the release that ships this.src/commands/config/plugins.rs:handle_claude_hookdispatches on the event and re-runs the samewtbinary with the command a user would type, so each action behaves exactly as the old hook command did. Its doc comment carries the per-event contracts (Claude plugin WorktreeRemove hook useswt remove -D, force-deleting unmerged branches on session exit #2939, Claude plugin WorktreeCreate hook: missing pipefail swallows wt failures ("hook succeeded but returned no worktree path") #3545, fix(plugin): resolve WorktreeRemove against the worktree path, not the project dir #3754, Plugin marker hooks follow the shell's cwd, so acdmid-session marks the wrong repository #3921).approve-enter-worktreestays, sharing its check withhook, for plugin copies installed beforehookexisted: marketplace installs don't update on their own.tests/integration_tests/claude_hook.rscovers the new subcommand directly; the existing shell-integration tests still run the realhooks.jsoncommands.plugin.jsongains the listing metadata the directory reads (license,homepage,repository,keywords,icon, withicon.pngcopied fromdocs/public/logo.png), and the plugin README describes what each hook runs, which the directory's security scan checks for.expand_pathinstead of$PWD, which the directory scanner read as a credential.