mirror of
https://github.com/max-sixty/worktrunk.git
synced 2026-12-03 01:46:01 +08:00
main
257
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3927e13ec2 |
docs: fix stale ^…± type comment, statusline command name, and relative WORKTRUNK_BIN example (#4972)
Three documentation claims no longer match the code; each is a one-line correction. - **`plugins/worktrunk/types/index.d.ts`**: `Row.committed` (`^…±`) was documented as "committed changes since the merge base". Since #4931 the field (filled from v2 JSON `default_branch.diff`) measures what merging into the default branch would add, falling back to the merge-base diff only when the merge would conflict. The two differ most for squash-merged branches, where the merge measure is ~0. - **`.config/clawpatch/features/feat_custom_performance.json`**: named a nonexistent `wt statusline` command running "on every shell prompt". The command is `wt list statusline`; the summary now describes it as used by asynchronous statuslines such as Claude Code and tmux, without claiming a per-redraw frequency. - **Shell integration troubleshooting** (`docs/src/content/docs/shell-integration.md`, plus the two generated skill mirrors): the dev-build example `export WORKTRUNK_BIN=./target/debug/wt` breaks after the first `wt switch`, because no wrapper resolves the path and it is looked up relative to the new worktree. Reproduced with the rendered fish wrapper: after the `cd`, the next call failed with `env: './fakewt': No such file or directory` (exit 127). The example now uses `"$PWD/target/debug/wt"`. `cargo test --test integration test_docs_are_in_sync` passes with the regenerated mirrors. No regression test: these are documentation-only changes. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
abef689c3d |
docs(list): make wt list --help a usable symbol legend (#4936)
Since #4858, the `wt list` footer explains a few visible status symbols and points to `wt list --help` for the rest, so the help now serves as the legend. It read poorly as one: at 100 columns the status symbols started at line 197 of 620, every symbol row carried a JSON column that split words mid-token at 60 columns, and three statements contradicted the code. This rewrites the legend as two-column tables and moves it up beside Gutter, corrects those three claims (`✗` counts tracked uncommitted changes without `--full`; a CI or Summary column named in `[list] columns` shows without `--full`; the summary model need not be off-machine), drops the CI table's Value column of schema-1 strings, and cuts a repeated paragraph, a repeated example and a link that pointed nowhere in the terminal. The JSON example now prints as indented JSON, the way `wt list --format=json` does, after the jq examples. The help goes to 576 lines, with the legend at line 134. To weigh: the schema-1 migration table is cut. `json-schema = 1` still works, and `wt config update` in v0.67 pinned it into some configs, so one sentence keeps it discoverable and links the table as of v0.83.0. The JSON field reference stays in the terminal. The footer now calls `^` the "primary worktree", since bare repos have no main worktree; that changes about 130 list snapshots, and two of them lose a second footer explanation to the longer label. Max asked for a review of `wt list --help` and picked these changes. Tests: pre-merge gate, with help, list and docs-sync snapshots regenerated. > _This was written by Claude Code on behalf of max-sixty_ |
||
|
|
64093ed192 |
Add Antigravity Marketplace README for worktrunk plugin (#4949)
Adds `plugins/worktrunk/.antigravity-plugin/README.md` so the Antigravity Marketplace detail page displays Antigravity-specific documentation instead of `plugins/worktrunk/README.md` (which documents Claude Code's `/wt-switch-create`, `WorktreeCreate`, and `EnterWorktree` hooks), and guards its presence in `test_plugin_layout_is_consolidated`. Per [Build plugins](https://antigravity.google/docs/build-plugins#directory-structure), Antigravity reads `.antigravity-plugin/README.md` for Marketplace pre-install documentation without affecting Claude Code's root `README.md`. Verified with `agy plugin validate --json plugins/worktrunk`, `test_plugin_layout_is_consolidated`, and `pre-commit run --all-files`. > _This was written by Antigravity on behalf of max-sixty_ |
||
|
|
6b33b2c8b3 |
Remove Gemini CLI extension and simplify Antigravity install URL (#4948)
Removes the Gemini CLI extension (`gemini-extension.json`, root `hooks/hooks.json`, `GEMINI CLI` detection in `wt config show`, its test helpers/snapshots, and its docs/Nix entries) and simplifies `wt config plugins antigravity install` and docs to install directly from `https://github.com/max-sixty/worktrunk`. Google moved consumer, Pro/Ultra, and Gemini 4+ users from Gemini CLI to Antigravity in June 2026, keeping Gemini CLI only for Enterprise Code Assist. Keeping `gemini-extension.json` at the repo root broke `agy plugin install https://github.com/max-sixty/worktrunk` — Antigravity saw the Gemini manifest first, copied the entire Rust repository into `~/.gemini/config/plugins/worktrunk/`, and imported dead Gemini hook events. Without `gemini-extension.json`, `agy plugin install https://github.com/max-sixty/worktrunk` auto-discovers `plugins/`, skips the Codex-only `plugins/worktrunk-markers`, and installs `plugins/worktrunk/` natively with its `.antigravity-plugin/plugin.json`, skills, and hooks. Requested by @max-sixty as follow-up to #4947. Verified with `agy plugin install .` in an isolated `HOME` (confirming bulk auto-discovery installs `worktrunk` cleanly), `pre-commit run --all-files`, `test_docs_are_in_sync`, and the integration test suite. > _This was written by Antigravity on behalf of max-sixty_ |
||
|
|
6aa9dc1e3c |
feat(list): measure ^…± as what merging into the default branch would add (#4931)
`^…±` now shows what merging the branch into the default branch would add. It diffs the default branch's tree against the tree `git merge-tree --write-tree <target> <branch>` produces, where it used to show the three-dot diff from the merge-base. JSON `default_branch.diff` (v2) and `main.diff` (v1) carry the same number. The integration probe already reduces this quantity to a yes/no answer, so a squash-merged branch marked `⊂` now shows `+0 -0`, not its full original diff. Implements the approach @max-sixty picked in #3842. On a clone of this repo with 16 branches, 4 of them squash-merged, the four `⊂` rows went from `+20`…`+80` to `+0 -0`, and the other 12 rows kept the same counts. A new integration test covers both kinds of row. Unit tests cover the cache read, the conflict fallback, an orphan branch and a sparse checkout. ## Disadvantages - **Conflicting merges keep the three-dot number.** A conflicting merge produces no tree to diff, so those rows fall back to the merge-base diff. `patch_id_match` rows are integrated *because* merge-tree conflicted, so a squash merge whose files the default branch changed again still shows its full count beside `⊂`. Orphans fall back the same way and stay empty. - **A diverged local/upstream default.** `⊂` checks both sides, but this column measures against the primary target only, the same base it used before. A branch integrated through the secondary side can still show a nonzero count. Measuring against both would need a rule for choosing one count. - **Ordinary branches can shift.** Where the default branch has since changed the same regions, the merged result differs from the branch's own diff by a few lines. The issue's table measured +3 to +35 lines. - **Naming and the preview pane.** The `…` in `^…±` comes from three-dot notation, and the picker's diff tab still shows the three-dot diff, so its stat line can differ from the column. I kept the header and left the pane unchanged, since both are visible-output decisions. - **JSON meaning changes without a schema bump.** The field descriptions in the schema and docs now say "Lines merging into the default branch would add/delete". Consumers that read it as the branch's own diff will see different numbers on integrated and overlapping branches. ## Performance I measured release builds of `main` and this branch on Linux, using a clone of this repo (5,662 commits) with 16 branches. Each figure is the median of 15 runs, repeated twice. | scenario | git subprocesses (old → new) | time (old → new) | |---|---|---| | cold `wt list --branches` | 101 → 101 (17 merge-tree, 34 diff-tree in both) | 80–82 ms → 80 ms | | warm | 11 → 11 | 31 ms → 31 ms | | first run after upgrade (old cache warm) | — → 45 (+17 merge-tree) | one run only; the next is back to 11 | | `[list] columns = ["branch", "branch-diff"]`, cold | 47 → 64 (+17 merge-tree) | 41 ms → 54 ms | - With the default columns, the `merge-tree` spawn is shared with the integration and conflict probes through the in-memory `merge_tree` map. The only change on a cold run is that a tree-to-tree diff replaces the three-dot diff. - A user who keeps `^…±` but drops Status now pays for one `merge-tree` per row, which `BranchDiff` didn't need before. - Warm runs spawn nothing extra. The result is cached under a new `merge-add-stats` kind keyed `(target, branch)`. Only the `LineDiff` is stored, never the merged tree, because nothing references that tree and `git gc` can prune it. - Sparse checkouts filter by the sparse pathspec and skip both caches, as the three-dot path does. - Existing `diff-stats` entries stay valid. They are still read for the conflict fallback; otherwise they go unused and age out through the LRU. ## Testing `cargo test --lib` and `cargo test --test integration` pass locally, apart from four tests that also fail on `main` in this sandbox: a FIFO copy test in each suite, the fsmonitor daemon test and the merge-signing test. The `--help` snapshots and generated docs are regenerated for the new column and field descriptions. Refs #3842. This leaves the conflict and diverged-target cases above open. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
ec5fc26d49 |
Add Antigravity plugin support (#4947)
Adds native Google Antigravity plugin support alongside the existing
Claude Code, Codex, and Gemini CLI integrations. Installing
`plugins/worktrunk/` now loads `.antigravity-plugin/plugin.json`,
`hooks.json`, and the mirrored `skills/` natively across Antigravity
App, CLI, and IDE instead of triggering Antigravity's broken
Gemini/Claude auto-conversions, and `wt config plugins antigravity
install|uninstall` plus `wt config show` detection wire it into the CLI.
Two details to weigh: the shared plugin icon moved from
`plugins/worktrunk/.claude-plugin/icon.png` to
`plugins/worktrunk/assets/icon.png` (updating the Claude and Codex
manifests to match) because Antigravity's Marketplace packager omits
dot-directories, and Antigravity has no `SessionEnd` or
worktree-lifecycle hook events, so activity markers rest at 💬 after a
session closes until another session runs or `wt config state marker
clear` is called. `wt config plugins antigravity hook` resolves the
target worktree from stdin `cwd` then `workspacePaths` (never the hook
process cwd, which is the plugin root). The Gemini CLI extension stays
in place for Enterprise Code Assist users.
Requested by @max-sixty. Verified with `agy plugin validate --json
plugins/worktrunk`, `claude plugin validate plugins/worktrunk`, live
`agy plugin install` and hook execution in an isolated `HOME`,
`pre-commit run --all-files`, and the Rust integration test suite
(including new end-to-end `hooks.json` and `config show` tests).
> _This was written by Antigravity on behalf of max-sixty_
|
||
|
|
e7b98db1dc |
docs(hook): say that declining or --no-hooks skips user hooks too, and that base is unset outside switch (#4934)
Corrects three places in the hook and merge help where the docs describe hooks more narrowly than the code runs them. The generated docs pages, skill references, JSON schema and help snapshots are regenerated from `src/cli/mod.rs` and `src/config/user/sections.rs`. No behavior changes. - **Declining approval.** The [approval section](https://github.com/max-sixty/worktrunk/blob/4321381664a73f90125916981ce1f310a0866d98/src/cli/mod.rs#L1684) said declining "skips every project command" for the operation. On a decline, each command continues with `ApprovedHookPlan::empty()`. That is [switch](https://github.com/max-sixty/worktrunk/blob/4321381664a73f90125916981ce1f310a0866d98/src/commands/worktree/switch.rs#L1787-L1797) and [merge](https://github.com/max-sixty/worktrunk/blob/4321381664a73f90125916981ce1f310a0866d98/src/commands/merge.rs#L344-L362), and remove, commit and squash print the same "continuing … without hooks". So a user's own `post-start` doesn't run either. The bullet now says every hook is skipped, user hooks included. - **`merge.verify`.** It was documented as "Run project hooks". [`approve_merge_plan`](https://github.com/max-sixty/worktrunk/blob/4321381664a73f90125916981ce1f310a0866d98/src/commands/merge.rs#L119-L123) returns an empty plan for `verify = false` / `--no-hooks` before it selects any hook, so user hooks are skipped too. The text now reads "Run hooks" in the help, the config example and the schema description. - **`base` outside switch/create.** The bare-vars table listed `base` as "= bare vars" for commit, merge and remove. [`hook_extras`](https://github.com/max-sixty/worktrunk/blob/4321381664a73f90125916981ce1f310a0866d98/src/config/expansion.rs#L323-L328) gives those hooks only `target` and `target_worktree_path`, so `{{ base }}` in a `pre-merge` hook is an undefined-variable error. The variable table just above already says `base` is "(switch/create only)". Those cells now read "unset". `test_docs_are_in_sync` and the `help` integration tests pass locally. Found by the nightly survey of `src/cli/mod.rs`. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
34b082db86 |
docs(llm-commits): replace the llm and aichat commit examples with Pi (#4885)
Removes the `llm` and `aichat` commit-generation examples and adds one
for Pi. Claude Code, Codex and OpenCode stay. Public configs use those
four agents far more than `llm` or `aichat`, and the docs still say that
any stdin-to-stdout command works.
The source of truth is `after_long_help` in `src/cli/mod.rs`. The config
docs, skill references, `dev/config.example.toml` and the two help
snapshots are regenerated from it, and the `Taskfile.yaml` benchmark
matches it. Other changes:
- **`llm-commits.md`**: Pi joins OpenCode under "Other tools". The
custom-template example now uses the documented Claude Code command
instead of `llm`.
- **Skill**: the tool check is now `which claude codex opencode pi`, in
both `SKILL.md` and `troubleshooting.md`.
- **Schema doc comments** (`src/config/user/{mod,sections}.rs` →
`user-config.json`): the `llm` examples become Claude Code and OpenCode
commands.
- **Plugin README**: lists Claude Code, Codex, OpenCode or Pi.
- **`wt switch` picker**: the "Summaries not configured" hint suggests
the documented Claude Code command instead of `llm -m haiku`.
The Pi command:
```toml
command = "pi -p --no-session --no-tools --no-extensions --no-skills --no-prompt-templates --no-context-files --model anthropic/claude-haiku-5-5 --thinking off"
```
Pi's CLI parser
([`args.ts`](https://github.com/earendil-works/pi/blob/2126569de40d5595dd3f41f7af126001f04c1de0/packages/coding-agent/src/cli/args.ts))
defines each of these flags. When stdin is piped, `main.ts` uses it as
the prompt and runs in print mode. Pi 1.7.0's published Anthropic
catalog lists `claude-haiku-5-5` and supports `--thinking off` for it.
`--no-extensions` also stops Worktrunk's own Pi activity extension from
marking the worktree while the message is generated. Pi 1.7.0, installed
here, parses the command and resolves the model, then stops at "No API
key found for anthropic". I had no key in CI, so the generated output
hasn't been checked end to end.
`test_docs_are_in_sync`, the other `readme_sync` tests (including the
Taskfile and llm-commits command-match checks) and the help integration
tests pass locally.
**Not changed:** `llm` still appears as a fixture in config, deprecation
and picker tests, and in the demo build's mock. Those aren't examples
users see.
---------
Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
|
||
|
|
e97b6cd190 |
fix: store switch history outside the shared git config (#4928)
`wt switch` recorded the worktree it left in `worktrunk.history` and `worktrunk.history-path` in the repository's shared `.git/config`. #4866 skipped unchanged writes, but every changed value still took `config.lock`, so switches in parallel worktrees could fail concurrent config writers elsewhere. Switch history now lives in `.git/wt/switch-history.json`, replaced atomically through `utils::write_atomically` without any lock. Branch and path are written together, so they can no longer disagree. The `Repository` API (`record_switch_source`, `set_switch_previous`, `clear_switch_previous`, `switch_previous`, `switch_previous_worktree`) keeps its signatures, so callers are unchanged. Values recorded in git config by older versions are no longer read: the first `wt switch -` after upgrading finds no history, and the next switch records it again. Tests: the three `config.lock` unit tests from #4866 are replaced by one that holds `config.lock` while recording, reading and clearing history, and asserts `.git/config` is byte-identical afterwards. Integration tests that seeded history with `git config worktrunk.history` now use `TestRepo::set_switch_previous`. Closes #4863 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
e8ac72d307 |
feat(list): explain visible status symbols when the footer has room (#4858)
`wt list` now uses spare room in the footer to explain symbols shown in the Status column. The existing summary, including hidden columns and timeouts, keeps its place. Each distinct symbol gets at most one explanation. I compared the same listing at 110, 55 and 35 columns. Its footer read, respectively: ```text ○ Showing 2 worktrees, 1 ahead (✗ would conflict ⇡ ahead of remote ^ main worktree) ○ Showing 2 worktrees, 1 ahead (✗ would conflict) ○ Showing 2 worktrees, 1 ahead ``` I also checked the exact-fit boundary and a locked worktree with active merge conflicts. Its row showed `✘`, and the footer explained `✘ merge conflicts`. The full pre-merge gate passed. Another option for narrow terminals would be to give explanations priority over counts. I’d be happy to explore that if you prefer it. Closes #1437. |
||
|
|
03bb7c9555 |
docs(relocate): stop claiming --commit --clobber never fails, and list its remaining skip reasons (#4897)
The `wt step relocate` help called `--commit --clobber` the form that "never fails". That isn't true, so the example now says what the flags do: "Auto-commit dirty worktrees and clobber non-worktree blockers". The "Skipped worktrees" list also gains the two skip reasons it left out. The generated docs page and the skill mirrors are updated to match. With both flags, `src/commands/relocate.rs` still: - skips a locked worktree (`reason: "locked"`), which the list already covered; - skips a worktree whose target path is held by a worktree outside this relocation (`"target_is_worktree"`), even with `--clobber`, since clobbering a worktree would corrupt git metadata. Now listed. A target held by a worktree in the same run, including a cycle, is ordered rather than skipped; - skips a worktree with unresolved conflicts (`"unmerged"`) when `--commit` would have committed it. Now listed; - aborts the run when an auto-commit fails. `test_docs_are_in_sync` and the help snapshot tests pass. I found this in the nightly survey. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
8eea97a252 |
docs(copy-ignored): warn that the node_modules symlink recipe needs an unslashed .gitignore pattern (#4887)
The Node.js recipe in `wt step copy-ignored --help` symlinks each worktree's `node_modules` to the primary worktree's. Git treats that symlink as a file, so the common `.gitignore` entry `node_modules/` (which matches only directories) leaves it untracked. `wt step commit` then stages it, and merging the commit makes Git replace the primary worktree's real, ignored `node_modules` directory with a link to itself, breaking every worktree. This adds one paragraph under the recipe saying the pattern must be `node_modules` without the slash, and what goes wrong otherwise. Verified with plain Git: with `node_modules/` in `.gitignore`, a `node_modules` symlink shows as `?? node_modules`; with `node_modules` it is ignored. The issue has the full `wt` reproduction. The docs mirrors and the `help_step_copy_ignored` snapshot are regenerated; `test_docs_are_in_sync` and the help snapshot tests pass. A code-level guard, such as having `wt step commit` refuse to stage a symlink that points at the primary worktree, would protect users who keep the slashed pattern. That is a product decision and is not part of this PR. Closes #4886 — automated triage Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
49069a5261 |
docs: add PyPI to the install options (#4875)
0.83.0 is the first release on PyPI (#4823), so the install docs can now list it. This adds a **PyPI (experimental)** entry under "Windows & other", after Conda / Pixi. It shows `uv tool install worktrunk@latest && wt config shell install`, then one line for the two uses #4822 asked for: listing `worktrunk` as a dependency, and `uvx --from worktrunk wt list` without installing. `@latest` makes a rerun of the line upgrade, as `brew install` and `cargo install` do for their entries. Without it, `uv tool install worktrunk` answers "`worktrunk` is already installed" and keeps the old version. I checked this with ruff in a scratch tool directory, because worktrunk has only one version on PyPI so far. `-U` behaves the same, but `@latest` is how Ruff's README writes its install line. The `uvx` line needs neither: an unpinned `uvx --from` resolved the newest version even with an older one cached. "Experimental" matches the note at the top of the package's PyPI description. #4823 deferred this until a version was actually on PyPI. I ran both commands against the published package in a scratch tool directory. Each printed `wt v0.83.0`, and `uv tool install` put `wt` and `git-wt` on the bin path. The README and both skill reference copies are regenerated from `docs/src/content/docs/worktrunk.md`, and `test_docs_are_in_sync` passes. > _This was written by Claude Code on behalf of max-sixty_ |
||
|
|
17646c683c |
docs(cli): shorten the -v/--verbose help line (#4877)
Cuts the global `-v`/`--verbose` help to `Verbose output (-v: template variables; -vv: debug logs)`. The previous text ran three lines in `wt --help` and repeated on every subcommand's `--help` and generated docs page. The detail it carried already has a home: `WORKTRUNK_VERBOSE` in the environment-variable table of `wt config --help`, the `-vv` log files in `wt config state logs --help`, and hook/alias template variables in `wt hook --help`. A `-vv` run also prints where its logs go. Docs mirrors and help snapshots regenerated; `test_docs_are_in_sync` and the help snapshot tests pass. > _This was written by Claude Code on behalf of max-sixty_ |
||
|
|
da19a7ac8f | Release v0.83.0 (#4874) | ||
|
|
c854edef7c |
feat(list): expose worktree last activity in schema 2 JSON (#4699)
Closes #4515. ## Problem Dashboards and cleanup tooling that want a per-worktree last-activity timestamp currently have to re-run `git status` per worktree, because schema 2 list JSON has no such field. ## Change Adds `worktree.modified_at` to schema 2 list JSON: the later of `head.committed_at` and the newest mtime among the changed or untracked files `git status` reports for that worktree. The statusline's schema 2 JSON envelope carries the same field for its single item and collects the mtimes as well — before this, it never set `needs_mtime`, so a dirty worktree silently reported the HEAD commit time. No-value semantics follow the existing `Tri` pattern: - Branch-only rows have no worktree object, so the field is absent there. - `null` when the status is unresolved. - A clean worktree reports the commit time without extra filesystem stats. To collect the file mtimes reliably, the shared cached status query behind `wt list` gains `-z`, and the paths that collect mtimes run it with `--untracked-files=all` instead of `normal`, still one subprocess per worktree. Only the schema 2 JSON paths collect mtimes — `wt list --format=json` and the statusline's schema 2 JSON — so the table, the text statusline, and the picker keep the `normal` query and never pay the per-file stat loop. The old text output quoted unusual filenames and collapsed untracked directories, so paths could not be trusted for stat calls; the NUL-delimited form also expands untracked directories into individual files. `parse_working_tree_status`, the conflict checks, and the picker diff state all read the same byte-oriented records now. Missing or deleted files are skipped rather than failing the row, and renames use the destination path. Docs: the worktree field table in the list command help (source for the generated command page and skill mirrors) gains the `modified_at` row, and `docs/public/schema/list-v2.json` is regenerated. ## Verification Validated with Rust 1.99 (the pinned 1.98 toolchain install is broken in this environment; no toolchain files were changed): - `cargo fmt --check` — pass - `cargo clippy --all-targets -- -D warnings` — pass - `cargo test --lib --bins commands::list` — 300 passed - `cargo test --lib --bins` — 2597 passed (run with root's `cap_dac_override` dropped; one permission-based picker test fails under unrestricted root because a read-only directory stays writable there, unrelated to this change) - `cargo test --test integration integration_tests::list::` — 103 passed, including a new test proving a clean worktree reports the commit time and a dirty worktree with a nested untracked file (with a newline in its name) reports that file's mtime - `cargo test --test integration integration_tests::readme_sync::test_docs_are_in_sync` — pass - Six list-JSON snapshots updated; their diffs contain only 33 added `modified_at` lines Not run: the full `hook pre-merge` gate — `pre-commit` and `cargo-nextest` are unavailable in this environment, so its all-feature, doctest, and documentation checks remain unrun. Follow-up (statusline `modified_at` fix): - New test `test_statusline_json_modified_at` fails before the fix (a dirty worktree's statusline JSON reports the HEAD commit time) and passes after - `cargo test --test integration` for the statusline and list modules — 202 passed - `cargo test --lib --bins` — 1570 + 1017 passed, with only the pre-existing root-environment picker failure noted above - `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings` — pass |
||
|
|
ee7960cb10 |
feat(list): expose the configured forge API host in JSON (#4857)
For a remote at `git@git.company.example:team/app.git` with `forge.hostname` set to `api.company.example`, `wt list --format=json` now reports both `host: "git.company.example"` and `api_host: "api.company.example"` in `repo.forge`. With no hostname configured, it omits `api_host`. A pull request targeting another repository keeps its own URL-derived metadata. I tested both JSON formats with the branch-built CLI, covering user and project settings, equal web and API hostnames, and a checkout without a remote. I also checked PR-target isolation, verified that the generated schema marks the field optional, and ran the full pre-merge gate successfully. Closes #4762. |
||
|
|
1c1b49d21f |
fix(alias): forward help flags through aliases that accept arguments (#4856)
With `sw = "wt switch {{ args }}"`, `wt sw --help` now prints the same
help as `wt switch --help`. The short `-h` spelling passes through too.
Both `wt sw` and `wt step sw` use the same rule.
Aliases that bind `help` keep their existing argument parsing. For a
fixed alias, `--help` and `-h` show how to inspect it without running
its body.
I checked both routes with the branch-built CLI, compared short and long
help with direct `wt switch` output, and verified that requesting help
for a fixed alias left its sentinel file absent. All 94 alias
integration tests and the full pre-merge gate passed.
Another option is to let ordinary argument handling decide every
invocation, including fixed aliases. I’m happy to replace this PR if you
prefer that behavior.
Closes #2305.
|
||
|
|
bf7fa8258d |
Publish JSON Schemas for user and project config (#4726)
Closes #4639. This is the files-and-tests scope agreed in the issue: no `wt config schema` command and no SchemaStore submission. ## What's in it - `docs/public/schema/user-config.json` and `project-config.json` are generated from the `UserConfig` / `ProjectConfig` schemars derives, and published at `https://worktrunk.dev/schema/{user,project}-config.json`. - They use the **deserialize** contract, so fields with a serde default stay optional. - Object schemas get `additionalProperties: false`, so editors flag misspelled keys. Map-valued tables (`projects`, `aliases`, `custom-columns`, named hook commands) keep their own `additionalProperties`. - The deprecated `pre-create` / `post-create` hook aliases are left out, so editors flag them as unknown keys. The loader still accepts them with its deprecation warning. - `test_docs_are_in_sync` regenerates both files next to `list-v2.json`. The config types live in the library crate, so the test calls the generator directly instead of shelling out. - Unit tests in `src/config/schema.rs`: - representative user and project TOML configs validate. Each fixture also has to deserialize into the real config type, so the tests can't drift from what the loader reads. - misspelled keys are rejected at the root, in nested tables, and inside `[projects."…"]`, and the project schema rejects user-only keys. - A short `## Editor schemas` section at the end of the `wt config` help explains the `#:schema` directive for Taplo / Tombi. The docs site test that pins the config page's table-of-contents count moves from 36 to 37 for the new heading. ## Testing - Local `wt hook pre-merge --yes` on macOS: all pre-commit hooks pass. 5,471 of 5,494 tests pass. The 23 failures are local-environment only: 22 need `fish`, which isn't installed here, and `in_process_git_reads_only_the_hermetic_config` picks up the system git config. CI on the fork is green apart from the jobs that need repo secrets (Codecov upload, review bot). - I checked the generated schema against Taplo and Tombi using a `#:schema` directive. Both accept a valid `.config/wt.toml` and flag misspelled keys (`pre-starts`, `[forge] platfrom`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
f1dee26601 |
fix(merge): preserve the default branch's worktree instead of erroring after the merge (#4853)
`wt merge <target>` run from a linked worktree that holds the default branch merged and pushed successfully, then failed the command with `✗ Cannot remove the default branch main` and exit 1. The error came from `check_not_default_branch(...)?` in [`finish_after_merge`](https://github.com/max-sixty/worktrunk/blob/5b7d969ed50728f026b9969763370834a3059f8a/src/commands/worktree/finish.rs#L157), which returned before post-merge hooks were registered. Every other condition that keeps the worktree (primary worktree, locked, nested, `--no-remove`) prints `Worktree preserved (...)` and continues; this one now does the same with `○ Worktree preserved (default branch)`. `wt merge --help` step 7 lists the new condition, and the generated docs mirrors are refreshed. To reach it, the primary worktree has to be on another branch (say `develop`), with `main` in a linked worktree, and you run `wt merge develop` from the `main` worktree. The new `test_merge_preserves_default_branch_worktree` sets that up with `repo_with_alternate_primary`. On main it produced `success: false` with the error above; with the fix it exits 0, its snapshot ends with the preserve line, and the worktree still exists afterwards. I picked preserving over keeping the error because the merge has already landed when this check runs, so an error there reports the merge as failed when it actually succeeded. If the error is the intended behavior, the alternative is to keep it and document it in `wt merge --help` instead. Local verification: the new test, `test_docs_are_in_sync`, and the help snapshots pass. Of the 300 `merge` integration tests, all pass except `test_merge_no_ff_signs_merge_commit`, which fails the same way on unmodified main in this sandbox (it needs SSH signing). Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
a55b8a7730 |
fix(list): keep other rows' commit details when one worktree's HEAD object is missing (#4852)
`git log --no-walk` refuses the whole call when one SHA names an absent object, so a single worktree whose HEAD points nowhere blanked Commit, Age and Message on every `wt list` row. `commit_details_many` now passes `--ignore-missing`, which keeps the single batch and simply omits the unreadable SHA; `wt list` then warns once per requested SHA git didn't return (`▲ Commit 1234…7890 not found in repository; its rows show no commit details`), so the explanation stays and only the broken row loses its cells. With the issue's reproduction, `main` and `healthy` now show `first` with their SHA and age. In schema-2 JSON, `head.short_sha` is `null` when it wasn't determined, like `subject` and `committed_at` beside it, rather than `""`. The help table and generated schema/docs reflect that. Schema 1 is unchanged. Tests: - `test_list_missing_head_object_keeps_other_rows_details` reproduces the report in JSON: it fails on the old code with the batch-failure warning and passes now, with healthy rows carrying `short_sha`/`subject` and the broken row `null`. - The unit test `commit_details_many_fails_loudly_on_unknown_sha` pinned the old all-or-nothing behavior; it is replaced by `commit_details_many_omits_missing_objects` (a readable SHA, an absent one, and the null OID return just the readable commit). - The old snapshot test for the batch failure now exercises the per-SHA path, so it is renamed `test_list_warns_when_head_commit_missing`; its snapshot, and `list_shows_warning_on_git_error`'s, now show the healthy rows' details. - `--ignore-missing` doesn't skip a *corrupt* loose object — git still exits 128 — so the batch-failure warning remains reachable. A new `test_list_warns_when_commit_details_batch_fails` covers it by corrupting a commit only a detached worktree reaches. The null-OID filter before the batch stays: git would accept the null OID under `--ignore-missing`, but the filter is what keeps unborn branches out of the new missing-commit warning. Closes #4851 — automated triage --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
8253cb57fc |
chore: correct two FAQ inventory gaps and stale comments in wt list and config show (#4847)
Two FAQ inventories leave out things Worktrunk does, and two comments no longer describe the code next to them. Each fix is the smallest edit that makes the text true. Rendered CLI output is unchanged. - **FAQ, temporary files:** `wt step squash --dry-run` also stages into a temporary index ([`squash.rs`](https://github.com/max-sixty/worktrunk/blob/322735d78d775985c4ff16fa3f3cf835bad987d1/src/commands/step/squash.rs#L541-L546)), the same way `wt step commit --dry-run` does, but the list didn't name it. AGENTS.md points to this section as the inventory of files Worktrunk creates. - **FAQ, commands Worktrunk executes:** the forge CLIs run for PR/MR lookups too, not only CI status: `pr:N`/`mr:N` resolution in `src/git/remote_ref/` and `wt switch --prs`. - **`wt list` collect module doc:** it called the commit-details SHA list "deduplicated" and listed only worktree HEADs and branch tips. The list is a plain chain that also includes remote-branch tips under `--remotes` ([`collect/mod.rs`](https://github.com/max-sixty/worktrunk/blob/322735d78d775985c4ff16fa3f3cf835bad987d1/src/commands/list/collect/mod.rs#L1198-L1212)). `git log --no-walk` collapses repeated SHAs in its output (checked: three copies of one SHA print one line), so this is a comment fix, not a behavior change. The doc also described the map as `(timestamp, subject)`; it is `(short_sha, timestamp, subject)`, and it feeds the pre-skeleton `%h` fold as well. - **`config show`:** one hint used a `\` string continuation, which AGENTS.md asks to avoid. It is now a plain literal with the same text, and the `config_show_unmatched_candidate_exe_emits_extra_hint` snapshot still matches. - **`.typos.toml`:** removes the `ede` entry, which existed only for commit hashes in `.snap` files that are now excluded. The `typos` pre-commit hook passes without it. The `mis` entry is still needed, for prose like "mis-keyed", so only its comment changes. The docs mirrors are regenerated with `test_docs_are_in_sync`, which passes, and the 237 `config_show` integration tests pass. There is no regression test because these are doc and comment edits. Found by the nightly survey. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
bac2845097 | fix(config): reject vars keys git would lowercase or refuse (#4830) | ||
|
|
f3f710e0d8 |
Install the Claude Code plugin with one command (#4843)
`claude plugin install worktrunk --marketplace max-sixty/worktrunk` adds the marketplace when Claude Code doesn't have it yet, then installs the plugin, so the Claude Code install is one command instead of `marketplace add` followed by `install`. `wt config plugins claude install` now runs that command, and its prompt preview, `--help` and the Agent Integration page show it. To weigh: `--marketplace` needs Claude Code 2.1.292 (released 2026-10-06). An older CLI rejects the option, and `wt config plugins claude install` reports the failed command. Checked live against 2.1.328 with a fresh config directory: the first run adds the marketplace and installs, a rerun succeeds as already installed, and a same-named marketplace from another source fails the same way `marketplace add` does. Max asked for the single-line form, after sparkjoy's README. `wt hook pre-merge` passes; the test for a failing second step goes with the second step. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Code <noreply@anthropic.com> |
||
|
|
93cc6937c3 |
chore: correct stale comments and a FAQ claim about wt remove (#4831)
Five small corrections from the nightly survey, none of which change behavior: - **FAQ, "What files does Worktrunk create?"**: said `wt remove <branch>` "deletes the branch". By default it deletes only a merged branch, as the same page's "What can Worktrunk delete?" section says. Now reads "deletes the branch if it's merged". The skill mirrors are regenerated. - **`tests/common/list_snapshots.rs`**: drops an `#![allow(dead_code)]` whose comment said the helpers are only used on some platforms. All three are called unconditionally from `list.rs` and `list_layout.rs`. `cargo clippy --all-targets` stays clean without it. - **`tests/integration_tests/switch_picker_dry_run.rs`**: "Same as above" sat under an unrelated test. It now names `test_picker_dry_run_emits_configured_rows_and_cache_json`. - **`src/git/remote_ref/gitea.rs`**: the `TEA_NO_PROMPT` comment said the code avoided "inventing a fake var" while doing exactly that. It now says the name is a placeholder that tea ignores. - **`src/commands/config/state.rs`**: `handle_state_get`'s unknown-key error listed `logs` as valid, but there is no `logs` arm. Every caller in `main.rs` passes a literal key, so users never see this message. No regression test: the changes touch only docs, comments, and an attribute. `test_docs_are_in_sync` passes. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
36e611bda7 |
fix(wt-switch-create): drop the Scope sentence reserving commits for user permission (#4828)
Deletes the sentence ending the `wt-switch-create` skill's Scope section, "Commits, pushes, and merges still each require explicit user permission." Sessions told elsewhere to commit finished work (a background session's system prompt, or the user's own instruction file) read it as the user reserving git, handed the work back uncommitted, and quoted it as the reason. Scope now states only the command's bounds: one worktree and the requested task in it. Whether to commit, push or merge falls back to the harness and the user's instructions, and Claude Code's default of committing only when asked keeps sessions with no other instruction unchanged. `rationale.md` gains a paragraph recording why Scope stays silent on git permissions, beside its existing note on keeping Scope to bounds rather than permission. The plugin mirror under `plugins/worktrunk/skills/` is regenerated; `test_docs_are_in_sync` passes. The behavioral effect is intermittent (about one session in seventeen, per the issue) and runs inside a live agent session, so CI can't exercise it. Closes #4827 — automated triage Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
b200ed58e5 |
fix(hooks): fail a hook before it starts when its template error is already decided (#4787)
A hook with an unguarded `{{ branch }}` can't expand in a detached
worktree, where `branch` is unset by design (#4009). In a background
hook that failure was silent: the runner renders each step (#3042), so
`wt remove` announced the `post-remove` hook, exited 0, and the error
reached only `runner.log`. In a jj-colocated repo, where every worktree
is detached, that happens on every removal.
Hook preparation already rejects a template that can't parse before any
step runs. `PreparedPipeline::validated` now also rejects one whose
render fails without reading anything an earlier step can change, which
excludes `vars.*` on a branch and Worktrunk's template functions. Such a
template gets the same error and exit status as a syntax error, in every
hook, foreground and background. An error that depends on `vars` or a
function still surfaces when its step runs. The hook help says so, and
points a command that identifies the worktree at `worktree_name` or
`worktree_path`.
Worth weighing: `wt remove` with such a `post-remove` hook now removes
the worktree, prints the error and exits 1, as a syntax error already
makes it. Blocking hooks such as `pre-remove` now fail before step 1
rather than at the broken step, which reverses part of #3042's deferral
for errors decided at preparation. Aliases keep deferring every
expansion error to its step, and the picker's alt-x removal sends the
error only to the debug log, as it does for syntax errors.
johnstegeman reported this in
[rex-config#9](https://redirect.github.com/johnstegeman/rex-config/pull/9).
Requested by max-sixty. With the source change reverted, the new
detached `post-remove` test and the new decided-error foreground case
fail; with it they pass. The run-time tests now use a `vars`-dependent
fixture that really is deferred, and the hooks, remove, prune, merge,
switch, picker and alias integration tests pass.
> _This was written by Claude Code on behalf of max-sixty_
|
||
|
|
66f0bf981e |
Release v0.82.0
Prepares Worktrunk 0.82.0, including release notes, contributor credits, and the minor version bump required by Rust library API changes. Protects active temporary indexes from concurrent stale-file cleanup with an owner lock, preserving forced-removal backups. Restores v0.81.0's daemon-backed removal check and cached macOS fsmonitor startup configuration, as explicitly [approved by the maintainer](https://github.com/max-sixty/worktrunk/pull/4716#issuecomment-6882959528): the unshipped post-shutdown full scan from #4456 is removed. The separate fix that spares live submodule daemons during orphan cleanup (#4729) remains. Includes current main through `0df653384`, corrected plugin documentation, and regenerated mirrors. Independent review covered the rollback, all intervening main changes, and all 30 changelog entries. Local validation passed 5,502 tests (one skipped), doctests, documentation checks, and 21 built-site tests. Full cross-platform validation and all PR checks, including patch coverage, passed. Tagging awaits explicit sign-off on the full adjudicated release safety review. > _This was written by Codex on behalf of max-sixty_ |
||
|
|
04ad96208b |
docs: note that the Claude desktop app skips the plugin's worktree hooks (#4777)
The Agent Integration page says the plugin's `WorktreeCreate`/`WorktreeRemove` hooks route Claude Code worktrees through `wt`, without saying that this doesn't apply to worktree sessions started from the Claude desktop app. The app creates those worktrees itself, under `.claude/worktrees/`, and doesn't call plugin worktree hooks. Upstream tracks this in [anthropics/claude-code#29716](https://github.com/anthropics/claude-code/issues/29716), which is still open. This PR adds one sentence to the worktree isolation section saying so and linking that issue, and regenerates the two skill mirrors. `test_docs_are_in_sync` passes. The page doesn't recommend the workaround from #4776, which is to copy the hooks into `~/.claude/settings.json` and disable the plugin. Two things count against it. Disabling the plugin drops `/wt-switch-create` and `/wt-diff`, and the CLI runs both copies when both are enabled. The upstream thread also disagrees on whether settings-file hooks run in the desktop app: one report says they do, and a later one says they don't. The workaround stays documented on the issue for anyone who wants that trade. Closes #4776 — automated triage Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
736606bac2 |
fix(copy-ignored): reach .worktreeinclude paths inside a wholly ignored directory (#4751)
`.worktreeinclude` now selects by git's own gitignore rules, including paths inside a wholly ignored directory that an include line names, as Claude Code does. `git ls-files --directory` lists such a directory as one entry, so `.cache/claude-code-types/` under an ignored `.cache/` matched nothing, and `copy-ignored` and `promote` skipped it. Claude Code's own `.worktreeinclude` copy reaches it, and a team trialling the Claude Code plugin lost that cache in every new worktree (Rikmorn/sidekick#287). Git now does all the matching. Discovery runs `git ls-files -o -i --directory` once with the standard exclude sources and, when `.worktreeinclude` exists, again with that file as the only source. An entry is selected where the two listings overlap, taking the deeper path of each pair where one holds the other. Inside a directory git lists whole, only lines that name a path (a slash before the end, past any leading `/` or `**/`) select, as found by a third listing of those lines plus the negations. A name matched at any depth (`.env`, `types/`) selects only outside such directories. Claude Code, which defines the file, agrees on path-naming lines; it differs in opening a directory from a line's text and then applying every line inside, so for `packages/*/.cache/types/` plus `.env` it also copies `packages/foo/node_modules/pkg/.env`. The `.worktreeinclude` parse error goes away, since git takes any line as a pattern. So: - A pattern naming a path inside an ignored directory (`.cache/types/`) selects it, and its siblings stay behind. - A pattern that matches at any depth (`.env`) selects the root `.env` and any `.env` git lists on its own, but never a package's `.env` from `node_modules/`. - A negation can't re-include a path inside a selected directory. - An include line naming a partly ignored directory (`build/` with only `build/*.o` ignored) selects only its ignored files. The cost is that each include listing walks every untracked directory: 0.33 s over 124k ignored files with a warm cache, against 0.03 s for the standard listing. Without `.worktreeinclude`, discovery runs one listing as before. Reaching inside ignored directories needed boundaries that whole-directory entries had made unnecessary: - Built-in VCS and tool-state directories now exclude everything inside them too, so `promote` no longer moves `.jj/repo`. - `promote` refuses a destination that resolves outside its worktree through a symlinked directory, and `copy-ignored` checks before creating parent directories. The containment error now says "write" rather than "copy". The Claude Code page now says that hook-made worktrees ignore `worktree.baseRef`, since the hook input carries the worktree's name and no base. Left alone, and older than this change: copying or promoting into a destination where another worktree is checked out inside an ignored directory writes into that worktree, with or without `.worktreeinclude`. > _This was written by Claude Code on behalf of max-sixty_ |
||
|
|
9b7ac2c13b |
docs(list): explain shortened counts (C, K, ∞) (#4770)
The `wt list` docs never explained the shortened counts, so a value like `↑3C` or `+∞` could only be decoded by reading [`format_overflow`](https://github.com/max-sixty/worktrunk/blob/a6cbc2947852261ac22540c4016901bd2f885847/src/commands/list/render.rs#L72-L91). This adds one paragraph under **Columns** in `wt list --help` and the generated docs: `C` is hundreds and `K` thousands, both rounded down, `∞` means 10,000 or more, line counts stay exact up to 999 and commit counts up to 99, shortened values are drawn brighter, and `--format=json` carries the exact counts. The paragraph describes current behavior, so it needs only a one-line edit if the column widths or the `C` notation change. The docs sync test passes and the two `wt list --help` snapshots are refreshed. Refs #4769 — automated triage. The issue's open questions (a third digit place for commit counts to drop `C`, and giving the count columns priority on narrow terminals) are rendering decisions this PR leaves alone. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
64515b0eb3 |
Label wt list diff columns with @ and ^ instead of HEAD and main (#4732)
`wt list` labelled its ahead/behind and branch-diff columns `main↕` and `main…±` in every repository, so a repo whose default branch is `master` or `develop` saw a header naming a branch it doesn't have (#4727). Following the discussion there, the headers now use the symbols worktrunk already gives these refs: | Column | Before | After | |--------|--------|-------| | `working-diff` | `HEAD±` | `@±` | | `ahead-behind` | `main↕` | `^↕` | | `branch-diff` | `main…±` | `^…±` | `^` is the default-branch shortcut `wt switch ^` accepts, and `@` is both Git's and `wt switch`'s name for the current HEAD. The `## Columns` section of the list docs now explains this in place of the sentence that defended the fixed `main` label. No column changes width. Each one is sized by its pre-allocated values (`+999 -999`, `↑99 ↓99`), which were already wider than the old headers, so the only layout change is where the shorter header is centred. Config keys (`[list] columns`) and JSON output don't change. The change itself is the three strings in `ColumnKind::header`. The rest is regenerated snapshots and doc mirrors, plus comments and test fixtures that quoted the old labels. One picker test, `test_arrow_toward_row_ignores_the_column_header`, relied on the header containing `main`; it now checks the same header exclusion with `Remote`, which appears only in the header row. The demo GIF snapshots under `docs/demos/snapshots/` still show the old headers. They come from the demo build (`docs/demos/build`), which needs VHS and isn't run here. Locally, the list, picker, help and docs-sync tests pass, along with clippy and fmt. Some `config_show`/`configure_shell` tests and a few socket and signing tests fail in this sandbox, and they fail the same way on `main`. Refs #4727. The issue's other points are still open: how `C`/`K`/`∞` overflow values are shown and documented. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
9bd2b63871 |
fix(wt-switch-create): leave the current worktree session before entering by path (#4714)
A session already in a worktree can enter only a worktree under its
repo's `.claude/worktrees/`, so `/wt-switch-create` step 3's
`EnterWorktree({path})` always hit the managed-location rejection there.
The `cd` recovery then left Claude Code tracking the old worktree: its
Bash guard, session exit, and `ExitWorktree` all kept acting on it. Step
3 now calls `ExitWorktree({action: "keep"})` before entering. That keeps
the old worktree on disk and makes the entry a first entry. With no repo
argument the session enters from where leaving put it, with no `cd`.
With a repo argument, `cd <repo>` follows as before.
This applies the patch from the issue verbatim:
`skills/wt-switch-create/SKILL.md` and `rationale.md`, plus the
`plugins/worktrunk/skills/` mirror regenerated by
`test_docs_are_in_sync`. That includes the follow-on edits: the handback
names the worktree the session left, `git stash pop` waits until the
session is in the new worktree, Cleanup covers the worktree that was
left, and rationale.md corrects the rejection list and the Known limits
entry.
Verification: the behavior depends on Claude Code's live
`EnterWorktree`/`ExitWorktree` tools, which CI can't run. The evidence
is the issue's live checks against Claude Code 2.1.316 and wt v0.81.0,
including a headless A/B where every already-in-a-worktree scenario went
from 0/3 (0/2 for `--worktree`) to 3/3 and plain sessions stayed 3/3.
Locally, the patch applied cleanly at `d022f7683` and
`test_docs_are_in_sync` passes with the regenerated mirror.
Closes #4713 — automated triage
---------
Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
|
||
|
|
d022f7683c |
docs(reference): repair broken in-page anchors for custom columns and default_branch object (#4688)
## What
Nine in-page anchor links in the reference docs point at fragments that
no heading generates:
- `](#custom-columns)` - the heading is `### Custom columns
[experimental]` (`skills/worktrunk/reference/list.md:123`, `#### Custom
columns [experimental]` at `skills/worktrunk/reference/config.md:231`),
so the generated fragment is `#custom-columns-experimental`. 6 links
updated (list.md x2, config.md x1, plus the `plugins/worktrunk/` synced
copies).
- `](#default-branch-object)` - the heading is `### default_branch
object` (`skills/worktrunk/reference/list.md:331`,
`docs/src/content/docs/list.md:347`), so the fragment is
`#default_branch-object` (underscore, not hyphen). 3 links updated
(skills + plugins list.md, docs list.md).
The `docs/src/content/docs/list.md` copy of the custom-columns links was
left alone: its own heading is `### Custom columns` (no `[experimental]`
suffix), so `#custom-columns` resolves there.
## Why
Readers of the Columns table and the JSON object docs click these links
and land nowhere. The default_branch link is especially easy to miss
since `head-object` / `worktree-object` next to it do resolve.
## How it was verified
- Every heading was read from the current `main` files; fragment names
follow the GitHub slugger (`[` `]` stripped, spaces to hyphens, `_`
kept).
- An anchor checker over all 91 markdown files found exactly these nine
dead fragments (plus three template placeholders like `{{ env.LINK }}`
and literal `...` / `@/...` ellipses, which are intentional and
untouched).
- The `skills/worktrunk/reference/` and
`plugins/worktrunk/skills/worktrunk/reference/` copies were kept
byte-identical.
## Follow-ups deliberately left out
- The `[experimental]` suffix in the headings leaks into the fragments;
renaming headings would produce cleaner anchors but changes existing
inbound links elsewhere, so only the links were repaired.
---------
Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Co-authored-by: viwe-monai <viwe-monai@users.noreply.github.com>
|
||
|
|
c38723335c |
fix: let /wt-diff tool.call throws reach the hook engine; test the subagent path (#4689)
Refs #4656 Updates the `/wt-diff` hook's error handling to properly surface `tool.call` tracking failures to the engine. * **Let throws reach the engine:** Removed the `try/catch`, `console.error`, and `.catch(...)` passthrough. Tracking errors now propagate natively so the engine can catch them and accurately log `hook skipped: threw <message>`. * **Tested the subagent path:** Added a test to verify that a subagent edit correctly tracks its worktree and shows its diff. |
||
|
|
a29ee2b13b |
Ship Codex activity-marker hooks as a separate hooks-only plugin (#4707)
Codex 0.164+ ties plugin hook approval to a fingerprint of every file in the plugin directory. The `worktrunk` plugin keeps the skills mirror and docs next to its four marker hooks, so almost every release made Codex ask users to approve hooks that hadn't changed (#4654). This PR moves those hooks into a second plugin, `worktrunk-markers`. It holds only its manifest and copies of the `wt.sh`/`wt.cmd` shims, so its fingerprint changes only when the hooks or shims change. `wt config plugins codex install` adds both plugins, and `uninstall` removes both. The design follows the live test max-sixty posted in #4654 on Codex 0.166.0. A skill or README change re-prompted the combined plugin but not a hooks-only one. That test also listed four requirements, and this PR covers each one: - **Existing installs.** When an existing user's `worktrunk` plugin updates, its hooks go away silently. The installer adds the markers plugin, and the Codex section of the agent-integration docs now names `codex plugin add worktrunk-markers@worktrunk` for older installs. - **No Claude hooks warning.** The `worktrunk` Codex manifest keeps `"hooks": {"hooks": {}}`, so Codex does not read Claude's `hooks/hooks.json` and warn. - **Real shim files.** The shims are real copies, not symlinks. The new `test_codex_markers_shims_match` checks that they match `plugins/worktrunk/hooks/` byte for byte, that the directory holds only those three files, and that the manifest has no `version`. Neither manifest has a `version` today, and no release step edits `plugin.json`. - **Uninstall.** `uninstall` removes the markers plugin first. `codex plugin remove` already exits 0 for a plugin that isn't installed, so older single-plugin installs uninstall cleanly. Verification: the Codex plugin, layout, help and docs-sync tests pass locally, with snapshots updated for the new install and uninstall output. In the sandbox, the full `pre-merge` gate stopped on `cargo fmt` (fixed in this commit) and on test failures that come from the sandbox itself: blocked Unix sockets, a `0644` signing key, and a nushell autoload file left in the shared home. `test_config_show_codex_available` fails the same way on `main` here. Two things are unverified. I haven't run a real Codex session against this branch. I also haven't checked that running `wt config plugins codex install` again succeeds when the marketplace is already registered, which is why the upgrade note in the docs names the direct `codex plugin add` command. Closes #4654 Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
78e1357583 |
feat(remove): back up uncommitted changes before --force discards them (#4545)
`wt remove --force` now saves a worktree's uncommitted changes before discarding them, using the same `refs/wt-backup/<branch>` ref and reflog that the squash backup in `wt merge` / `wt step squash` already uses. The output then prints the backup and a recovery command: ``` ▲ Discarding uncommitted changes (--force): ?? devbox.lock ↳ Backup created @ refs/wt-backup/feature-untracked (690353c) ↳ To recover in a new worktree, run wt switch --create --base 690353c… --no-hooks recovery/690353c ``` Closes #4544. ## What gets saved - Staged, unstaged, and untracked files go into the snapshot, which is what `git add -A` would stage. The snapshot is built through a `TempIndex`, so the real index and the stash list are left alone. - Ignored files, such as build output, are not saved. For submodules, only the checked-out commit is recorded; uncommitted changes inside a submodule are not saved. - The backup commit's parent is the worktree's `HEAD`, so the branch tip also stays reachable after `-D` deletes the branch. On an unborn branch the commit has no parent. - The backup is taken only when `--force` actually discards something. A clean `--force` removal creates no ref. ## Decisions for review - **Always on, no flag.** This follows the issue thread: a flag would grow the CLI, and always saving means `-f` loses nothing you can't get back. - **A failed backup refuses the removal.** The error is `Failed to back up uncommitted changes; worktree not removed`, followed by git's own error, and the "Discarding uncommitted changes" warning is printed only after the backup succeeds. That follows the data-safety guidance in AGENTS.md. It means `wt remove -f` now refuses a worktree that `git add -A` can't snapshot, such as one holding an unreadable non-ignored file or an untracked nested repo with no commits. A worktree whose `git status` fails (for example, a corrupt index) still has no backup and is removed as before (#4347). The alternative is to warn and continue. - **Cost.** Untracked files that aren't ignored are written as blobs. A large unignored artifact makes the removal slower and grows the object store until the reflog entry expires. Nothing prunes `refs/wt-backup/` today, and this PR doesn't change that. ## Code `create_safety_backup` and the new `create_removal_backup` (`src/git/repository/working_tree.rs`) share a `record_backup` helper for the `commit-tree` / `update-ref` step. The helper looks up the branch name without the cache, and falls back to `symbolic-ref` so an unborn branch is still named. The removal side lives in `stage_worktree_removal` (`src/git/remove.rs`). That function runs right before the worktree is renamed into trash, so it covers `wt remove`, `wt merge --remove`, and the foreground path. ## Tests - `test_remove_force_with_untracked_files` now checks that the backup ref holds the untracked file's content, that its parent is the removed branch tip, and that an ignored file is excluded. - A new unit test covers the unborn-branch case. - `test_remove_force_refuses_when_backup_fails` checks that an untracked nested repo with no commits leaves the worktree in place, and that no discard warning is printed. - The four `remove_force_with_*` snapshots and the `wt remove --help` snapshot gain the new lines. The docs (`wt remove` help, FAQ) mention the backup. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
0081536a2b |
fix(switch): handle fork branch conflicts on GitLab and Azure DevOps (#4542)
`wt switch` now handles a fork PR or MR whose branch name is already used locally on GitLab and Azure DevOps, matching the existing GitHub and Gitea behavior. GitLab uses the source project's namespace as a prefix, including nested groups; Azure DevOps uses the fork repository name. The prefixed branch tracks the PR or MR ref and remains fetch-only, so it cannot push to the fork. The change also updates the `wt switch` help and its generated documentation to describe the shared behavior. Integration tests cover GitLab conflicts with and without existing tracking, Azure DevOps conflicts, and the no-conflict Azure path. The prefixed-name unit tests, docs sync test, and help snapshots pass locally. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
5d54622eee |
docs(remove): mention the wt switch picker's Alt-x in wt remove help (#4703)
Adds one sentence to `wt remove --help`, after the examples that remove worktrees by name: it points readers who want to choose interactively to `Alt-x` in the [`wt switch` picker](https://worktrunk.dev/switch/#interactive-picker). This follows the maintainer's request in #4635. Bare `wt remove` still removes the current worktree. The generated docs page, the skill reference mirrors, and the `help_remove_long` snapshot were regenerated. `test_docs_are_in_sync` and the help snapshot tests pass locally. Closes #4635 Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
ea0dbee6ce |
fix(switch): clear a stale marker when --create makes the branch (#4704)
A branch deleted outside `wt` (for example with `git branch -D`) leaves its `worktrunk.state.<branch>.marker` key in git config. A later `wt switch --create` with the same name then showed the old 🤖/💬. Now `wt switch --create` clears that branch's marker once `git worktree add -b` succeeds. #4684 already clears the marker on every `wt` deletion path. This is the follow-up the maintainer asked for when closing #4685. - The deletion helper from #4684 moves to `Repository::clear_branch_marker`, and both call sites use it. It is still best effort: a failed unset is logged at debug level, and only marker JSON is removed, so a `vars` entry named `marker` that shares the key is left alone. - Only `--create` clears the marker. Switching to an existing branch keeps its marker, and so does a DWIM checkout from a remote branch or a PR/MR ref. - A branch deleted and recreated with plain `git` still keeps its marker until `wt config state marker clear`. The marker help, its generated docs, and the help snapshot now say so. `test_switch_create_clears_stale_marker` sets a marker on a branch name that has no branch and on an existing branch. It then runs `wt switch --create` for the first and plain `wt switch` for the second. It fails without the change, because the stale marker survives, and passes with it. The existing `deletion_*` unit tests pass on the moved helper. Refs #4683 Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
1519b5132e |
Retry failed plugin worktree lookups instead of caching misses (#4668)
Calling /wt-diff before git init caches a null worktree lookup for the session directory. Initializing the repository afterward does not help: subsequent commands reuse that miss and report no Git worktree for the rest of the module lifetime. A transient Git/process failure is similarly cached permanently. Cache only successful locate results. Successful worktree lookups still avoid repeated Git subprocesses. This intentionally trades negative-cache savings for recovery: three repeated non-repository lookups now perform three Git probes rather than one. These probes occur when locating for the command/open pane; passive hooks still only note directories. Positive-cache invalidation behavior is unchanged. Added a canonical Claude test for a failed command followed by a now-available repository, opening the pane and retaining the successful lookup cache. Native plugin validation at `1e4d728a2c740b93c945c3f6a76cbde2c77899d5` with Claude Code 2.1.316: `claude plugin validate plugins/worktrunk` passes with the existing missing-version warning, and `claude plugin test plugins/worktrunk` passes all 9 canonical tests. Restoring only the relevant production file to upstream while retaining the new canonical test gives 8 passes and 1 failure; the unchanged upstream suite passes all 8 tests. The plugin snapshots were checked against every tracked Git blob at the PR head. These local runs use the canonical mocked host events, not a live terminal/provider session. Additional Git-boundary evidence: Node 24 executes the actual locate function body extracted from register.tsx, with TypeScript types stripped, against real temporary Git repositories. Four checks cover git init after a miss, a controlled transient process failure followed by actual Git discovery, successful-cache reuse, and repeated non-repository probe counts. Unchanged source: two failures/two passes. Fixed: four passes in 490ms. That standalone runner checks the Git boundary separately from the native plugin suite; no live-session or maintainer acceptance is claimed. AI disclosure: implementation, tests and description were prepared with Codex and independently reviewed by another Codex agent. No human-authorship or human-review claim is made. |
||
|
|
5bdb832fe8 | fix(remove): clear a branch's marker when wt deletes the branch (#4684) | ||
|
|
a8d0fdf84c |
fix(docs): stop move-changes after stash failures (#4678)
The documented `move-changes` alias now stops when either stash operation fails. A failed stash push no longer starts the new worktree, and a failed stash pop no longer runs the forwarded command in a partially restored worktree. The docs sync test and site build passed. A shell reproduction confirmed that the previous command ran its follow-up after a failed stash pop and the revised command exits with that failure. The full pre-merge gate ran 5,476 tests: 5,469 passed, seven failed in local environment-sensitive tests (including unavailable Unix sockets, shell snapshots, and signing key permissions). This is a documentation-only edit, so the shell reproduction covers the changed recipe; PR CI will verify the published revision. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
2ab571273e |
fix(remove): show the delete-branch config override (#4615)
`wt remove --delete-branch` already overrides `[remove] delete-branch = false`, but the flag was hidden from help. This makes the override visible in help and the generated remove guide, and makes the `-D` conflict error point to it when the conflict comes from config. An explicit `--no-delete-branch` conflict now names that flag directly. The new help test failed before the change and passes now. The existing merged-branch override test and a new unmerged `--delete-branch -D` test pass, as do all 192 removal integration tests and the docs sync test. The local docs build could not run: Astro requires Node >=22.23.4 and this runner has 22.23.3. Closes #4614 — automated triage Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
2c04fb3704 |
Add a /wt-diff pane to the Claude Code plugin (#4638)
The Claude Code plugin gains `/wt-diff`, a pane beside the conversation that lists the worktrees the session has worked in, with the selected one's `wt step diff` below it, drawn file by file with Claude Code's own diff renderer. It is a hooks module, Claude Code's early-access function hooks API, and the plugin's only one. A worktree joins the list when the session starts or moves into it, or when the session or a subagent edits a file there or runs a Bash command there that isn't read-only. Until `/wt-diff` first runs, the hooks only note those directories in session state: no `git` or `wt` process runs and nothing is drawn, which a test asserts. While the pane is open, `wt list --format=json` (once per repository) supplies the rows and `wt step diff` the selected worktree's files; it refreshes on open, on selection, after a burst of non-read-only tool calls goes quiet, and at the end of each turn. Keys: `1`–`9` select a worktree, `j`/`k` move between files (`ctrl+↓`/`ctrl+↑` from the prompt, borrowing the chords of Claude Code's own diff panel), `r` refreshes, and the arrows and page keys scroll. Running `/wt-diff` again, or `ctrl+x tab`, gives the pane the keyboard back. A plugin can't ship keybindings, so the pane has no dedicated chord. Compatibility: Claude Code releases without hooks modules drop the `modules` key and still load the command hooks (checked on 2.1.100), so the 🤖/💬 markers keep working there. Codex and Gemini never read the module. Where to look: - `plugins/worktrunk/hooks/register.tsx` — the module, with its spec at the top. - `plugins/worktrunk/hooks/patch.ts` — splits the patch into files, with rename and mode notes. - `plugins/worktrunk/types/index.d.ts` — the state contract; `tests/diff.test.tsx` — the suite. - `hooks/hooks.json` gains `modules`, `plugin.json` gains `types`, and the agent integration docs gain a `/wt-diff` section (skills mirrors regenerated). One drawing holds 100,000 characters, so the selected file always draws (cut at whole hunks, or to the start of its first hunk, if it must be) and the others draw within the remaining budget; a patch over the 4 MiB that `$.process.run` captures drops its last file and says so. Checked locally: `claude plugin validate plugins/worktrunk`, `claude plugin test plugins/worktrunk` (8 pass), `test_docs_are_in_sync` and `test_plugin_layout_is_consolidated`, and live sessions on Claude Code 2.1.314. > _This was written by Claude Code on behalf of max-sixty_ |
||
|
|
bc8ad63e23 | feat(completion): complete remote-qualified switch branches (#4613) | ||
|
|
bb25aea3ef |
Simplify shell integration detection to known setup lines (#4595)
Shell integration detection used partial shell-syntax heuristics to decide whether an entire rc-file line belonged to Worktrunk. An alias quoting initialization, or an initialization followed by another command, could therefore be removed by uninstall. Recognize complete generated, documented, and historical setup forms instead. Current installer lines come directly from the generator; install, diagnostics, and uninstall share the matcher, which also supplies the shell identity. Preserve custom command names, `.exe` names, Git dispatch, and older installer forms without adding a parser dependency. Remove the syntax-variation heuristics and their tests. Customized shell expressions remain user-managed: uninstall leaves them alone, diagnostics explain that boundary, and installing over such a setup may append the standard initialization line. Regression coverage checks install idempotency and preservation of quoted aliases and compound statements. Validation: shell unit and install/uninstall integration tests, independent CLI lifecycle probes, help snapshots, documentation sync/build, doctests, and all pre-commit checks pass. The full local gate ran 5,430 tests with 5,422 passing. Its documentation-sync failure was resolved by regeneration and a passing repeat; remaining failures were an unchanged startup test, two process-discovery preconditions, and four PowerShell-related failures. The installed `pwsh` also stack-overflows on standalone `1 + 1`, independently of Worktrunk. CI must pass before merge. Closes #4106. > _This was written by Codex on behalf of max-sixty_ |
||
|
|
db2641148f |
docs: describe the squash fallback message and detect OpenCode in the skill (#4510)
Two doc claims didn't match the code; this corrects both in their sources and regenerates the mirrors. - **LLM-less fallback** ([`llm-commits.md`](https://github.com/max-sixty/worktrunk/blob/main/docs/src/content/docs/llm-commits.md#fallback-behavior)): the page said every message without an LLM names the changed files. That holds for `wt step commit` ([`src/llm.rs#L744-L767`](https://github.com/max-sixty/worktrunk/blob/de3b9c1c7a03cd6863777668228cfec9ddbb3bfd/src/llm.rs#L744-L767)), but squashes from `wt step squash` and `wt merge` use `Squash commits from <branch>` with the combined subjects in the body ([`src/llm.rs#L883-L889`](https://github.com/max-sixty/worktrunk/blob/de3b9c1c7a03cd6863777668228cfec9ddbb3bfd/src/llm.rs#L883-L889)). The `wt step squash` help already says so. - **Skill tool detection** (`skills/worktrunk/SKILL.md`): the agent was told to run `which claude codex llm aichat`, leaving out `opencode`, which Worktrunk detects itself ([`src/output/commit_generation.rs#L167`](https://github.com/max-sixty/worktrunk/blob/de3b9c1c7a03cd6863777668228cfec9ddbb3bfd/src/output/commit_generation.rs#L167)) and `llm-commits.md` documents. `docs/public/.well-known/agent-skills/index.json` changes only because the SKILL.md digest moved. Verified with `cargo test --test integration test_docs_are_in_sync`; docs-only, so no regression test. --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
5acc8da7c5 |
chore: correct stale docs and skill references to the trash drain and picker tabs (#4529)
This PR fixes comments, user docs, and maintainer skills that no longer match the code. There are no behavior changes. #4516 replaced the trash sweep, and several references still describe the old one. A few other docs were wrong before that. - **Troubleshooting, `wt list` timeout example**: the warning prints `TaskKind::display_name()` labels (`working-tree diff, working-tree conflict check`), not the kebab-case names the example showed. The snapshot in `format_drain_timeout_diag`'s tests uses the same labels. - **Troubleshooting, config checklist**: dropped "path must be relative, not absolute". No such validation exists, and `worktree-path` accepts absolute paths. - **`drain_trash` doc** (`src/git/remove.rs`): dropped "Every staged removal starts a drain". That describes the behavior #4516 replaced. Removals now skip spawning when a drain is already running. - **State module doc**: the default-branch override key is `worktrunk.default-branch`, not `worktrunk.default_branch.*`. - **Summary tab number**: `PreviewMode::Summary = 6`, so the `[list] summary` doc comment and a test comment now say tab 6 instead of 5. - **`release` skill**: the safety-scan note named "the trash sweep in `src/commands/process.rs`" as the densest destructive code outside `src/git/`. That sweep now only spawns a drain; the deletion walk is in `src/remove_dir.rs`, so the note points there. `unlinkat`, the walk's primitive, is added to the keyword regex, which would otherwise miss changes to it. - **`writing-user-outputs` skill**: `sweep_stale_trash` is now `run_internal_sweep`. The plugin skills mirror was regenerated, and `test_docs_are_in_sync` and the `switch_picker_dry_run` tests pass. No regression test is needed because no behavior changed. Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> |
||
|
|
a6c26c787e |
Retain partial JSON results when later command steps fail (#4584)
Preserve confirmed work in JSON output when a later command step fails. For example, a switch that creates a worktree before `--execute` fails still reports the created path; push and merge retain a completed target update if final verification fails. Command payloads stay on stdout, readable diagnostics stay on stderr, and the exit status signals failure. Carry typed partial facts across mutation boundaries and serialize them in the command handlers. This covers switch, commit/squash, merge/push, remove/prune, relocation, and copy-ignored without adding a public result/error envelope. Switch failures before any result exists now leave stdout empty instead of returning an error-only JSON object. Help and regression tests document the contract. Validation: 309 focused tests and nine additional boundary cases passed, including late commit/squash, prune, relocation, and detached-removal failures and skipped-copy accounting. Clippy, pre-commit, documentation checks, and doctests passed. The full local gate had 12 failures: nine passed sequentially, while three PowerShell tests reproduced `Stack overflow.`. After integrating current main, all-target/all-feature compilation and a review of the overlapping changes passed. CI remains the merge gate. > _This was written by Codex on behalf of max-sixty_ |