Merged
Conversation
TypeScript/Bun rewrite with citty for subcommands and @clack/prompts for interactive UI. Commands: add, checkout/switch, cd, ls, rm, purge, completion. Uses a shell wrapper protocol where stdout carries cd targets and all user output goes to stderr, enabling the parent shell to change directories. Includes shell completions for zsh, bash, and fish with branch grouping (user branches, agent branches, active worktrees, remote-only). Configuration via ~/.wtrc (JSON) for default_branch, base_dir, owner, and agent_prefixes. https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
Tests cover: - classifyBranch pure logic (10 cases) - config loading/parsing with various .wtrc contents (7 cases) - git helper integration tests against a real temp repo (18 cases) - CLI entrypoint smoke tests for subcommands and completions (8 cases) 3 CLI --help tests currently fail due to citty writing help output to a file descriptor that Bun.spawn doesn't capture in child processes. https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
- docs/: user guide with pages for commands, configuration, shell integration, and completions (ready for GitHub Pages) - README.md: rewritten with install, usage, development, and contributing sections linking to docs - CLAUDE.md: project context for AI-assisted development covering architecture, conventions (cd protocol, bun shell escaping), and testing notes - .claude/settings.json: pre-approved permissions for test/build - tests/cli.test.ts: fix 3 failing --help tests by testing command registration via direct import (bun test can't capture stdout from child bun processes that call process.exit) All 44 tests pass. https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
- Delete build.sh, add scripts/install.ts (same logic, TypeScript) - Add "install-cli" script to package.json - Update README, docs, CLAUDE.md to reference bun run install-cli - Add contributing guideline: no bash scripts, all scripts in scripts/ as TypeScript https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
Replace three large inline shell script strings with a single SUBCOMMANDS data structure and three generator functions. Adding a subcommand or flag now means editing one array entry instead of three shell-specific templates. https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
- src/command.ts: defineWtCommand() wraps citty's defineCommand, requiring completionType on every positional arg. TypeScript enforces that new commands conform. getWtArgs() reads the metadata back. - src/subcommands.ts: central registry of name → command mappings. Aliases (switch → checkout) declared here. Both index.ts and completion.ts import this. - src/commands/*.ts: all commands converted from defineCommand to defineWtCommand with inline completionType annotations. - src/commands/completion.ts: generates zsh/bash/fish scripts by introspecting the subCommands registry and _wtArgs metadata. No more hand-maintained shell string templates. - src/index.ts: simplified to import subCommands from registry. - tests/cli.test.ts: added test verifying _wtArgs completion metadata. 45 tests pass. https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
- .github/workflows/ci.yml: runs tests and build verification on push to main/dev and on all PRs - .github/TODO-release.md: tracks plan for one-line install with prebuilt binaries (cross-compiled via bun build --compile) - README.md: add "keep tests and docs current" contributing guideline, note about upcoming prebuilt binaries in install section - CLAUDE.md: add "tests and docs" convention https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
- Set up Biome for linting and formatting with auto-fix applied to all source files (import sorting, node: protocol, formatting) - Add lint and check scripts to package.json - Add lint job to CI workflow - Configure Dependabot for npm and GitHub Actions dependencies - Update CLAUDE.md with linting docs, issue quality expectations, git-host-agnostic policy, and "question existing patterns" guideline - Soften GitHub-specific language in docs/commands.md https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
Define a WtCommand interface that extends citty's CommandDef with our _wtArgs metadata and non-optional meta. This eliminates all `as any` casts in command.ts and completion.ts, types WtPositionalArg.default as string instead of any, and makes getWtArgs accept WtCommand instead of any. https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces
wt, a comprehensive CLI utility for managing git worktrees. It provides a user-friendly interface for creating, switching between, and cleaning up git worktrees with intelligent branch management.Key Changes
Core git operations (
src/git.ts): Comprehensive git wrapper functions for worktree and branch management, including:CLI commands:
add: Create new worktrees with new branchescheckout/switch: Create worktrees for existing branchescd: Navigate to worktree directories with auto-creationls: List all worktrees with optional status badgesrm: Remove worktrees and optionally clean up branchespurge: Clean up stale worktree metadata and branches with gone upstreamscompletion: Generate shell completion scripts for zsh, bash, and fishConfiguration system (
src/config.ts): JSON-based configuration file (~/.wtrc) supporting:Shell integration:
cdfunctionalityNotable Implementation Details
git worktree list --porcelaincdfunctionality via wrapper)https://claude.ai/code/session_017UQ2nQgzW7MiNPmsfoAqPu