Commit Graph

1003 Commits

Author SHA1 Message Date
Maximilian Roos ace16de0e8 Remove wildcard prefix matching from search
Remove the manual wildcard suffix addition and rely on the expand
option for prefix matching instead.
2026-01-08 12:22:44 -08:00
Maximilian Roos 7dea514ec4 feat(search): enable wildcard prefix matching for search terms
Add wildcard suffix to search terms and enable expand option in elasticlunr
to support prefix matching. This allows partial term matches (e.g., "switc"
will match "switch").
2026-01-08 12:08:11 -08:00
Maximilian Roos 549dd99a5d Refactor copy-ignored docs into dedicated step page
Move copy-ignored documentation from hook.md to a dedicated section in step.md. Remove language-specific copy examples from hook.md and consolidate them in step.md with setup instructions, common patterns, and language-specific notes. Update references across documentation and source files to point to the new step page section. Sync skill reference files with docs.
2026-01-07 23:28:05 -08:00
Maximilian Roos 7b512bd71e Refactor: clarify hook documentation and flag descriptions
Update descriptions in hook documentation and CLI help text for clarity:
- Change "Long-running tasks that can finish in parallel" to "Long-running tasks that don't block worktree creation"
- Change "lets you override" to "overrides" for more direct phrasing
2026-01-07 23:24:42 -08:00
Maximilian Roos 6eaeb032ac Refactor: simplify wording in documentation and error messages 2026-01-07 23:22:17 -08:00
Maximilian Roos 6665c128d4 feat(diagnostic): add -vv flag for diagnostic report generation (#472)
* feat(diagnostic): add -vv flag for diagnostic report generation

Add verbosity levels to the CLI:
- `-v` enables debug logging (existing behavior)
- `-vv` also writes a diagnostic report to .git/wt-logs/diagnostic.md

The diagnostic report includes:
- Command that was run and result
- Environment (wt version, OS, git version, shell integration)
- Worktree list
- User and project config contents
- Verbose log (if available)

When gh CLI is installed, shows a hint with the full `gh issue create`
command for easy bug reporting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): make version check more robust in diagnostic test

The version string can be either "v0.9.5" (from git describe) or
"0.9.5" (from cargo), so check for "wt " instead of "wt v".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(test): handle Windows path separators in diagnostic snapshot

The project config path uses backslashes on Windows (.config\wt.toml)
but forward slashes on Unix (.config/wt.toml).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test(diagnostic): add unit tests for config formatting functions

