@zenobius/pi-worktrees 0.0.1 → 0.1.0
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 +245 -18
- package/dist/index.js +14701 -71
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -1,37 +1,264 @@
|
|
|
1
|
-
# pi-worktrees
|
|
1
|
+
# `@zenobius/pi-worktrees`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Git worktree management for [Pi Coding Agent](https://github.com/badlogic/pi-mono) with a clean `/worktree` command surface.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This extension helps you spin up isolated feature workspaces quickly, with safety checks and optional post-create automation.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- Interactive setup for worktree settings
|
|
11
|
-
- Automatic worktree listing, creation, removal, and pruning
|
|
9
|
+
## Why this extension?
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
When you’re doing multiple feature branches, hotfixes, or experiments, `git worktree` is fantastic—but easy to misuse.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
`pi-worktrees` gives you a guided interface inside Pi:
|
|
16
14
|
|
|
15
|
+
- Create feature worktrees with consistent branch naming (`feature/<name>`)
|
|
16
|
+
- List and inspect active worktrees
|
|
17
|
+
- Remove worktrees safely (with confirmations)
|
|
18
|
+
- Prune stale worktree references
|
|
19
|
+
- Configure default worktree location and post-create hook
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
### Global install (all projects)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pi install npm:@zenobius/pi-worktrees
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Project-local install (shared via `.pi/settings.json`)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pi install -l npm:@zenobius/pi-worktrees
|
|
17
35
|
```
|
|
36
|
+
|
|
37
|
+
### Local development install
|
|
38
|
+
|
|
39
|
+
> nothing to do here, it's already defined in `.pi/settings.json#extensions`
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
If Pi is already running, use `/reload` to load newly installed extensions.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Quick start
|
|
48
|
+
|
|
49
|
+
In Pi:
|
|
50
|
+
|
|
51
|
+
```text
|
|
18
52
|
/worktree init
|
|
19
|
-
/worktree create
|
|
53
|
+
/worktree create auth-refactor
|
|
20
54
|
/worktree list
|
|
21
55
|
/worktree status
|
|
22
|
-
/worktree cd
|
|
23
|
-
/worktree remove
|
|
56
|
+
/worktree cd auth-refactor
|
|
57
|
+
/worktree remove auth-refactor
|
|
24
58
|
/worktree prune
|
|
25
59
|
```
|
|
26
60
|
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Command reference
|
|
64
|
+
|
|
65
|
+
| Command | Description |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `/worktree init` | Interactive setup for extension settings |
|
|
68
|
+
| `/worktree settings` | Show all current settings |
|
|
69
|
+
| `/worktree settings <key>` | Get one setting (`parentDir`, `onCreate`) |
|
|
70
|
+
| `/worktree settings <key> <value>` | Set one setting |
|
|
71
|
+
| `/worktree create <feature-name>` | Create a new worktree + branch `feature/<feature-name>` |
|
|
72
|
+
| `/worktree list` | List all worktrees (`/worktree ls` alias) |
|
|
73
|
+
| `/worktree status` | Show current repo/worktree status |
|
|
74
|
+
| `/worktree cd <name>` | Print matching worktree path |
|
|
75
|
+
| `/worktree remove <name>` | Remove a worktree (`/worktree rm` alias) |
|
|
76
|
+
| `/worktree prune` | Remove stale worktree metadata |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Configuration
|
|
81
|
+
|
|
82
|
+
Settings live in `~/.pi/agent/pi-worktrees-settings.json` under `worktree`:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"worktree": {
|
|
87
|
+
"parentDir": "~/.local/share/worktrees/{{project}}",
|
|
88
|
+
"onCreate": "mise setup"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `parentDir`
|
|
94
|
+
|
|
95
|
+
Where new worktrees are created.
|
|
96
|
+
|
|
97
|
+
- **Default**: `../<project>.worktrees/` (relative to your main worktree)
|
|
98
|
+
- Supports template variables
|
|
99
|
+
|
|
100
|
+
### `onCreate`
|
|
101
|
+
|
|
102
|
+
Optional command run **after** successful worktree creation, in the new worktree directory.
|
|
103
|
+
|
|
104
|
+
Useful examples:
|
|
105
|
+
|
|
106
|
+
- `mise setup`
|
|
107
|
+
- `bun install`
|
|
108
|
+
- `mise setup && bun install`
|
|
109
|
+
|
|
110
|
+
### Template variables
|
|
111
|
+
|
|
112
|
+
Available in `parentDir` and `onCreate` strings:
|
|
113
|
+
|
|
114
|
+
- `{{path}}` → created worktree path
|
|
115
|
+
- `{{name}}` → feature/worktree name
|
|
116
|
+
- `{{branch}}` → created branch name
|
|
117
|
+
- `{{project}}` → repository name
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## ASCII state machine (extension behavior)
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
[Idle]
|
|
125
|
+
|
|
|
126
|
+
v
|
|
127
|
+
[/worktree <cmd>]
|
|
128
|
+
|
|
|
129
|
+
+--> [unknown/empty] --------------------------> [Show help] --> [Idle]
|
|
130
|
+
|
|
|
131
|
+
+--> [init] --> [has UI?]
|
|
132
|
+
| |no
|
|
133
|
+
| v
|
|
134
|
+
| [Error] -----------------------> [Idle]
|
|
135
|
+
| |
|
|
136
|
+
| yes
|
|
137
|
+
| v
|
|
138
|
+
| [Prompt for settings]
|
|
139
|
+
| |
|
|
140
|
+
| [Confirm save?] --no---------------> [Cancelled] --> [Idle]
|
|
141
|
+
| |
|
|
142
|
+
| yes
|
|
143
|
+
| v
|
|
144
|
+
| [Save settings] -----------------> [Idle]
|
|
145
|
+
|
|
|
146
|
+
+--> [create <name>] --> [Validate repo/name/branch/path]
|
|
147
|
+
| |fail
|
|
148
|
+
| v
|
|
149
|
+
| [Error] -------------> [Idle]
|
|
150
|
+
| |
|
|
151
|
+
| pass
|
|
152
|
+
| v
|
|
153
|
+
| [git worktree add -b feature/<name>]
|
|
154
|
+
| |fail
|
|
155
|
+
| v
|
|
156
|
+
| [Error] -------------> [Idle]
|
|
157
|
+
| |
|
|
158
|
+
| pass
|
|
159
|
+
| v
|
|
160
|
+
| [Run onCreate hook?]
|
|
161
|
+
| |no
|
|
162
|
+
| v
|
|
163
|
+
| [Success] -----------> [Idle]
|
|
164
|
+
| |
|
|
165
|
+
| yes
|
|
166
|
+
| v
|
|
167
|
+
| [Hook succeeds or fails (non-blocking)]
|
|
168
|
+
| v
|
|
169
|
+
| [Success] -----------> [Idle]
|
|
170
|
+
|
|
|
171
|
+
+--> [remove <name>] --> [Find target + safety checks]
|
|
172
|
+
| |fail
|
|
173
|
+
| v
|
|
174
|
+
| [Error] -------------> [Idle]
|
|
175
|
+
| |
|
|
176
|
+
| pass
|
|
177
|
+
| v
|
|
178
|
+
| [Confirm remove?] --no--> [Cancelled] --> [Idle]
|
|
179
|
+
| |
|
|
180
|
+
| yes
|
|
181
|
+
| v
|
|
182
|
+
| [git worktree remove]
|
|
183
|
+
| |fail (dirty worktree)
|
|
184
|
+
| v
|
|
185
|
+
| [Confirm force?] --no---------> [Cancelled] --> [Idle]
|
|
186
|
+
| |
|
|
187
|
+
| yes
|
|
188
|
+
| v
|
|
189
|
+
| [git worktree remove --force]
|
|
190
|
+
| |fail
|
|
191
|
+
| v
|
|
192
|
+
| [Error] --------------------> [Idle]
|
|
193
|
+
| |
|
|
194
|
+
| pass
|
|
195
|
+
| v
|
|
196
|
+
| [Success] -------------------> [Idle]
|
|
197
|
+
|
|
|
198
|
+
+--> [list | status | cd] ---------------------> [Display info] --> [Idle]
|
|
199
|
+
|
|
|
200
|
+
+--> [prune] --> [dry-run stale refs]
|
|
201
|
+
|none
|
|
202
|
+
v
|
|
203
|
+
[Nothing to do] --------------> [Idle]
|
|
204
|
+
|
|
|
205
|
+
found
|
|
206
|
+
v
|
|
207
|
+
[Confirm prune?] --no----------> [Cancelled] --> [Idle]
|
|
208
|
+
|
|
|
209
|
+
yes
|
|
210
|
+
v
|
|
211
|
+
[git worktree prune]
|
|
212
|
+
|fail
|
|
213
|
+
v
|
|
214
|
+
[Error] ---------------------> [Idle]
|
|
215
|
+
|
|
|
216
|
+
pass
|
|
217
|
+
v
|
|
218
|
+
[Success] --------------------> [Idle]
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Safety behavior
|
|
224
|
+
|
|
225
|
+
- Refuses to run mutating commands outside a git repository
|
|
226
|
+
- Refuses to create if target branch or worktree path already exists
|
|
227
|
+
- Refuses to remove:
|
|
228
|
+
- the main worktree
|
|
229
|
+
- the current worktree
|
|
230
|
+
- Uses confirmation prompts for destructive actions
|
|
231
|
+
- `onCreate` failures are reported but do **not** undo worktree creation
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Troubleshooting
|
|
236
|
+
|
|
237
|
+
### `Not in a git repository`
|
|
238
|
+
Run commands from inside a git repo (or one of its worktrees).
|
|
239
|
+
|
|
240
|
+
### `Branch 'feature/<name>' already exists`
|
|
241
|
+
Choose another feature name or delete/rename the branch.
|
|
242
|
+
|
|
243
|
+
### Can’t remove worktree due to changes
|
|
244
|
+
Use `/worktree remove <name>`, then confirm the force remove prompt.
|
|
245
|
+
|
|
246
|
+
### `cd` does not switch shell directory
|
|
247
|
+
`/worktree cd` prints the path; it does not directly mutate your shell state.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
27
251
|
## Development
|
|
28
252
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
253
|
+
```bash
|
|
254
|
+
mise run build
|
|
255
|
+
mise run test
|
|
256
|
+
mise run lint
|
|
257
|
+
mise run format
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
34
261
|
|
|
35
262
|
## License
|
|
36
263
|
|
|
37
|
-
MIT
|
|
264
|
+
MIT. See [LICENSE](./LICENSE).
|