Commit Graph

37 Commits

Author SHA1 Message Date
Adriano Machado ca91420e1e fix(bare-repo): UX fixes for worktree-path prompt and wt config create --project in bare repos (#2951) 2026-06-02 00:19:15 -07:00
Worktrunk Bot ec62580c29 revert(hooks): keep docs on pre-start/post-start; code accepts both (#2857)
Per @max-sixty's [direction in
#2838](https://github.com/max-sixty/worktrunk/issues/2838#issuecomment-4509447593):
revert the docs portion of #2840 and keep the code. Docs continue to
recommend `pre-start`/`post-start`; both names work in code so anyone
who already followed the briefly-changed docs (e.g. @EcksDy) isn't
stranded once a release ships these aliases.

## User-visible — back to `pre-start`/`post-start`

- README, docs site, skill mirrors, `dev/*.example.toml`,
`plugins/worktrunk/README.md`, `flake.nix`, `.config/wt.toml`
- `src/cli/mod.rs` / `src/cli/config.rs` / `src/cli/step.rs` /
`src/help.rs` after_long_help and example snippets — and the auto-synced
`docs/content/` and `skills/worktrunk/reference/` mirrors
- `wt hook --help` canonical subcommand names; completion advertises
`-start` only
- `HookType` Display via strum, serde `rename`, and clap `ValueEnum`
name — all `pre-start`/`post-start`. The Rust variant identifiers stay
`PreCreate`/`PostCreate` (internal; we already paid for that rename in
#2840, and now the eventual flip is a Display-only change)
- `HooksConfig` serde canonical fields

## `*-create` still works (kept code)

- `wt hook pre-create` / `post-create` — CLI alias on the canonical
subcommand
- `pre-create` / `post-create` in config: top-level, `[hooks.*]`, and
per-project, in string, `[table]`, and `[[array-of-tables]]` form.
Mechanism: serde `alias = ...` on the field, plus a silent in-memory
rename in `migrate_content()` so the round-trip in `unknown_tree`
doesn't flag table forms as schema-unknown.
- The pre-0.32.0 `post-create` fatal-load-error machinery stays removed
— the name is reclaimed, and both forms load without error.

## Smaller bits

- `valid_user_config_keys()` / `valid_project_config_keys()` append
`pre-create` / `post-create` so the unknown-field round-trip skips them.
`test_valid_*_keys_all_deserialize` skips both aliases (they can't sit
alongside the canonical without a duplicate-field error).
- `DEPRECATED_SECTION_KEYS` drops the `pre-start`/`post-start` entries
#2840 added — `pre-start`/`post-start` are canonical again.
- `find_pre_start_from_doc` / `find_post_start_from_doc` /
`find_renamed_hook_key` / `is_non_empty_item` /
`migrate_start_hooks_doc` and their tests are removed; the migration
direction flips via a new `migrate_create_hooks_doc` (silent, mirrors
the prior shape).
- Test files `e2e_shell_post_create.rs` and `post_create_commands.rs`
rename back to `_post_start_` (via `git mv`, so the rename shows as a
rename).

## Testing

`cargo run -- hook pre-merge --yes` — 3806 tests pass; the 10 failures
are all `case_4` of `shell_wrapper::unix_tests::*` (nu-shell case; `nu`
isn't installed in this runner; same failures occur on `main`).

Also manually verified that a fresh `wt switch --create` against a
project config with `[post-create]` loads cleanly with no unknown-field
warning and the hook fires as `post-start`.

## Follow-up

Per @max-sixty: in a couple of weeks, once a release with
both-names-work is out and users have had a chance to upgrade, the docs
flip is straightforward (most of it is in `src/cli/mod.rs`'s
`after_long_help` and the doc-sync test propagates).

Re #2838.

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 16:03:03 +00:00
Maximilian Roos d7e3f88422 feat(hooks): rename worktree-creation hooks to pre-create/post-create (#2840)
Phase 1 of the staged hook rename tracked in #2838: the worktree-creation hooks `pre-start`/`post-start` become `pre-create`/`post-create`. The old names keep working with no deprecation warning yet (Phase 2, months out, adds the warning).

## What changes

- `pre-create`/`post-create` are canonical everywhere: the `HookType` enum, the `HooksConfig` serde fields, the `wt hook` CLI, completion, and all docs.
- Old names keep working: `migrate_content()` rewrites `pre-start`/`post-start` config keys to `-create` before serde, and `parse_hook_type` accepts the old CLI names as silent aliases. `wt config update` rewrites them on disk; `wt config show` shows the migration diff. `wt hook <type>` execution and `wt hook show` both accept the old names; completion and `--help` advertise only the canonical names.
- `detect_deprecations()` flags the old keys so `update`/`show` act on them, but `format_deprecation_warnings()` stays silent (Phase 2 adds the warning). A new empty-warnings guard in `check_and_migrate` keeps a `-start`-only config from emitting a stray hint.
- The dead pre-0.32.0 `post-create` machinery is removed: the fatal `POST_CREATE_REMOVED_MSG` load error, the vestigial `HooksConfig.post_create` merge-fold, and `find_post_create_from_doc`. `post-create` is reclaimed as the canonical background creation hook.

## Semantic flip

Before v0.32.0, the key `post-create` named a *blocking* hook. It now names the *background* one.

Since v0.44.0, a pre-0.32.0 `post-create` config is a fatal load error on the `check_and_migrate` paths: `ProjectConfig::load` and user/system config loading, which fire on essentially every `wt` command. A repo carrying one has been unusable ever since. The one path that skips that check is `project_config_at_ref` (the base-ref read behind `wt switch --create`), which applies only structural migration. A pre-0.32.0 `post-create` surviving solely on a base ref, never checked out into a worktree, would now load as a background hook rather than folding into the blocking `pre-start`. That edge case is accepted: once `post-create` is valid again, reclaiming the name and detecting the dead key are mutually exclusive.

## Reviewing this diff

205 files, but the substance is ~36 files under `src/`. The rest is regenerated snapshots and auto-synced doc mirrors. Start with:

- `src/config/deprecation.rs` — detection (`find_renamed_hook_key`), migration (`rename_hook_key`), removal of the fatal block, the empty-warnings guard, and the `DEPRECATED_SECTION_KEYS` entries that stop unknown-field detection from flagging the migrated keys.
- `src/config/hooks.rs`, `src/git/mod.rs` — the serde field and enum renames.
- `src/config/project.rs` — `ProjectConfig::load` deserializes `check_and_migrate`'s migrated content, so a current-worktree config using the old keys loads into the canonical fields.
- `src/cli/hook.rs`, `src/commands/hook_commands.rs`, `src/completion.rs`, `src/main.rs` — the CLI alias layer; `wt hook show` accepts the old type names as hidden value-parser aliases.
- `src/cli/mod.rs` — the `wt hook` docs, including the soft-deprecation note linking #2838.

The ~93 modified snapshots also pick up deterministic env-block lines (`GIT_*: ""`, `LLVM_PROFILE_FILE`) that pre-existing snapshots already carry. That is stale-snapshot drift surfaced by the regeneration, not a behavior change.

## Testing

Full suite green (3799 tests). New coverage: `snapshot_migrate_start_to_create` (migration preserves value shape and position), `test_deprecated_start_hook_key_runs_silently` and `test_standalone_hook_start_alias_runs_silently` (old config and CLI names run with no warning), `test_config_show_displays_start_hook_migration` (`config show` reveals the diff without an "unknown field" warning), and `test_hook_show_accepts_deprecated_start_hooks` (a current-worktree config using the old keys loads, and `wt hook show` takes both the canonical and the deprecated type arguments).

Part of #2838.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-05-20 19:31:50 -07:00
Maximilian Roos a5a8a49820 test(testing): default wt_command() CWD to an isolated tempdir (#2649)
## Summary

Bare `wt_command()` (free function in `src/testing/mod.rs`) previously
didn't set `current_dir`, so spawned `wt` test subprocesses inherited
the test process's CWD — which is the worktrunk repo root, with its own
`.config/wt.toml` and git history. PR #2648 patched one such case
(`test_config_init_already_exists`) per-test after the nix sandbox
surfaced it.

This change sets a sane default at the constructor: a process-scoped
empty `LazyLock<TempDir>` (outside any git repo, no project config). The
inherited CWD is never the implicit answer.

## Why structural over per-test

I audited the 330 bare `wt_command()` callsites in
`tests/integration_tests/`:

- **297 already set `current_dir(...)` later** in their chain —
`Command::current_dir` overwrites, so the new default is a no-op for
them.
- **33 SUSPECT** sites don't set `current_dir`. None deliberately rely
on inherited CWD — they're all CWD-independent in practice today (`wt
--help`, `wt --version`, `wt config plugins opencode install`, `wt
config shell init <shell>`, clap routing of unknown subcommands, etc.)
but precariously so. A future change to any of those code paths that
starts reading project config would silently couple them to the
worktrunk repo's `.config/wt.toml` again.

Setting the default once removes the latent surprise; patching 33 sites
would not.

## What's in here

- `src/testing/mod.rs`: add `isolated_test_cwd()` helper backed by
`LazyLock<TempDir>`; call `cmd.current_dir(...)` from `wt_command()`.
- `tests/CLAUDE.md`: document the new default contract.
- `tests/integration_tests/config_init.rs`: remove the now-redundant
per-test override added in #2648.

## Test plan

- [x] `cargo check --tests` clean
- [x] All 64 SUSPECT-class tests pass with the new default (help,
completion, custom subcommand routing, opencode plugin
install/uninstall, config_init, config_show_theme)
- [x] Full integration suite has the same pre-existing flakes as `main`
(test_quickstart_merge, test_docs_merge_pre_merge_hook,
test_readme_example_complex, ci_status::* — verified by stashing and
running on main)
- [x] All 1737 unit tests pass
- [x] `pre-commit run --all-files` clean

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-08 18:05:49 -07:00
Maximilian Roos 1fe346be42 ci(nightly): re-enable nix-flake job & fix sandbox failures (#2648)
## Summary

Restore the `nix-flake` nightly job (disabled in #2647) and fix the
sandbox-specific test failures it surfaces. With this merged, the
nightly cron run is back to gating against packaging-environment bugs.

## What's in here

- **Build-mode snapshot redaction**: 49 snapshots hardcoded
  `target/debug/wt` in "Invoked as:" and diagnostic output, which broke
  under crane's release builds. Collapse both modes to
  `target/[BUILD_MODE]/wt` in the shared insta filter.
- **Nix sandbox env**: add `pkgs.python3` and `pkgs.procps` to
  `worktrunk-tests`' native build inputs (needed by argv-quoting,
  post-start, and pgid-invariant tests). Replace
  `#!/usr/bin/env python3` with the absolute python path resolved at
  script-write time, since `/usr/bin/env` doesn't exist on NixOS.
- **PTY filter ordering**: extend `add_pty_binary_path_filters`'
  alternation to match the `[BUILD_MODE]` placeholder so PTY snapshots
  still collapse to `[BIN]` after the prelude rewrite runs first
  (caught by worktrunk-bot review).
- **One inherited-CWD test fix**: `test_config_init_already_exists`
  branched on whether the inherited CWD had a project config — pin
  it to a no-config tempdir so the snapshot is deterministic across
  cargo and nix.

## Test plan

- [x] `nix-flake` job passes in CI (1633 / 1633, was 54 failing)
- [x] All required `ci` checks pass
- [x] Auto-reviewer approved

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-08 16:22:53 -07:00
Worktrunk Bot 04db9ab801 fix(config): reject post-create hook instead of silently migrating (#2361)
## Summary

- Converts the `post-create` → `pre-start` silent migration into a fatal
load error. Paves the way to later reclaim `post-create` as a
background-semantics counterpart to `post-start` without the silent flip
risk.
- Project config: rejects with `ConfigError`. User config: surfaces as
`LoadError::Validation` and best-effort load continues without the file.
- `wt config show` renders the error inline instead of hiding it.

Marked as **draft for consideration** — this is step 1 of the two-PR
sequence discussed in [#1571
(comment)](https://github.com/max-sixty/worktrunk/issues/1571#issuecomment-4291059416).
A follow-up PR (one release later) would perform the actual `pre-start`
→ `pre-create` / `post-start` → `post-create` rename. Supersedes the
closed [#2359](https://github.com/max-sixty/worktrunk/pull/2359).

## Test plan

- [x] `cargo test --lib --bins` (601 passing)
- [x] `cargo test --test integration` (1540 passing; 10 `case_4`
failures are local `nu`-not-installed environmental, unrelated to this
PR)
- [x] `cargo clippy --all-targets --all-features` clean
- [x] New integration tests:
`test_post_create_in_project_config_is_fatal` and
`test_post_create_in_user_config_warns_and_skips`

---------

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 17:46:28 -07:00
Maximilian Roos eb2c2ff032 fix(config): remove extra blank line in config create output (#1525)
The success path in `wt config create` printed a blank line between the
success message and hint lines, inconsistent with the "already exists"
path.

> _This was written by Claude Code on behalf of @max-sixty_

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-14 14:50:05 -07:00
Maximilian Roos dc7f5bca5c Replace bright-black with underline for inline references in hints (#1285) 2026-03-05 02:14:38 -08:00
worktrunk-bot f3ae9a8ac6 fix: unify config path resolution so config create matches config load (#1135) 2026-02-22 06:09:13 -08:00
Maximilian Roos 7ed8cdb421 Revert "feat: add jj (Jujutsu) support alongside git"
This reverts commit cd8420235b.
2026-02-15 14:33:29 -08:00
Maximilian Roos cd8420235b feat: add jj (Jujutsu) support alongside git
Adds support for jj (Jujutsu) as a VCS backend alongside git. Introduces the `Workspace` trait to abstract over both VCS implementations, enabling `wt` commands to work with either git or jj repositories. Includes full jj implementations of core workflows: switch, merge, remove, commit/squash/push/rebase steps, and comprehensive integration tests. Commands automatically detect the repository type and route to the appropriate backend.
2026-02-15 00:47:05 -08:00
Maximilian Roos 45c1f0f796 fix(config): improve hint messages for wt config create (#628)
- Remove extra newline between info message and hint
- Make hint context-aware based on which configs exist:
  - Both configs: suggest viewing both user and project configs
  - User only: suggest creating project config
  - Project only: suggest creating user config
- Remove format reference hint (promoted to wt config --help)

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-14 11:30:45 -08:00
Maximilian Roos 928b3017cd test: remove verbose assertion messages and doc comments (#458)
* Simplify assert messages by removing redundant descriptions

Remove verbose assertion messages that repeat the condition being tested.
Messages like "Should contain indicator" when asserting `contains("●")` are
redundant since the code is self-documenting. This reduces noise in tests
while maintaining clarity through meaningful assertion failures.

* test: remove verbose assertion messages and doc comments

Removed facile test verbosity across three categories:

1. **Doc comments** (~236 lines): Removed `/// Test X` comments that just
   restated test function names. Kept multi-line explanations that add context.

2. **Test names** (9 functions): Shortened overly verbose names by removing
   filler words while maintaining clarity:
   - test_merge_when_primary_not_on_default_but_default_has_worktree →
     test_merge_primary_not_on_default_with_default_worktree
   - test_complete_switch_option_prefix_shows_options_not_branches →
     test_complete_switch_option_prefix_shows_options

3. **Assertion messages** (19 instances): Removed messages that just restate
   the check:
   - assert!(path.exists(), "Path should exist") → assert!(path.exists())
   - assert!(x.is_file(), "Should be a file") → assert!(x.is_file())

Kept messages that add semantic meaning (e.g., "hook should have run") or
include debugging variables.

Total: 279 lines removed across 31 files. All 723 integration + 401 unit tests
passing.

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

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

* test: remove unreferenced snapshot files from renamed tests

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

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 16:51:44 -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 710b881df0 Add colored command reference output to documentation (#273)
Convert --help-page output to HTML with ANSI colors preserved,
matching how `wt list` outputs render in the web docs. The doc
sync test now converts command reference blocks from markdown
code fences to Zola's {% terminal() %} shortcode with proper
HTML styling.

- Add with_colors parameter to get_help_reference()
- Use std::println! to preserve ANSI codes (bypass anstream TTY detection)
- Add strip_ansi_codes() helper for pattern matching
- Convert command reference blocks to HTML in readme_sync test
- Fix URL typo in config docs (/hooks/ → /hook/)

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-20 23:39:55 -08:00
Maximilian Roos ad6ec2351b Replace emojis with single-width Unicode symbols (#255)
* Replace emojis with single-width Unicode symbols

Switch from graphical emojis (🔄, ✅, ❌, etc.) to single-width Unicode
symbols (◎, ✓, ✗, etc.) for message indicators:

- ◎ Progress (bullseye)
- ✓ Success (checkmark)
- ✗ Error (x mark)
- ▲ Warning (triangle)
- ↳ Hint (corner arrow)
- ○ Info (empty circle)
- ❯ Prompt (shell prompt)

Benefits:
- Better terminal compatibility (emojis render inconsistently)
- More serious/professional aesthetic
- Consistent single-character width for alignment

Also reduces gutter indentation from 3 to 2 columns to align with 1-char
symbols, and adds colors to the symbols themselves (red for errors, green
for success, etc.).

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

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

* Update shell integration test snapshots

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

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

* Update documentation and comments to use new symbols

Update help text examples, doc comments, and .claude rules files
to reflect the new single-width Unicode symbols.

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

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

* Update .claude rules to use symbol terminology

Rename emoji→symbol consistently in documentation guidelines.

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

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

* Use cstr! for pre-colored symbols

Symbols now have their semantic colors embedded using color_print's cstr!
macro, which creates colored &'static str constants. This ensures symbols
are always consistently colored without needing to wrap each usage site.

- PROGRESS_SYMBOL: cyan ◎
- SUCCESS_SYMBOL: green ✓
- ERROR_SYMBOL: red ✗
- WARNING_SYMBOL: yellow ▲
- HINT_SYMBOL: dim ↳
- INFO_SYMBOL: dim ○
- PROMPT_SYMBOL: cyan ❯

Message formatting functions now apply color only to the text content,
since symbols are pre-colored.

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

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

* Update shell integration test snapshots for pre-colored symbols

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

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

* Add filter for shell-escaped paths in test snapshots

When shell_escape quotes paths, the filters replace the path portion
but leave the quotes. Add filters to normalize '[REPO]' to [REPO].

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

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

* Filter syntax-highlighted [REPO] placeholders

Shell-escaped paths get green syntax highlighting. Add filter to
normalize colored [REPO] placeholders back to plain [REPO].

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

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

* Fix snapshot filters for shell-escaped path formatting

CI (Ubuntu/Windows) produces different ANSI formatting around
shell-escaped paths than local macOS. Add filters to normalize
the dim formatting codes around [REPO] placeholders.

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

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

* Update snapshots for single-width Unicode symbols

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

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

* Update PTY test snapshots for new symbols

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

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

* Update snapshots for new symbols after merge

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

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-19 17:34:44 -08:00
Maximilian Roos 12dbe6df58 Fix snapshot filters to strip quotes from shell-escaped paths (#257)
* Fix snapshot filters to match shell-escaped paths on Windows

shell_escape::escape() quotes paths containing special characters like ~
(tilde) or backslashes (Windows paths). The snapshot filters only matched
unquoted paths, causing CI failures on Windows where paths like
D:\a\worktrunk\... get quoted to 'D:\a\worktrunk\...'.

Add filters that match single-quoted versions of all path patterns:
- Repo paths (absolute, forward-slash, and POSIX-style)
- Tilde-prefixed paths (~/repo)
- Worktree paths
- Windows temp directory patterns

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

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

* Trigger CI

* Fix snapshot filters to strip quotes from shell-escaped paths

When shell_escape quotes paths containing special characters (tildes,
backslashes), the filters need to strip these quotes to normalize output
across platforms.

Two issues were fixed:
1. Quoted path filters were replacing with quoted placeholders instead of
   stripping the quotes entirely
2. When ANSI codes appear between the quote and path content, the quoted
   path filter doesn't match - added cleanup filters to strip quotes around
   placeholders after all path filters have run

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

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

* Fix snapshot filter for ANSI codes inside quotes

shell_escape::escape() quotes paths with special characters (tildes,
backslashes). The quoted paths include ANSI color codes from syntax
highlighting between the quotes and the path content, e.g.:
  '<ANSI>[REPO]<ANSI>'

The cleanup filters now use ANSI-aware regex patterns:
  r"'(?:\x1b\[[0-9;]*m)*\[REPO\](?:\x1b\[[0-9;]*m)*'"

This matches quotes with zero or more ANSI escape sequences inside
and strips them, normalizing output across platforms.

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

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

* Simplify snapshot placeholders: [REPO] -> _REPO_

Replace bracket-based placeholders with underscore-based ones to
eliminate regex escaping complexity in test filters:

- [REPO] -> _REPO_
- [WORKTREE_XXX] -> _WORKTREE_XXX_

This makes the cleanup filters much simpler since underscores don't
need escaping in regex patterns. The ANSI-aware patterns still work
but are now simpler to read and maintain.

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

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

* Add filter to normalize syntax highlighting around placeholders

Bash syntax highlighters color paths differently across platforms
(green on Linux, no color on macOS). Add filters to strip ANSI color
codes from around _REPO_ and _WORKTREE_ placeholders so snapshots
are consistent regardless of the platform's syntax highlighting behavior.

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

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

* Fix filter to normalize CI syntax highlighting to local format

Linux CI produces different ANSI code structure for paths in hints:
- CI: [2m [0m[2m_REPO_[2m [0m (separate spans for spaces)
- Local: [2m _REPO_ [0m (all in one span)

Add filter to match CI format and convert to local format so
snapshots work consistently on both platforms.

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

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

* Fix filter to handle green color codes around placeholders

The bash syntax highlighter on Linux CI applies green color ([32m) to
_REPO_ placeholders, while macOS local does not. Update the filter to
handle optional [32m before and [0m after the placeholder.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-19 17:01:30 -08:00
Maximilian Roos 87d482736b Add suggest_command helper for copy-pasteable CLI hints (#244)
* Add suggest_command helper for copy-pasteable CLI hints

Introduce a helper that builds complete, copy-pasteable commands for hint
messages. Commands now use the "To X, run Y" pattern and end with the
command for easy copying.

Key changes:
- New suggest_command() in src/styling/suggest.rs with shell escaping
- Hints include specific branch names and arguments
- Pattern: "To delete the unmerged branch, run wt remove feature -D"
- Document pattern in cli-output-formatting.md guidelines

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

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

* Update snapshots for hint message refinements

Snapshots updated to reflect:
- "To skip pre-merge commands, add --no-verify" pattern
- Consistent hint formatting with ending commands

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

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-17 21:58:31 -08:00
Maximilian Roos aae2b6574c Add integration tests for config and state commands (#219)
Add three new tests for project config creation in config_init.rs:
- test_config_create_project_creates_file: verifies project config file creation
- test_config_create_project_already_exists: tests idempotent behavior

Add test_state_get_logs_with_files in config_state.rs to verify log file
listing displays correct table headers and file information.
2025-12-15 13:33:26 -08:00
Maximilian Roos 7723fce280 more rstest (#150)
* Add temp_home fixture for tests that need custom home directory

Tests that manipulate shell config files or other home directory content were creating `TempDir::new()` manually. Convert these to use an `#[rstest]` fixture for consistency and cleaner test code.

The `temp_home` fixture:
- Creates a temporary directory for use as a fake HOME
- Automatically cleans up when dropped
- Makes test intent clearer by appearing in function signature

This reduces boilerplate across multiple test files (config_init, config_show, configure_shell, hook_show, list_config) and enables better test composition.

* Refactor tests to use repo_with_remote fixture

Replace manual setup_remote() calls with #[from(repo_with_remote)]
rstest fixture parameter to reduce boilerplate in test functions.
Also normalize import ordering across test files.
2025-12-11 04:03:09 -08:00
Maximilian Roos 5f304744c9 Combine config hint messages for brevity
Consolidate multiple hint lines into single messages where they provide related guidance, reducing visual clutter in help output.
2025-12-09 00:06:14 -08:00
Maximilian Roos 69474c620d Add --project flag to wt config create (#110)
Add `wt config create --project` to generate `.config/wt.toml` project
config files with documented examples. This makes it easier for users
to discover and create project configs.

Changes:
- Add --project flag to create project config instead of user config
- Show both user and project config templates in --help
- Update reference from dev/wt.example.toml to docs URL
- Add example to wt config --help

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-08 12:04:13 -08:00
Maximilian Roos 462b12c329 Fix: Remove explicit dimming from hint commands
The `output::hint` function already applies dim styling, so adding an explicit `<dim>` tag after a `<bright-black>` command in a hint causes redundant and incorrect styling. This commit removes the unnecessary `<dim>` tags from various hint messages in error handling and output generation, ensuring consistent and correct output styling.
2025-12-01 11:55:08 -08:00
Maximilian Roos 892bbd83c7 Fix: Use gutter output for cache show command 2025-12-01 11:35:30 -08:00
Maximilian Roos 1be558a785 feat: Add GitHub Pages deployment workflows (#65)
* Refactor: Standardize user messages for improved clarity

This commit introduces a set of refinements to user-facing messages across the application. The goal is to ensure consistency in tone, terminology, and presentation, making interactions more intuitive and understandable for users.

* feat: Add a documentation site for Worktrunk

This commit adds the initial scaffolding for the Worktrunk documentation site, built with Zola and a customized Juice theme.

The site includes:
- Basic configuration (`config.toml`)
- Custom SASS styling (`custom.scss`)
- Custom SVG logos and favicons
- Overridden Zola templates (`base.html`, `index.html`, `page.html`)
- Markdown content for:
    - Quick Start
    - Concepts
    - Configuration
    - Commands Reference
    - Advanced Features
    - FAQ

The content is an initial auto-generated draft and requires review for accuracy and completeness before being considered production-ready. A `CLAUDE.md` file is included to highlight this and list necessary verification steps.

* feat: Add GitHub Pages deployment workflows

Build Zola docs site and deploy to worktrunk.dev on push to main.

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

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-30 18:22:28 -08:00
Maximilian Roos e5c1a7f6de docs: Standardize "user config" terminology
Renames all instances of "global config" to "user config" for clarity and consistency across the documentation and CLI. This affects the README, help messages, and internal code comments.
2025-11-28 16:59:48 -08:00
Maximilian Roos 9c8063e568 Refine semantic color usage for output messages 2025-11-27 15:11:19 -08:00
Maximilian Roos e497344c08 feat: Auto-wrap messages in semantic colors and update docs
Simplifies styling documentation to reflect `color-print` usage, allowing for automatic semantic color wrapping of output messages.
2025-11-27 14:44:09 -08:00
Maximilian Roos cadca7c123 feat: Improve terminal output and shell configuration
Migrate to `color-print` for enhanced terminal output and fix the `configure_shell` output.
2025-11-27 13:12:05 -08:00
Maximilian Roos 8cd3a85b77 Fix(cli): Improve error reporting and message consistency
Refactor output to send all messages to stderr and include the branch name in select preview messages for better user experience.
2025-11-26 23:54:28 -08:00
Maximilian Roos 22df27d3a2 refactor: Centralize command output through output module
Ensures all command-line interface output is routed through a dedicated `output` module.
This change helps manage how `wt` produces output, especially in "internal" mode where
`stdout` is reserved for shell script directives.

Previously, `print!` and `println!` were used directly in command code, which could
lead to unintended output interfering with shell integration scripts.

The `output_system_guard` test has been updated to enforce this new rule, scanning
`src/commands` for direct `print!` and `println!` usage and flagging violations.
2025-11-24 20:11:26 -08:00
Maximilian Roos 73138958f6 feat: Rename config list to config show and enhance shell integration
Renamed the `wt config list` command to `wt config show` for better clarity.
This command now includes enhanced shell integration checks:
- Displays shell status for better visibility.
- Verifies `compinit` order for Zsh to ensure proper completion loading.
2025-11-24 18:03:22 -08:00
Maximilian Roos 79ead88546 docs: Refer to wt config create --help 2025-11-23 13:16:23 -08:00
Maximilian Roos 7ca9f3596c refactor: Rename config init to config create 2025-11-21 03:36:47 -08:00
Maximilian Roos d3d64abd87 feat: Add user configuration for wt list and apply different help templates
Refactor help templates to allow for command-specific variations and introduce user configuration options for `wt list --full` and `--branches`.
2025-11-20 23:35:55 -08:00
Maximilian Roos 376f97886a refactor: Simplify command approval, status symbol logic, and shorten home directory paths 2025-11-20 11:34:28 -08:00
Maximilian Roos 4f7a3b0816 feat: Improve consistency of CLI outputs and add config init tests
- Ensures standalone messages consistently use emojis for better visual hierarchy.
- Adds `test_config_init_already_exists` and `test_config_init_creates_file` to verify `wt config init` behavior, including correct emoji usage for output messages.
2025-11-10 22:02:21 -08:00