@zenobius/pi-worktrees 0.1.0 → 0.2.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 +89 -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 +19 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1091 -14987
- package/dist/services/config/config.d.ts +62 -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/schema.d.ts +25 -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
|
@@ -58,6 +58,32 @@ In Pi:
|
|
|
58
58
|
/worktree prune
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
### How I use `/worktrees`
|
|
62
|
+
|
|
63
|
+
Since I use nvim and zellij, i want the worktrees I create to be clones of the workspace
|
|
64
|
+
I have for the current one, so to this end, my `onCreate` looks like:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"worktrees": {
|
|
69
|
+
"**": {
|
|
70
|
+
"worktreeRoot": "{{mainWorktree}}.worktrees",
|
|
71
|
+
"onCreate": [
|
|
72
|
+
"mise trust --yes",
|
|
73
|
+
"mise setup",
|
|
74
|
+
"zellij action new-tab --name {{name}} --cwd {{path}}",
|
|
75
|
+
"zellij action new-pane --in-place --cwd {{path}} -- nvim",
|
|
76
|
+
"zellij action new-pane --cwd {{path}} --direction right -- pi"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This means when ever i create a new worktree, it creates a new zellij tab with nvim and pi running
|
|
85
|
+
in it on the new worktree path.
|
|
86
|
+
|
|
61
87
|
---
|
|
62
88
|
|
|
63
89
|
## Command reference
|
|
@@ -66,7 +92,7 @@ In Pi:
|
|
|
66
92
|
|---|---|
|
|
67
93
|
| `/worktree init` | Interactive setup for extension settings |
|
|
68
94
|
| `/worktree settings` | Show all current settings |
|
|
69
|
-
| `/worktree settings <key>` | Get one setting (`
|
|
95
|
+
| `/worktree settings <key>` | Get one setting (`worktreeRoot`, `onCreate`) |
|
|
70
96
|
| `/worktree settings <key> <value>` | Set one setting |
|
|
71
97
|
| `/worktree create <feature-name>` | Create a new worktree + branch `feature/<feature-name>` |
|
|
72
98
|
| `/worktree list` | List all worktrees (`/worktree ls` alias) |
|
|
@@ -74,47 +100,97 @@ In Pi:
|
|
|
74
100
|
| `/worktree cd <name>` | Print matching worktree path |
|
|
75
101
|
| `/worktree remove <name>` | Remove a worktree (`/worktree rm` alias) |
|
|
76
102
|
| `/worktree prune` | Remove stale worktree metadata |
|
|
103
|
+
| `/worktree templates` | Preview template variables with current + generated values |
|
|
77
104
|
|
|
78
105
|
---
|
|
79
106
|
|
|
80
107
|
## Configuration
|
|
81
108
|
|
|
82
|
-
Settings live in `~/.pi/agent/pi-worktrees-settings.json
|
|
109
|
+
Settings live in `~/.pi/agent/pi-worktrees-settings.json`.
|
|
83
110
|
|
|
84
111
|
```json
|
|
85
112
|
{
|
|
113
|
+
"worktrees": {
|
|
114
|
+
"github.com/org/repo": {
|
|
115
|
+
"worktreeRoot": "~/work/org/repo.worktrees",
|
|
116
|
+
"onCreate": ["mise install", "bun install"]
|
|
117
|
+
},
|
|
118
|
+
"github.com/org/*": {
|
|
119
|
+
"worktreeRoot": "~/work/org/shared.worktrees",
|
|
120
|
+
"onCreate": "mise setup"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"matchingStrategy": "fail-on-tie",
|
|
86
124
|
"worktree": {
|
|
87
|
-
"
|
|
125
|
+
"worktreeRoot": "~/.local/share/worktrees/{{project}}",
|
|
88
126
|
"onCreate": "mise setup"
|
|
89
127
|
}
|
|
90
128
|
}
|
|
91
129
|
```
|
|
92
130
|
|
|
93
|
-
###
|
|
131
|
+
### Matching model
|
|
94
132
|
|
|
95
|
-
|
|
133
|
+
For the current repository, settings are resolved in this order:
|
|
96
134
|
|
|
97
|
-
|
|
98
|
-
-
|
|
135
|
+
1. Exact URL match in `worktrees`
|
|
136
|
+
2. Most-specific glob match in `worktrees`
|
|
137
|
+
3. Fallback to legacy `worktree`
|
|
138
|
+
|
|
139
|
+
`matchingStrategy` controls ties between equally specific patterns:
|
|
140
|
+
|
|
141
|
+
- `fail-on-tie` (default)
|
|
142
|
+
- `first-wins`
|
|
143
|
+
- `last-wins`
|
|
99
144
|
|
|
100
145
|
### `onCreate`
|
|
101
146
|
|
|
102
|
-
|
|
147
|
+
`onCreate` accepts either:
|
|
148
|
+
|
|
149
|
+
- a single string command
|
|
150
|
+
- an array of commands
|
|
103
151
|
|
|
104
|
-
|
|
152
|
+
When an array is used, commands run sequentially and stop on first failure.
|
|
105
153
|
|
|
106
|
-
|
|
107
|
-
- `bun install`
|
|
108
|
-
- `mise setup && bun install`
|
|
154
|
+
### `worktreeRoot`
|
|
109
155
|
|
|
156
|
+
Where new worktrees are created.
|
|
157
|
+
|
|
158
|
+
- **Default**: `{{mainWorktree}}.worktrees`
|
|
159
|
+
- Supports template variables
|
|
160
|
+
|
|
161
|
+
> Backward compatibility: `parentDir` is still accepted as a deprecated alias for `worktreeRoot`.
|
|
162
|
+
> The extension will migrate existing `parentDir` values to `worktreeRoot` automatically.
|
|
110
163
|
### Template variables
|
|
111
164
|
|
|
112
|
-
Available in `
|
|
165
|
+
Available in `worktreeRoot` and `onCreate` values:
|
|
113
166
|
|
|
114
167
|
- `{{path}}` → created worktree path
|
|
115
168
|
- `{{name}}` → feature/worktree name
|
|
116
169
|
- `{{branch}}` → created branch name
|
|
117
170
|
- `{{project}}` → repository name
|
|
171
|
+
- `{{mainWorktree}}` → main worktree path (repository root)
|
|
172
|
+
|
|
173
|
+
### Migration note
|
|
174
|
+
|
|
175
|
+
Legacy single-worktree config remains supported and is migrated through the shared
|
|
176
|
+
`@zenobius/pi-extension-config` migration chain.
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"worktree": {
|
|
180
|
+
"worktreeRoot": "...",
|
|
181
|
+
"onCreate": "..."
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Migration behavior:
|
|
187
|
+
|
|
188
|
+
1. Legacy flat keys are normalized to `worktree`
|
|
189
|
+
2. Legacy `worktree` is migrated to `worktrees["**"]`
|
|
190
|
+
3. Migration version metadata is managed by `@zenobius/pi-extension-config`
|
|
191
|
+
|
|
192
|
+
Deprecation timing follows the migration policy in `@zenobius/pi-extension-config`.
|
|
193
|
+
This extension does not apply a separate ad-hoc deprecation mechanism.
|
|
118
194
|
|
|
119
195
|
---
|
|
120
196
|
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Runs post-create hooks sequentially.
|
|
17
|
+
* Stops at first failure and reports the failing command.
|
|
18
|
+
*/
|
|
19
|
+
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;
|