Add tests for:
- format_config_section: file not found, empty file, content, truncation
- strip_ansi_codes: ANSI code removal
- truncate_log: small and large content

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-08 06:56:07 +00:00
Maximilian Roos ce375d6c57 Simplify config state help text
Remove verbose "When to use" sections from ci-status and previous-branch
documentation, replacing with concise usage examples inline with the
description.
2026-01-07 21:19:44 -08:00
Maximilian Roos 5e13207987 Simplify documentation and CLI help text
Reorganize and condense help content for config and hook commands to improve clarity and reduce redundancy. Move practical examples earlier and consolidate explanatory sections. Update default-branch help to emphasize common use cases, and streamline approval workflow documentation.
2026-01-07 20:38:11 -08:00
Maximilian Roos bd2a7c16e9 feat(step): add copy-ignored command for syncing .worktreeinclude files (#469)
* feat(step): add copy-ignored command for syncing .worktreeinclude files

Add `wt step copy-ignored` to copy files listed in `.worktreeinclude` that
are also gitignored between worktrees. Useful in post-create hooks to sync
local config files (.env, IDE settings, build caches) to new worktrees.

Key features:
- Uses git ls-files --ignored for accurate gitignore handling (nested
  .gitignore, global excludes, .git/info/exclude)
- Uses ignore crate for .worktreeinclude pattern matching
- COW (reflink) copying for efficient large directory handling
- --directory flag stops at directory boundaries (avoids listing
  thousands of files in target/ or node_modules/)
- Skips existing files for idempotent hook usage
- Skips symlinks and .git entries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: update hook examples to use wt step copy-ignored

Replace manual CoW bash scripts with the new `wt step copy-ignored`
command in hook documentation. Update Rust and Node.js sections to
show `.worktreeinclude` patterns instead of complex shell commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add worktree-only branch completion filter

Add a new `worktree_only_completer()` function to filter branch completions
to only worktree branches, and update the `CopyIgnored` command to use it
instead of `local_branches_completer()` for the `--from` and `--to` arguments.

* Refactor hook documentation on copying files and CoW strategies

Replace the `.worktreeinclude` and `wt step copy-ignored` approach with direct
copy-on-write examples using native OS commands (`cp -c`, `cp --reflink=auto`).
Add comparison table of symlink vs copy vs CoW strategies with their tradeoffs.
Update language-specific sections (Rust, Node.js) to show CoW patterns instead
of `.worktreeinclude` configuration. Improve clarity on disk efficiency and
cross-platform fallback patterns.

* chore: use wt step copy-ignored for this repo

Add .worktreeinclude with target/ and replace the manual bash CoW
script with `wt step copy-ignored` in post-create hook.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: update all manual CoW examples to use wt step copy-ignored

Update cli.rs (source for hook docs) and tips-patterns.md to use the
new copy-ignored command instead of manual bash CoW scripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: use gutter format for dry-run output, sync skill files

- Refactor copy-ignored --dry-run to show files in a gutter list
  instead of printing each item separately
- Sync skill documentation files with docs (hook.md, step.md,
  tips-patterns.md) after rebase on main

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: simplify error handling in copy-ignored

- Use expect() for strip_prefix since paths always come from git ls-files
- Remove verbose .with_context() wrappers for simple errors - let them bubble up
- Reduces untestable code paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add idempotent and nested file tests for copy-ignored

- test_copy_ignored_idempotent: verifies running twice succeeds (AlreadyExists branch)
- test_copy_ignored_nested_file: copies single file in subdirectory

Improves coverage by exercising more code paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: fix copy-ignored tests to hit correct code paths

- test_copy_ignored_no_worktreeinclude: now creates worktree first
  so it hits the .worktreeinclude check instead of "same worktree"
- test_copy_ignored_empty_intersection: same fix
- Add test_copy_ignored_idempotent and test_copy_ignored_nested_file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add --to flag test for copy-ignored coverage

Adds test for the --to flag which specifies an explicit destination
worktree. This covers lines 437-439 which were previously uncovered.

Note: The .worktreeinclude parse error path (line 465) and copy error
path (line 524) remain untested because:
- The ignore crate is very lenient and doesn't return parse errors
- Filesystem copy errors are hard to test reliably cross-platform

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: add .git skip coverage for copy_dir_recursive

Adds a .git file inside the target directory to test that
copy_dir_recursive correctly skips .git entries (line 598).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ci: trigger CI run

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-07 20:35:34 -08:00
Maximilian Roos 75e1e039f7 feat(hook): add --foreground flag for debugging background hooks (#470)
* feat(hook): add --no-background flag for post-start/post-switch debugging

Allows running background hooks (post-start, post-switch) in the
foreground to see their output directly, useful for debugging.

Usage: wt hook post-start --no-background

Follows the existing --no-background pattern from wt remove.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor(cli): rename --no-background to --foreground across all commands

Rename the flag for running operations in foreground mode from
--no-background to --foreground for better UX. The old flag remains
as a hidden deprecated alias with a warning message.

Affected commands:
- wt remove --foreground
- wt hook post-start --foreground
- wt hook post-switch --foreground

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add tests for deprecated --no-background flag

Add tests to verify the deprecated --no-background flag still works and
shows the deprecation warning. This covers the code paths for:
- wt remove --no-background
- wt hook post-start --no-background
- wt hook post-switch --no-background

These tests ensure the deprecation warnings are emitted and the old flag
continues to function as expected.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 19:04:57 -08:00
Maximilian Roos df5804030e feat(hooks): add --var flag to override template variables (#466)
* Add --var flag to override hook template variables

* refactor(config): unify template variable constants as single source of truth

Move TEMPLATE_VARS and DEPRECATED_TEMPLATE_VARS from cli.rs to
config/expansion.rs to prevent drift between CLI validation and hook
context building. This ensures the --var flag validation always matches
the actual available template variables.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 14:07:39 -08:00
Maximilian Roos eba1553446 feat(config): [ci] platform override and documentation improvements (#465)
* feat(config): add [ci] platform override for custom CI domains

For GitHub Enterprise or self-hosted GitLab with custom domains where
URL-based detection fails, users can now explicitly specify their CI platform:

```toml
[ci]
platform = "github"  # or "gitlab"
```

- Add ProjectCiConfig struct with platform field
- Modify get_platform_for_repo to accept platform_override parameter
- Add ProjectConfig::ci_platform() helper to reduce duplication
- Update all call sites (config.rs, list/mod.rs, ci_status.rs)
- Document in wt config --help and example config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: document underdocumented features

Add documentation for features that existed but weren't discoverable:

- `--show-prompt` and `--stage` flags for `wt step commit/squash`
- `skip-shell-integration-prompt` config option for CI environments
- `[select]` pager configuration for preview panel
- Expanded JSON query examples for `wt list --format=json`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 14:02:05 -08:00
Maximilian Roos c1a5f94d74 feat(select): add Tab 4 for upstream diff preview (#464)
Add "remote⇅" tab to wt select showing ahead/behind diff vs upstream
tracking branch, aligning with wt list's "Remote⇅" column.

Changes:
- Add UpstreamDiff mode (4) to PreviewMode enum
- Implement render_upstream_diff_preview() with:
  - branch@{u} syntax for performance
  - Three-dot diff for merge-base semantics
  - Proper handling of diverged, ahead, behind states
  - ⇡/⇣ symbols matching wt list
- Shell-escape state path in skim bindings (security)
- Borrow UpstreamStatus instead of cloning (performance)
- Update Tab 3 message to "no file changes" (consistency)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 13:47:06 -08:00
Maximilian Roos 271b718d9b feat(hooks): add base and base_worktree_path template variables (#463)
Add two new template variables for creation hooks (post-create, post-start,
post-switch when creating a new worktree):

- {{ base }} — the branch the new worktree was created from (e.g., "main")
- {{ base_worktree_path }} — absolute POSIX path to the base branch's worktree

These variables enable hooks to copy files from the base worktree when creating
new worktrees, such as:

```toml
[post-create]
copy-env = "cp {{ base_worktree_path }}/.env {{ worktree_path }}/.env"
```

Implementation:
- Add base_worktree_path field to SwitchResult::Created to compute once and reuse
- Pass through extra_vars pattern (same as target for merge hooks)
- Variables only available on creation, not existing worktree switches

Closes the TODO at src/commands/command_executor.rs:85.

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-07 12:58:02 -08:00
Maximilian Roos 92abd99656 Format help text command references with backticks
Wrap command references in backticks (e.g., `wt merge`) in help text and documentation to render them as code. Updates both source documentation files and CLI help strings, with corresponding snapshot updates.
2026-01-07 12:54:52 -08:00
Maximilian Roos 9936c69d26 fix: ensure clear completes before demo recording starts
- Move `clear` before `Show` in omnibus tape (was typing "clear" on screen)
- Increase sleep after `clear` from 500ms to 1s in all tapes
- Prevents first frame from showing setup commands/SSH messages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-06 14:32:07 -08:00
Maximilian Roos ba012899d9 Add [select] pager config with backward-compatible auto-detection (#449)
* feat: add [select] pager config with backward-compatible auto-detection

Adds a `[select] pager` config option to override git's pager specifically
for `wt select` diff previews. When not configured, maintains existing
behavior by auto-detecting delta/bat/batcat and appending --paging=never
to prevent hangs in non-TTY contexts.

Users can now set explicit pager commands:
```toml
[select]
pager = "delta --paging=never"
```

The config option takes precedence over auto-detection, giving users full
control while preserving backward compatibility for existing setups.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* test: add coverage for has_explicit_pager_config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* test: add config deserialization tests for [select] pager

Tests verify that the SelectConfig struct deserializes correctly from TOML,
including edge cases (empty string, optional section).

Note: The actual config-loading code path in get_diff_pager() (lines 38-43)
remains uncovered because it only executes during wt select's TUI preview
generation, which requires complex PTY test setup.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 13:03:38 -08:00
Maximilian Roos 9502f23321 deprecate template-file and squash-template-file config options (#445) 2026-01-06 06:46:18 -08:00
Maximilian Roos 66fe9b0ddd Simplify Twitter thread demo with published metadata
Remove structural comments and planning notes, add publication date
and URL. Clean up monospace formatting and condense explanatory text.
2026-01-05 17:38:54 -08:00
Maximilian Roos ba959adbfa Refactor bash detection in code-copy.js
Check data-lang attribute and code content instead of relying on
stripped language classes. Update comment to reflect current detection
logic for bash/shell code blocks.
2026-01-05 16:14:42 -08:00
Maximilian Roos 3719a9de4d Clarify worktree path computation as configurable
Update documentation and help text to describe worktree path computation
as using a configurable template rather than automatic derivation.
2026-01-05 14:48:23 -08:00
Maximilian Roos dc74367b46 Fix GitHub link in hero section
Change the GitHub stars link to point to the repository root instead
of the stargazers page.
2026-01-05 14:29:50 -08:00
Maximilian Roos 32771bcad6 feat: improve worktree-path config discoverability (#431)
* feat: improve worktree-path config discoverability

- Add `wt config create` mention to main --help text
- Show one-time hint after first `wt switch --create` per repo
- Add `wt config state hints` subcommand for managing shown hints
- Hints tracked via git config (worktrunk.hints.<name>)
- Include hints in `wt config state` output (table and JSON)
- Fix: `wt config shell` → `wt config shell install` in help

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update approval_pty snapshots with worktree-path hint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update shell wrapper and integration prompt snapshots

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add tests for hints state commands

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Format hints tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Suppress worktree-path hint when user has custom config

The worktree-path hint ("Customize worktree locations: wt config create")
was showing to all users on their first `wt switch --create`, but users
who already have a custom worktree-path configured don't need this hint.

Now the hint only shows when:
1. This is the first --create in the repo (hint not already shown)
2. AND the user has no custom worktree-path in their config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update snapshots after merge from main

Regenerate snapshots to include both:
- Main's new message format ("Created branch X and worktree from Y")
- Onboarding's hint line ("Customize worktree locations: wt config create")

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-05 13:42:43 -08:00
Maximilian Roos bd865a466f Improve default config examples (#432)
* Standardize template variable documentation examples

Use consistent canonical values throughout all documentation:
- Repo: myproject (not my-project)
- Branch: feature/auth (not feature/foo, feature/new-stuff)
- Worktree: myproject.feature-auth
- Description: "Repository directory name" (not "Repository name")

Also:
- Add missing {{ main_worktree_path }} to Claude plugin skill docs
- Expand dev/wt.example.toml with all available variables
- Add Documentation Examples section to cli-output-formatting.md
- Sync auto-generated docs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify project config example template

- Show both hook formats (single/table) once at top
- Remove redundant format examples from each hook section
- Remove separate Examples section at bottom
- Keep language-specific commands as examples (npm, docker)
- Trim template variables to most useful subset

Result: 91 lines (down from 162)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-05 13:00:14 -08:00
Maximilian Roos 4b6040b334 docs: add FAQ entry for what Worktrunk can delete (#430)
* docs: add FAQ entry for files Worktrunk creates

Document all files and directories Worktrunk creates:
- Worktree directories (wt switch/select)
- Config files (user and project)
- Shell integration (bashrc/zshrc/fish)
- Metadata in .git/ (config keys, CI cache, logs)

Also fix two stale comments:
- hook_filter.rs: .worktrunk.toml → .config/wt.toml
- ci_status.rs: git config → file-based cache path

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add FAQ entry for what Worktrunk can delete

Addresses user concerns from #397 about accidental worktree deletion.
Documents safeguards for worktree and branch removal, recommends
`git worktree lock` for protecting precious ignored data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-05 12:23:24 -08:00
Maximilian Roos dce131be09 docs: add FAQ entry for files Worktrunk creates (#429)
Document all files and directories Worktrunk creates:
- Worktree directories (wt switch/select)
- Config files (user and project)
- Shell integration (bashrc/zshrc/fish)
- Metadata in .git/ (config keys, CI cache, logs)

Also fix two stale comments:
- hook_filter.rs: .worktrunk.toml → .config/wt.toml
- ci_status.rs: git config → file-based cache path

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-05 12:01:49 -08:00
Maximilian Roos 6e1f5c0fc1 Clarify hook execution order and types
Update documentation to distinguish between user hooks and project hooks,
and clarify their execution sequence. User hooks run before project hooks
and don't require approval. Replace "project commands" with generic "hooks"
terminology in merge pipeline steps for accuracy.
2026-01-05 09:57:15 -08:00
Maximilian Roos 7e06824bd1 refactor: update merge command help text
Change the merge command description from "Run from a feature worktree to merge into the default branch" to "Merge the current branch into the default branch" for clarity and accuracy.
2026-01-05 09:55:43 -08:00
Maximilian Roos 06536029a2 Update merge help text to use generic terminology
Replace "merge steps" with "operations" in the wt step reference
to more accurately describe the command's purpose.
2026-01-04 20:49:47 -08:00
Maximilian Roos 0340924d47 refactor: improve CLI help text and documentation
Clarify Push command documentation and improve help text descriptions
for select, squash, and merge commands. Update test snapshots to reflect
these documentation changes.
2026-01-04 20:17:15 -08:00
Maximilian Roos 88969d7010 Update GitHub stars badge and link
Uncomment the stars badge in README and update the GitHub button
link to point to stargazers page instead of the repository root.
2026-01-04 19:01:31 -08:00
Maximilian Roos 0755acf15f Rename "path mismatch" to "branch-worktree mismatch" (#418)
Rename the concept of "path mismatch" (when a worktree exists for a branch
but not at the expected template location) to "branch-worktree mismatch"
throughout the codebase.

The old terminology "path mismatch" was ambiguous about what was mismatched.
The new terminology better describes the relationship problem (branch and
worktree don't align) without prescribing a fix. This is important because:
- Branches have primacy in worktrunk's model
- The fix is always branch-side (rename, recreate), not worktree-side

Changes:
- Rust enum: WorktreeState::PathMismatch → BranchWorktreeMismatch
- Struct field: path_mismatch → branch_worktree_mismatch
- JSON API: "path_mismatch" → "branch_worktree_mismatch"
- User message: "Branch-worktree mismatch; expected {branch} @ {path}"
- Help text: Added explanation "(branch name doesn't match worktree path)"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 13:37:50 -08:00
Maximilian Roos f87199d1b7 feat: improve bare repo support with symbolic-ref HEAD heuristic (#417)
* refactor: centralize home worktree lookup with find_home() and home_path()

Replace scattered `worktrees[0]` patterns with centralized methods:
- `Worktree::find_home()` - static method for when worktrees already fetched
- `Repository::home_path()` - convenience wrapper that fetches internally

Priority: default branch's worktree → first worktree → repo base (bare repos)

This avoids potential panics on empty worktree lists and provides
consistent behavior for bare repos where there's no git "main worktree".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add unit tests for Worktree::find_home()

Cover all branches:
- Empty list returns None
- Default branch match returns that worktree
- Default branch not first still finds it
- No match returns first worktree
- Empty default branch returns first

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: improve bare repo support with symbolic-ref HEAD heuristic

- Add symbolic-ref HEAD heuristic for default branch detection in bare
  repos and empty repos (before first commit)
- Fix bootstrap case where `wt switch --create main` failed in empty
  bare repos because unborn branch was passed to git worktree add
- Add NotInWorktree error type for clear error when "@" is used from
  bare repo directory
- Add TODO for graceful degradation of wt list when default_branch fails
- Update documentation for detection algorithm in --help and web docs
- Add CLAUDE.md guidelines for documentation updates

The symbolic-ref HEAD heuristic only applies when running from the bare
repo directory (not linked worktrees) or in empty repos where no
branches exist yet. In linked worktrees, HEAD points to the current
branch, not the default branch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 13:20:22 -08:00
Maximilian Roos aab859cef4 docs: fix copy button position during horizontal scroll (#415)
Wrap code blocks in a container div so the copy button stays fixed at
the top-right corner when scrolling horizontally. Previously the button
would scroll with the code content.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 12:19:52 -08:00
Maximilian Roos 974b356070 docs: improve help text for select, squash, and merge (#413)
* refactor: clarify Push command documentation

Update Push command help text to better describe its behavior.
Changed "Push changes to local target branch" to "Fast-forward target
to current branch" and expanded the description to clarify it updates
the local target branch (e.g., main) to include current commits,
equivalent to `git push . HEAD:main`.

* docs: improve clarity of CLI help text descriptions

- Main about: "Git worktree management" → "Git worktree management for parallel AI agent workflows"
- wt list: "List worktrees and optionally branches" → "List worktrees and their status"
- wt config state: "Get, set, or clear stored state" → "Manage internal data and cache"
- wt list --full: "Show CI, merge-base diffstat, and working tree conflict check" → "Include CI status and diff analysis (slower)"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: update snapshots and docs for help text changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: improve help text for select, squash, and merge

- wt select: Replace keybinding instructions with purpose description
  "Browse and switch worktrees with live preview."

- wt step squash: Clarify "since target" to "since branching"
  "Squash commits since branching"

- wt merge subtitle: Condense 5-item list to concise summary
  "Squash & rebase, fast-forward target, remove the worktree."

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 11:38:21 -08:00
Maximilian Roos a5722e2c04 docs: improve clarity of CLI help text (#410)
* refactor: clarify Push command documentation

Update Push command help text to better describe its behavior.
Changed "Push changes to local target branch" to "Fast-forward target
to current branch" and expanded the description to clarify it updates
the local target branch (e.g., main) to include current commits,
equivalent to `git push . HEAD:main`.

* docs: improve clarity of CLI help text descriptions

- Main about: "Git worktree management" → "Git worktree management for parallel AI agent workflows"
- wt list: "List worktrees and optionally branches" → "List worktrees and their status"
- wt config state: "Get, set, or clear stored state" → "Manage internal data and cache"
- wt list --full: "Show CI, merge-base diffstat, and working tree conflict check" → "Include CI status and diff analysis (slower)"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: update snapshots and docs for help text changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 00:05:52 -08:00
Maximilian Roos ddd4cbf0f6 docs: Clarify squash command description
Change "Squash commits down to target" to "Squash commits since target"
and expand the help text to better describe the operation of combining
all commits since diverging from target into one.
2026-01-03 23:27:30 -08:00
Maximilian Roos 1154ff0744 Clarify branch cleanup target comparison logic
Reword the explanation of how the "same commit" check differs from
other checks in determining the target branch for comparison.
2026-01-03 21:11:43 -08:00
Muzz Khan fffdf8f471 fix(chore): Removed unnecessary character from installation commands. (#405)
* fix(chore): Removed unnecessary character from installation commands.

* fix: update source file to match README changes

The README is auto-generated from docs/content/worktrunk.md.
This updates the source file to remove $ prefixes from the
installation commands, making the sync test pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Maximilian Roos <m@maxroos.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 04:15:52 +00:00
Maximilian Roos 143ec2a497 Clarify remove command help text
Update the `wt remove` command help to explicitly mention that branches
are only deleted if merged, and that the command defaults to removing
the current worktree. Adjust wording in branch cleanup section to use
"By default" for consistency.
2026-01-03 19:50:42 -08:00
Maximilian Roos 49c15097ff refactor(tests): simplify snapshot testing with auto-bound settings (#396)
* refactor(tests): simplify snapshot testing with auto-bound settings

- Auto-bind snapshot settings in TestRepo::new() via _snapshot_guard field
- Remove manual setup_snapshot_settings().bind() wrappers from tests
- Inline make_snapshot_cmd calls directly in assert_cmd_snapshot! macros
- Remove unused helper functions (json_settings, bind, bind_json)
- Use auto-naming from test function names (explicit names only for multi-snapshot tests)
- Fix directive file guard lifetime in test_remove_internal_mode
- Clean up orphaned snapshot files and let git detect renames

Net reduction: -183 lines in test files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: update statusline tests for fish-abbreviated paths

The auto-bound snapshot settings from TestRepo use `_REPO_` filters
for full paths, but the statusline command uses fish-style path
abbreviation (e.g., `/p/v/f/.../repo`). These abbreviated paths
weren't matched by the existing filters.

Updated `claude_code_snapshot_settings()` to:
- Filter fish-abbreviated paths ending in `/repo` to `[PATH]`
- Strip leading ANSI reset codes from output
- Remove unused `repo` parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: normalize statusline paths across platforms

The statusline output varies by platform:
- Linux: Raw path filtered by auto-bound settings to `_REPO_`
- macOS: Fish-style abbreviation bypasses auto-bound filters

Updated claude_code_snapshot_settings() to normalize both cases
to a consistent `[PATH]` placeholder for cross-platform tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-03 01:00:10 -08:00
Maximilian Roos 79203970c9 Add pre-remove hook to clean up background processes (#384)
- Add pre-remove hook to .config/wt.toml that kills the zola dev server
  when a worktree is removed (prevents orphaned processes)
- Add zellij quit command to demo tape after recording stops
- Document the pre-remove cleanup pattern in tips-patterns.md dev server example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-02 16:10:50 -08:00
Maximilian Roos 2c5000de8a Make worktree-path optional in config (#379)
* Rename template variables for clarity with deprecation warnings

Renames hook template variables for clearer semantics:
- `repo_root` → `repo_path` (absolute path to repository root)
- `worktree` → `worktree_path` (absolute path to current worktree)
- `main_worktree` → `repo` (repository directory name)

Adds new `main_worktree_path` variable for the actual path to the default
branch worktree, useful for sharing dependencies across worktrees.

Deprecated variables continue to work but emit warnings with migration
assistance:
- Detects deprecated variables using minijinja's undeclared_variables()
- Creates a `.new` migration file with replacements
- Shows inline warning: "User config uses deprecated template variables:
  repo_root → repo_path, worktree → worktree_path"
- Shows hint: "Wrote migrated config.toml.new; to apply: mv ..."

Project config warnings only appear when in main worktree (where changes
can be committed). Warnings are deduplicated per path per process.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix issues identified in Codex review

- Fix malformed template bug: check for closing `}}` BEFORE emitting
  replacement to prevent corrupted output
- Add shell escaping to mv command paths using shell_escape::escape
- Add `--` separator to mv command to prevent paths starting with `-`
  from being interpreted as flags
- Handle migration file write errors gracefully with hint message
  instead of propagating error that would block config loading
- Use distinct [TEST_CONFIG_NEW] placeholder for .new files in
  snapshots for better readability
- Add test for malformed template preservation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify deprecated variable replacement with regex

Replace manual character-by-character parsing (~55 lines) with regex-based
approach (~13 lines) that:
- Handles both {{ }} and {% %} Jinja blocks
- Supports multiline blocks with (?s) dotall mode
- Preserves original formatting instead of normalizing whitespace
- Uses word boundaries to avoid false matches

Trade-off: regex moves from dev to prod dependency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix snapshot filter for Windows shell-escaped paths

Windows paths with backslashes get quoted by shell_escape, so the
filter needs to handle: 'C:\Users\...\test-config.toml'

Update regex to match both forward/backward slashes and optional quotes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify replacement by reusing TOML string extraction

Instead of regex-matching Jinja blocks, reuse extract_template_strings()
to get TOML string values, then do word-boundary replacement within them.

This naturally excludes TOML keys like `worktree-path` since we only
process string values, not keys.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update test snapshots after merge: main_worktree → repo

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add test for config show with missing user config

Verifies the "Not found (using defaults)" hint and default worktree-path
display when user config file doesn't exist.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Make worktree-path optional in config

When saving a new config file (e.g., approving a command), don't write
the default worktree-path. This allows users to benefit from future
default changes without having an explicit value override them.

Changes:
- worktree_path is now Option<String> with skip_serializing_if
- Added worktree_path() getter that returns the default when None
- Removed default config display from `wt config show` when file missing
- Updated tests to use the getter and check None default

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-02 14:01:34 -08:00
Maximilian Roos 180fa41402 Comment out commit-generation config section by default 2026-01-02 13:24:27 -08:00
Maximilian Roos feff9d22ca Rename template variables for clarity with deprecation warnings (#369)
* Rename template variables for clarity with deprecation warnings

Renames hook template variables for clearer semantics:
- `repo_root` → `repo_path` (absolute path to repository root)
- `worktree` → `worktree_path` (absolute path to current worktree)
- `main_worktree` → `repo` (repository directory name)

Adds new `main_worktree_path` variable for the actual path to the default
branch worktree, useful for sharing dependencies across worktrees.

Deprecated variables continue to work but emit warnings with migration
assistance:
- Detects deprecated variables using minijinja's undeclared_variables()
- Creates a `.new` migration file with replacements
- Shows inline warning: "User config uses deprecated template variables:
  repo_root → repo_path, worktree → worktree_path"
- Shows hint: "Wrote migrated config.toml.new; to apply: mv ..."

Project config warnings only appear when in main worktree (where changes
can be committed). Warnings are deduplicated per path per process.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix issues identified in Codex review

- Fix malformed template bug: check for closing `}}` BEFORE emitting
  replacement to prevent corrupted output
- Add shell escaping to mv command paths using shell_escape::escape
- Add `--` separator to mv command to prevent paths starting with `-`
  from being interpreted as flags
- Handle migration file write errors gracefully with hint message
  instead of propagating error that would block config loading
- Use distinct [TEST_CONFIG_NEW] placeholder for .new files in
  snapshots for better readability
- Add test for malformed template preservation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify deprecated variable replacement with regex

Replace manual character-by-character parsing (~55 lines) with regex-based
approach (~13 lines) that:
- Handles both {{ }} and {% %} Jinja blocks
- Supports multiline blocks with (?s) dotall mode
- Preserves original formatting instead of normalizing whitespace
- Uses word boundaries to avoid false matches

Trade-off: regex moves from dev to prod dependency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix snapshot filter for Windows shell-escaped paths

Windows paths with backslashes get quoted by shell_escape, so the
filter needs to handle: 'C:\Users\...\test-config.toml'

Update regex to match both forward/backward slashes and optional quotes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Simplify replacement by reusing TOML string extraction

Instead of regex-matching Jinja blocks, reuse extract_template_strings()
to get TOML string values, then do word-boundary replacement within them.

This naturally excludes TOML keys like `worktree-path` since we only
process string values, not keys.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update test snapshots after merge: main_worktree → repo

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-02 13:19:10 -08:00
Maximilian Roos 7b5bea8ce4 Add tests for documentation template examples (#374)
Ensures template examples in docs work as described. Tests cover basic
variables, filters (sanitize, hash_port), operator precedence with
concatenation, and full command examples from docs.

Catches issues like PR #373 where operator precedence was documented
incorrectly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-02 11:32:56 -08:00
coriocactus ab4b7e6801 fix: documentation incorrectly shows ~ concatenation with | filter without parentheses (#373)
* fix: documentation incorrectly shows ~ concatenation with | filter without parentheses

* style: format code with cargo fmt

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Maximilian Roos <m@maxroos.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-02 11:04:26 -08:00
Maximilian Roos b0ff39cb4f Clarify wt switch help text to address git switch confusion (#371)
- Add inline clarification distinguishing wt switch from git switch
- Add "When wt switch fails" section with common failure conditions
- Simplify path description: "computed from a template" instead of
  "derived automatically"

Addresses user confusion reported in #327 where users expected
wt switch to change a worktree's branch like git switch does.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-01 23:29:36 -08:00
Maximilian Roos ad2ba155a3 Refactor demo dependencies to auto-download and build
- Move VHS fork from manual setup to automatic build from source
- Download Claude Code binary and Zellij plugin on demand
- Remove hard-coded binary paths and vhs-keystrokes detection
- Simplify demo registration by removing vhs_type parameter
- Update documentation with new dependency management approach
- Requires Go for building VHS fork, automatically validates on first run
2026-01-01 22:36:25 -08:00
Maximilian Roos 00f0f4bfe3 Fix escaped pipe characters in markdown table help output (#368)
- Add unescape_table_pipes() to convert \| to | before termimad rendering
- Shorten Filters table in hook help to fit 80-column terminals
- Update test to verify escaped pipe handling

The \| escape sequence is used in markdown tables to include literal pipe
characters, but termimad doesn't handle it. This adds preprocessing to
convert \| to | for all tables in help output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-01 18:14:25 -08:00