@fatdoge/wtree 0.1.10 → 0.2.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.en.md +66 -1
- package/README.md +60 -1
- package/api/cli/wtree.ts +248 -78
- package/dist-node/api/cli/wtree.js +266 -81
- package/dist-node/api/cli/wtui.js +0 -0
- package/package.json +16 -15
- package/skills/wtree/SKILL.md +162 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wtree
|
|
3
|
+
description: "Manage git worktrees using the wtree CLI. Use when the user wants to create, list, delete, open, lock, unlock, or prune git worktrees, or work with multiple branches simultaneously."
|
|
4
|
+
allowed-tools: Bash
|
|
5
|
+
user-invocable: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# wtree - Git Worktree Manager
|
|
9
|
+
|
|
10
|
+
You manage git worktrees using the `wtree` CLI tool. Always use non-interactive flags so commands complete without user input.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
The `wtree` CLI must be installed globally (`npm install -g @fatdoge/wtree`) or run via `npx @fatdoge/wtree`. If working inside the wtree project itself, use `node dist-node/api/cli/wtree.js`.
|
|
15
|
+
|
|
16
|
+
## Important Rules
|
|
17
|
+
|
|
18
|
+
1. **Always use `--json` flag** when you need to parse output programmatically
|
|
19
|
+
2. **Always use `--yes`** to skip all confirmation prompts
|
|
20
|
+
3. **Always use `--no-editor`** unless the user explicitly asks to open an editor
|
|
21
|
+
4. **Always use `--no-install`** unless the user explicitly asks to install dependencies
|
|
22
|
+
5. **Use `--repo <path>`** if the current working directory is not inside the target git repository
|
|
23
|
+
6. **Never run `wtree` without a subcommand** — that enters interactive mode
|
|
24
|
+
|
|
25
|
+
## Commands Reference
|
|
26
|
+
|
|
27
|
+
### List Worktrees
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
wtree list --json
|
|
31
|
+
# With specific repo:
|
|
32
|
+
wtree list --json --repo /path/to/repo
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Returns a JSON array of worktree objects:
|
|
36
|
+
```json
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
"id": "<base64url-encoded-path>",
|
|
40
|
+
"path": "/absolute/path/to/worktree",
|
|
41
|
+
"head": "<commit-sha>",
|
|
42
|
+
"branch": "branch-name",
|
|
43
|
+
"isMain": true,
|
|
44
|
+
"isLocked": false
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Create Worktree
|
|
50
|
+
|
|
51
|
+
For an **existing** local or remote branch:
|
|
52
|
+
```bash
|
|
53
|
+
wtree create <branch-name> --yes --no-editor --no-install --json
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For a **new branch** based on a reference:
|
|
57
|
+
```bash
|
|
58
|
+
wtree create <new-branch-name> --base <base-ref> --yes --no-editor --no-install --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
With a specific target directory:
|
|
62
|
+
```bash
|
|
63
|
+
wtree create <branch> --dir <relative-path> --yes --no-editor --no-install --json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
- `<branch-name>` (positional, required): The branch to check out or create
|
|
68
|
+
- `--dir <path>`: Worktree directory, relative to repo root (default: `worktrees/<branch-sanitized>`)
|
|
69
|
+
- `--base <ref>`: Base reference for new branch creation (e.g., `main`, `origin/main`)
|
|
70
|
+
- `--yes`: Auto-confirm new branch creation and accept default directory
|
|
71
|
+
- `--editor <name>`: Open in specific editor after creation (`trae`, `cursor`, `code`)
|
|
72
|
+
- `--no-editor`: Do not open any editor
|
|
73
|
+
- `--no-install`: Skip automatic dependency installation
|
|
74
|
+
- `--json`: Output result as JSON
|
|
75
|
+
|
|
76
|
+
Returns on success:
|
|
77
|
+
```json
|
|
78
|
+
{"ok": true, "data": {"id": "...", "path": "...", "head": "...", "branch": "...", "isMain": false, "isLocked": false}}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Delete Worktree
|
|
82
|
+
|
|
83
|
+
Delete one or more worktrees by branch name or path:
|
|
84
|
+
```bash
|
|
85
|
+
wtree delete <branch-or-path> --yes --json
|
|
86
|
+
wtree delete <branch1> <branch2> --yes --json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Force delete (even with uncommitted changes):
|
|
90
|
+
```bash
|
|
91
|
+
wtree delete <branch> --yes --force --json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Parameters:
|
|
95
|
+
- Positional args: Worktree identifiers (branch name, path, or directory basename)
|
|
96
|
+
- `--yes`: Skip deletion confirmation
|
|
97
|
+
- `--force`: Force-delete even if there are uncommitted changes
|
|
98
|
+
- `--json`: Output result as JSON
|
|
99
|
+
|
|
100
|
+
### Open Worktree
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
wtree open <branch-or-path>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Opens the worktree directory in the system file manager.
|
|
107
|
+
|
|
108
|
+
### Lock / Unlock Worktree
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
wtree lock <branch-or-path>
|
|
112
|
+
wtree unlock <branch-or-path>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Prune Invalid Worktrees
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
wtree prune
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Removes worktree records for directories that no longer exist.
|
|
122
|
+
|
|
123
|
+
### Configuration
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
wtree config # Show all config as JSON
|
|
127
|
+
wtree config get <key> # Get a single config value
|
|
128
|
+
wtree config set <key> <value> # Set a config value
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Available config keys: `baseDir`, `openCommand`, `editorCommand`
|
|
132
|
+
|
|
133
|
+
## Workflow Examples
|
|
134
|
+
|
|
135
|
+
### Create a worktree for a new feature branch
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# 1. List existing worktrees
|
|
139
|
+
wtree list --json
|
|
140
|
+
|
|
141
|
+
# 2. Create worktree with new branch from main
|
|
142
|
+
wtree create feature/my-feature --base main --yes --no-editor --no-install --json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Clean up old worktrees
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# 1. List all worktrees
|
|
149
|
+
wtree list --json
|
|
150
|
+
|
|
151
|
+
# 2. Delete unwanted ones
|
|
152
|
+
wtree delete feature/old-branch --yes --json
|
|
153
|
+
|
|
154
|
+
# 3. Prune stale records
|
|
155
|
+
wtree prune
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Create worktree for an existing remote branch
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
wtree create feature/existing-branch --yes --no-editor --no-install --json
|
|
162
|
+
```
|