@desplega.ai/wts 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +273 -0
- package/dist/index.js +3437 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# wts - Git Worktree Manager
|
|
2
|
+
|
|
3
|
+
A CLI tool for managing git worktrees with tmux integration, fzf fuzzy selection, Claude Code launcher support, and GitHub PR creation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### From npm (recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @desplega.ai/wts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or with other package managers:
|
|
14
|
+
```bash
|
|
15
|
+
yarn global add @desplega.ai/wts
|
|
16
|
+
pnpm add -g @desplega.ai/wts
|
|
17
|
+
bun add -g @desplega.ai/wts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### From source
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cd wts
|
|
24
|
+
bun install
|
|
25
|
+
bun link
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Prerequisites
|
|
29
|
+
|
|
30
|
+
- [Bun](https://bun.sh) runtime
|
|
31
|
+
- Git 2.15+ (worktree support)
|
|
32
|
+
- Optional: [fzf](https://github.com/junegunn/fzf) for interactive selection
|
|
33
|
+
- Optional: [tmux](https://github.com/tmux/tmux) for window management
|
|
34
|
+
- Optional: [gh](https://cli.github.com/) CLI for PR creation
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Register your project
|
|
40
|
+
cd /path/to/your/git/project
|
|
41
|
+
wts init
|
|
42
|
+
|
|
43
|
+
# Create a worktree for a feature
|
|
44
|
+
wts create my-feature --new-branch --tmux
|
|
45
|
+
|
|
46
|
+
# List worktrees
|
|
47
|
+
wts list
|
|
48
|
+
|
|
49
|
+
# Switch between worktrees (with fzf picker)
|
|
50
|
+
wts switch
|
|
51
|
+
|
|
52
|
+
# Create a PR from your worktree
|
|
53
|
+
wts pr my-feature --draft
|
|
54
|
+
|
|
55
|
+
# Clean up merged worktrees
|
|
56
|
+
wts cleanup
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
### `wts init`
|
|
62
|
+
|
|
63
|
+
Register the current project for worktree management.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
wts init # Interactive setup
|
|
67
|
+
wts init -y # Use defaults, skip prompts
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Creates a global config entry at `~/.wts.json` and optionally a local `.wts-config.json` for project-specific settings.
|
|
71
|
+
|
|
72
|
+
### `wts create <alias>`
|
|
73
|
+
|
|
74
|
+
Create a new worktree.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
wts create feature-auth # Interactive branch selection via fzf
|
|
78
|
+
wts create feature-auth -n # Create new branch named 'feature-auth'
|
|
79
|
+
wts create feature-auth -b existing-branch # Use existing branch
|
|
80
|
+
wts create feature-auth --base develop # Base new branch on 'develop'
|
|
81
|
+
wts create feature-auth --tmux # Open in tmux window
|
|
82
|
+
wts create feature-auth --tmux --claude # Open tmux + launch Claude Code
|
|
83
|
+
wts create feature-auth --no-setup # Skip setup script
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Worktrees are created at `.worktrees/<project>/YYYY-MM-DD-<alias>/`.
|
|
87
|
+
|
|
88
|
+
### `wts list`
|
|
89
|
+
|
|
90
|
+
List worktrees for the current project.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
wts list # Current project only
|
|
94
|
+
wts list -a # All tracked projects
|
|
95
|
+
wts list --json # JSON output
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Aliases: `wts ls`
|
|
99
|
+
|
|
100
|
+
### `wts switch [alias]`
|
|
101
|
+
|
|
102
|
+
Switch to a worktree.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
wts switch # Interactive fzf picker
|
|
106
|
+
wts switch my-feature # Switch directly
|
|
107
|
+
wts switch --tmux # Open in new tmux window
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `wts delete <alias>`
|
|
111
|
+
|
|
112
|
+
Remove a worktree.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
wts delete my-feature # Remove worktree
|
|
116
|
+
wts delete my-feature -f # Force remove (uncommitted changes)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Aliases: `wts rm`
|
|
120
|
+
|
|
121
|
+
### `wts cd <alias>`
|
|
122
|
+
|
|
123
|
+
Print the worktree path (for shell integration).
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
wts cd my-feature # Prints path to stdout
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### `wts pr [alias]`
|
|
130
|
+
|
|
131
|
+
Create a GitHub pull request from a worktree branch.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
wts pr # Auto-detect from current worktree
|
|
135
|
+
wts pr my-feature # Specify worktree
|
|
136
|
+
wts pr --draft # Create as draft PR
|
|
137
|
+
wts pr --web # Open in browser after creation
|
|
138
|
+
wts pr -t "My PR title" # Set title
|
|
139
|
+
wts pr -b "Description here" # Set body
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Requires `gh` CLI to be installed and authenticated.
|
|
143
|
+
|
|
144
|
+
### `wts cleanup`
|
|
145
|
+
|
|
146
|
+
Remove merged or stale worktrees.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
wts cleanup # Remove merged worktrees (interactive)
|
|
150
|
+
wts cleanup --dry-run # Show what would be removed
|
|
151
|
+
wts cleanup -f # Force, no confirmation
|
|
152
|
+
wts cleanup --older-than 30 # Include worktrees older than 30 days
|
|
153
|
+
wts cleanup --unmerged # Include unmerged worktrees
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Configuration
|
|
157
|
+
|
|
158
|
+
### Global Config (`~/.wts.json`)
|
|
159
|
+
|
|
160
|
+
Stores tracked projects and default settings.
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"projects": {
|
|
165
|
+
"my-project": {
|
|
166
|
+
"path": "/Users/me/code/my-project",
|
|
167
|
+
"registeredAt": "2024-01-08T12:00:00.000Z"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"defaults": {
|
|
171
|
+
"worktreeDir": ".worktrees",
|
|
172
|
+
"tmuxWindowTemplate": "{project}-{alias}",
|
|
173
|
+
"autoTmux": false,
|
|
174
|
+
"autoClaude": false
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Local Config (`.wts-config.json`)
|
|
180
|
+
|
|
181
|
+
Project-specific overrides (optional).
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"worktreeDir": ".worktrees",
|
|
186
|
+
"tmuxWindowTemplate": "{project}-{alias}",
|
|
187
|
+
"autoTmux": true,
|
|
188
|
+
"autoClaude": true,
|
|
189
|
+
"setupScript": ".wts-setup.sh"
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Configuration Options
|
|
194
|
+
|
|
195
|
+
| Option | Type | Default | Description |
|
|
196
|
+
|--------|------|---------|-------------|
|
|
197
|
+
| `worktreeDir` | string | `.worktrees` | Base directory for worktrees (relative to git root) |
|
|
198
|
+
| `tmuxWindowTemplate` | string | `{project}-{alias}` | Template for tmux window names |
|
|
199
|
+
| `autoTmux` | boolean | `false` | Auto-open tmux window on create |
|
|
200
|
+
| `autoClaude` | boolean | `false` | Auto-launch Claude Code on create |
|
|
201
|
+
| `setupScript` | string | - | Script to run after worktree creation |
|
|
202
|
+
|
|
203
|
+
### Template Variables
|
|
204
|
+
|
|
205
|
+
- `{project}` - Project name (from git root folder)
|
|
206
|
+
- `{alias}` - Worktree alias
|
|
207
|
+
|
|
208
|
+
## Shell Integration
|
|
209
|
+
|
|
210
|
+
Add this function to your `.bashrc` or `.zshrc` for easy directory switching:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Change to a worktree directory
|
|
214
|
+
wcd() {
|
|
215
|
+
local path
|
|
216
|
+
path=$(wts cd "$1" 2>/dev/null)
|
|
217
|
+
if [ $? -eq 0 ] && [ -n "$path" ]; then
|
|
218
|
+
cd "$path"
|
|
219
|
+
else
|
|
220
|
+
echo "Worktree '$1' not found"
|
|
221
|
+
return 1
|
|
222
|
+
fi
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Usage:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
wcd my-feature # cd to the my-feature worktree
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Setup Scripts
|
|
233
|
+
|
|
234
|
+
You can configure a setup script to run automatically after worktree creation.
|
|
235
|
+
|
|
236
|
+
### Bash Script (`.wts-setup.sh`)
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
#!/bin/bash
|
|
240
|
+
echo "Setting up worktree at $WTS_WORKTREE_PATH"
|
|
241
|
+
cd "$WTS_WORKTREE_PATH"
|
|
242
|
+
bun install
|
|
243
|
+
cp .env.example .env
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### TypeScript Script (`.wts-setup.ts`)
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
const worktreePath = process.env.WTS_WORKTREE_PATH;
|
|
250
|
+
console.log(`Setting up worktree at ${worktreePath}`);
|
|
251
|
+
// Run setup logic...
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
The `WTS_WORKTREE_PATH` environment variable is set to the worktree path.
|
|
255
|
+
|
|
256
|
+
## Worktree Naming Convention
|
|
257
|
+
|
|
258
|
+
Worktrees are created with a date-prefixed path:
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
.worktrees/<project>/YYYY-MM-DD-<alias>/
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Example: `.worktrees/my-project/2024-01-08-feature-auth/`
|
|
265
|
+
|
|
266
|
+
This enables:
|
|
267
|
+
- Easy sorting by creation date
|
|
268
|
+
- Automatic cleanup of old worktrees
|
|
269
|
+
- Clear visual organization
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT
|