@zenobius/pi-worktrees 0.1.0 → 0.2.0-next.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 +159 -13
- package/dist/cmds/cmdCd.d.ts +3 -0
- package/dist/cmds/cmdCreate.d.ts +3 -0
- package/dist/cmds/cmdInit.d.ts +3 -0
- package/dist/cmds/cmdList.d.ts +2 -0
- package/dist/cmds/cmdPrune.d.ts +2 -0
- package/dist/cmds/cmdRemove.d.ts +3 -0
- package/dist/cmds/cmdSettings.d.ts +3 -0
- package/dist/cmds/cmdStatus.d.ts +2 -0
- package/dist/cmds/cmdTemplates.d.ts +3 -0
- package/dist/cmds/shared.d.ts +26 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1296 -14978
- package/dist/services/completions.d.ts +4 -0
- package/dist/services/config/config.d.ts +104 -0
- package/dist/services/config/migrations/01-flat-single.d.ts +2 -0
- package/dist/services/config/migrations/02-worktree-to-worktrees.d.ts +2 -0
- package/dist/services/config/migrations/03-parentDir-to-worktreeRoot.d.ts +2 -0
- package/dist/services/config/migrations/04-oncreate-display-output-max-lines.d.ts +2 -0
- package/dist/services/config/migrations/05-oncreate-command-display-format.d.ts +2 -0
- package/dist/services/config/schema.d.ts +32 -0
- package/dist/services/git.d.ts +83 -0
- package/dist/services/glob.d.ts +1 -0
- package/dist/services/templates.d.ts +8 -0
- package/dist/types.d.ts +15 -0
- package/dist/ui/templatePreview.d.ts +21 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# `@zenobius/pi-worktrees`
|
|
2
2
|
|
|
3
|
+
<img width="1531" height="1172" alt="image" src="https://github.com/user-attachments/assets/33fe4c01-4d9b-41ec-a326-116db6e750df" />
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
Git worktree management for [Pi Coding Agent](https://github.com/badlogic/pi-mono) with a clean `/worktree` command surface.
|
|
4
7
|
|
|
5
8
|
This extension helps you spin up isolated feature workspaces quickly, with safety checks and optional post-create automation.
|
|
@@ -44,6 +47,28 @@ If Pi is already running, use `/reload` to load newly installed extensions.
|
|
|
44
47
|
|
|
45
48
|
---
|
|
46
49
|
|
|
50
|
+
## Getting started in 2 minutes
|
|
51
|
+
|
|
52
|
+
1. Install the extension:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pi install npm:@zenobius/pi-worktrees
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
2. Open a git repo in Pi and run:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
/worktree init
|
|
62
|
+
/worktree create auth-refactor
|
|
63
|
+
/worktree list
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. Optional: jump into it from your shell using the printed path:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
/worktree cd auth-refactor
|
|
70
|
+
```
|
|
71
|
+
|
|
47
72
|
## Quick start
|
|
48
73
|
|
|
49
74
|
In Pi:
|
|
@@ -58,6 +83,27 @@ In Pi:
|
|
|
58
83
|
/worktree prune
|
|
59
84
|
```
|
|
60
85
|
|
|
86
|
+
### Example: How I use `/worktree`
|
|
87
|
+
|
|
88
|
+
I use Neovim and Zellij, and I want each new worktree to boot a ready-to-code workspace. My `onCreate` looks like:
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"worktrees": {
|
|
92
|
+
"**": {
|
|
93
|
+
"worktreeRoot": "{{mainWorktree}}.worktrees",
|
|
94
|
+
"onCreate": [
|
|
95
|
+
"mise trust --yes",
|
|
96
|
+
"mise setup",
|
|
97
|
+
"zellij action new-tab --name {{name}} --cwd {{path}}",
|
|
98
|
+
"zellij action new-pane --in-place --cwd {{path}} -- nvim",
|
|
99
|
+
"zellij action new-pane --cwd {{path}} --direction right -- pi"
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This creates a new Zellij tab with Neovim and Pi running in the new worktree path.
|
|
61
107
|
---
|
|
62
108
|
|
|
63
109
|
## Command reference
|
|
@@ -66,7 +112,7 @@ In Pi:
|
|
|
66
112
|
|---|---|
|
|
67
113
|
| `/worktree init` | Interactive setup for extension settings |
|
|
68
114
|
| `/worktree settings` | Show all current settings |
|
|
69
|
-
| `/worktree settings <key>` | Get one setting (`
|
|
115
|
+
| `/worktree settings <key>` | Get one setting (`worktreeRoot`, `parentDir` alias, `onCreate`) |
|
|
70
116
|
| `/worktree settings <key> <value>` | Set one setting |
|
|
71
117
|
| `/worktree create <feature-name>` | Create a new worktree + branch `feature/<feature-name>` |
|
|
72
118
|
| `/worktree list` | List all worktrees (`/worktree ls` alias) |
|
|
@@ -74,47 +120,147 @@ In Pi:
|
|
|
74
120
|
| `/worktree cd <name>` | Print matching worktree path |
|
|
75
121
|
| `/worktree remove <name>` | Remove a worktree (`/worktree rm` alias) |
|
|
76
122
|
| `/worktree prune` | Remove stale worktree metadata |
|
|
123
|
+
| `/worktree templates` | Preview template variables with current + generated values |
|
|
77
124
|
|
|
78
125
|
---
|
|
79
126
|
|
|
80
127
|
## Configuration
|
|
81
128
|
|
|
82
|
-
Settings live in `~/.pi/agent/pi-worktrees-settings.json
|
|
129
|
+
Settings live in `~/.pi/agent/pi-worktrees-settings.json`.
|
|
83
130
|
|
|
84
131
|
```json
|
|
85
132
|
{
|
|
133
|
+
"worktrees": {
|
|
134
|
+
"github.com/org/repo": {
|
|
135
|
+
"worktreeRoot": "~/work/org/repo.worktrees",
|
|
136
|
+
"onCreate": ["mise install", "bun install"]
|
|
137
|
+
},
|
|
138
|
+
"github.com/org/*": {
|
|
139
|
+
"worktreeRoot": "~/work/org/shared.worktrees",
|
|
140
|
+
"onCreate": "mise setup"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"matchingStrategy": "fail-on-tie",
|
|
144
|
+
"onCreateDisplayOutputMaxLines": 5,
|
|
145
|
+
"onCreateCmdDisplayPending": "[ ] {{cmd}}",
|
|
146
|
+
"onCreateCmdDisplaySuccess": "[x] {{cmd}}",
|
|
147
|
+
"onCreateCmdDisplayError": "[ ] {{cmd}} [ERROR]",
|
|
148
|
+
"onCreateCmdDisplayPendingColor": "dim",
|
|
149
|
+
"onCreateCmdDisplaySuccessColor": "success",
|
|
150
|
+
"onCreateCmdDisplayErrorColor": "error",
|
|
86
151
|
"worktree": {
|
|
87
|
-
"
|
|
152
|
+
"worktreeRoot": "~/.local/share/worktrees/{{project}}",
|
|
88
153
|
"onCreate": "mise setup"
|
|
89
154
|
}
|
|
90
155
|
}
|
|
91
156
|
```
|
|
92
157
|
|
|
93
|
-
###
|
|
158
|
+
### Configuration reference
|
|
94
159
|
|
|
95
|
-
|
|
160
|
+
| Key | Type | Default | Description |
|
|
161
|
+
|---|---|---|---|
|
|
162
|
+
| `worktrees` | `Record<string, WorktreeSettings>` | `{}` | Pattern-matched settings by repo URL or glob. |
|
|
163
|
+
| `matchingStrategy` | `'fail-on-tie' \| 'first-wins' \| 'last-wins'` | `fail-on-tie` | Tie-break behavior for equally specific patterns. |
|
|
164
|
+
| `onCreateDisplayOutputMaxLines` | `number` (integer, `>= 0`) | `5` | Number of latest stdout/stderr lines shown in live UI updates during `onCreate`. |
|
|
165
|
+
| `onCreateCmdDisplayPending` | `string` | `[ ] {{cmd}}` | Template for pending/running command display lines. |
|
|
166
|
+
| `onCreateCmdDisplaySuccess` | `string` | `[x] {{cmd}}` | Template for successful command display lines. |
|
|
167
|
+
| `onCreateCmdDisplayError` | `string` | `[ ] {{cmd}} [ERROR]` | Template for failed command display lines. |
|
|
168
|
+
| `onCreateCmdDisplayPendingColor` | `string` | `dim` | Pi theme color name for pending/running command lines. |
|
|
169
|
+
| `onCreateCmdDisplaySuccessColor` | `string` | `success` | Pi theme color name for successful command lines. |
|
|
170
|
+
| `onCreateCmdDisplayErrorColor` | `string` | `error` | Pi theme color name for failed command lines. |
|
|
171
|
+
| `worktree` (legacy) | `WorktreeSettings` | n/a | Legacy fallback shape; migrated automatically. |
|
|
96
172
|
|
|
97
|
-
|
|
98
|
-
|
|
173
|
+
### Matching model
|
|
174
|
+
|
|
175
|
+
For the current repository, settings are resolved in this order:
|
|
176
|
+
|
|
177
|
+
1. Exact URL match in `worktrees`
|
|
178
|
+
2. Most-specific glob match in `worktrees`
|
|
179
|
+
3. Fallback to legacy `worktree`
|
|
180
|
+
|
|
181
|
+
`matchingStrategy` controls ties between equally specific patterns:
|
|
182
|
+
|
|
183
|
+
- `fail-on-tie` (default)
|
|
184
|
+
- `first-wins`
|
|
185
|
+
- `last-wins`
|
|
99
186
|
|
|
100
187
|
### `onCreate`
|
|
101
188
|
|
|
102
|
-
|
|
189
|
+
`onCreate` accepts either:
|
|
190
|
+
|
|
191
|
+
- a single string command
|
|
192
|
+
- an array of commands
|
|
193
|
+
|
|
194
|
+
When an array is used, commands run sequentially and stop on first failure.
|
|
195
|
+
|
|
196
|
+
### `onCreateDisplayOutputMaxLines`
|
|
197
|
+
|
|
198
|
+
Controls only live UI output verbosity for `onCreate` command execution.
|
|
199
|
+
- **Default**: `5`
|
|
200
|
+
- **Scope**: display only
|
|
201
|
+
- **Does not affect**: logfile contents (full stdout/stderr is still logged)
|
|
202
|
+
|
|
203
|
+
### `onCreate` command line display templates
|
|
103
204
|
|
|
104
|
-
|
|
205
|
+
These templates control how each command line is rendered in the live progress list.
|
|
105
206
|
|
|
106
|
-
- `
|
|
107
|
-
- `
|
|
108
|
-
- `
|
|
207
|
+
- `onCreateCmdDisplayPending` (default: `[ ] {{cmd}}`)
|
|
208
|
+
- `onCreateCmdDisplaySuccess` (default: `[x] {{cmd}}`)
|
|
209
|
+
- `onCreateCmdDisplayError` (default: `[ ] {{cmd}} [ERROR]`)
|
|
109
210
|
|
|
211
|
+
Supported token:
|
|
212
|
+
- `{{cmd}}` (or `{cmd}`) → expanded command string
|
|
213
|
+
|
|
214
|
+
### `onCreate` command line display colors
|
|
215
|
+
|
|
216
|
+
These settings use Pi theme color names:
|
|
217
|
+
|
|
218
|
+
- `onCreateCmdDisplayPendingColor` (default: `dim`)
|
|
219
|
+
- `onCreateCmdDisplaySuccessColor` (default: `success`)
|
|
220
|
+
- `onCreateCmdDisplayErrorColor` (default: `error`)
|
|
221
|
+
|
|
222
|
+
Supported color names in this extension: `dim`, `accent`, `info`, `success`, `warning`, `error`.
|
|
223
|
+
|
|
224
|
+
### `worktreeRoot`
|
|
225
|
+
|
|
226
|
+
Where new worktrees are created.
|
|
227
|
+
|
|
228
|
+
- **Default**: `{{mainWorktree}}.worktrees`
|
|
229
|
+
- Supports template variables
|
|
230
|
+
|
|
231
|
+
> Backward compatibility: `parentDir` is still accepted as a deprecated alias for `worktreeRoot`.
|
|
232
|
+
> The extension will migrate existing `parentDir` values to `worktreeRoot` automatically.
|
|
110
233
|
### Template variables
|
|
111
234
|
|
|
112
|
-
Available in `
|
|
235
|
+
Available in `worktreeRoot` and `onCreate` values:
|
|
113
236
|
|
|
114
237
|
- `{{path}}` → created worktree path
|
|
115
238
|
- `{{name}}` → feature/worktree name
|
|
116
239
|
- `{{branch}}` → created branch name
|
|
117
240
|
- `{{project}}` → repository name
|
|
241
|
+
- `{{mainWorktree}}` → main worktree path (repository root)
|
|
242
|
+
|
|
243
|
+
### Migration note
|
|
244
|
+
|
|
245
|
+
Legacy single-worktree config remains supported and is migrated through the shared
|
|
246
|
+
`@zenobius/pi-extension-config` migration chain.
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"worktree": {
|
|
250
|
+
"worktreeRoot": "...",
|
|
251
|
+
"onCreate": "..."
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Migration behavior:
|
|
257
|
+
|
|
258
|
+
1. Legacy flat keys are normalized to `worktree`
|
|
259
|
+
2. Legacy `worktree` is migrated to `worktrees["**"]`
|
|
260
|
+
3. Migration version metadata is managed by `@zenobius/pi-extension-config`
|
|
261
|
+
|
|
262
|
+
Deprecation timing follows the migration policy in `@zenobius/pi-extension-config`.
|
|
263
|
+
This extension does not apply a separate ad-hoc deprecation mechanism.
|
|
118
264
|
|
|
119
265
|
---
|
|
120
266
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WorktreeCreatedContext } from '../types.ts';
|
|
2
|
+
import { WorktreeSettingsConfig } from '../services/config/schema.ts';
|
|
3
|
+
export interface OnCreateResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
executed: string[];
|
|
6
|
+
failed?: {
|
|
7
|
+
command: string;
|
|
8
|
+
code: number;
|
|
9
|
+
error: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface OnCreateHookOptions {
|
|
13
|
+
logPath?: string;
|
|
14
|
+
displayOutputMaxLines?: number;
|
|
15
|
+
cmdDisplayPending?: string;
|
|
16
|
+
cmdDisplaySuccess?: string;
|
|
17
|
+
cmdDisplayError?: string;
|
|
18
|
+
cmdDisplayPendingColor?: string;
|
|
19
|
+
cmdDisplaySuccessColor?: string;
|
|
20
|
+
cmdDisplayErrorColor?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Runs post-create hooks sequentially.
|
|
24
|
+
* Stops at first failure and reports the failing command.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runOnCreateHook(createdCtx: WorktreeCreatedContext, settings: WorktreeSettingsConfig, notify: (msg: string, type: 'info' | 'error' | 'warning') => void, options?: OnCreateHookOptions): Promise<OnCreateResult>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worktree Extension - Git worktree management for isolated workspaces
|
|
3
|
+
*
|
|
4
|
+
* Provides commands to create, list, and manage git worktrees for feature development.
|
|
5
|
+
* Codifies the patterns from the using-git-worktrees skill into an interactive command.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExtensionFactory } from '@mariozechner/pi-coding-agent';
|
|
8
|
+
declare const PiWorktreeExtension: ExtensionFactory;
|
|
9
|
+
export default PiWorktreeExtension;
|