@maxiaochao/pi-worktree 0.4.0 → 0.4.2
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/CHANGELOG.md +10 -0
- package/README.md +8 -2
- package/TESTING.md +5 -0
- package/bin/pi-worktree +10 -3
- package/bin/pi-worktree-completion.bash +5 -3
- package/package.json +1 -1
- package/skills/pi-worktree/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-10-27 - v0.4.2
|
|
4
|
+
|
|
5
|
+
- support removing multiple worktrees in order
|
|
6
|
+
- Allow removing multiple worktrees in order, retaining individual safety confirmations and stopping on failure.
|
|
7
|
+
|
|
8
|
+
## 2026-10-23 - v0.4.1
|
|
9
|
+
|
|
10
|
+
- return the worktree root from already-active nested directories
|
|
11
|
+
- Return Git's canonical worktree root for already-active create calls made from a nested directory; preserve the dirty flag.
|
|
12
|
+
|
|
3
13
|
## 2026-10-12 - v0.4.0
|
|
4
14
|
|
|
5
15
|
- Replace CLI start and prepare with the create-only command
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ pi-worktree create feature
|
|
|
17
17
|
pi-worktree create --base main --json feature
|
|
18
18
|
pi-worktree info feature
|
|
19
19
|
pi-worktree out
|
|
20
|
-
pi-worktree remove feature
|
|
20
|
+
pi-worktree remove feature another-feature
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
`create` 从当前分支(或显式 `--base`)创建或复用 `.worktrees/feature` 并记录 base,不启动 Pi。`--json` 提供相同操作的机器可读结果。
|
|
@@ -65,10 +65,16 @@ pi-worktree create [--base <ref>] [--json] <name>
|
|
|
65
65
|
pi-worktree list
|
|
66
66
|
pi-worktree info <name>
|
|
67
67
|
pi-worktree out
|
|
68
|
-
pi-worktree remove <name>
|
|
68
|
+
pi-worktree remove <name> [<name> ...]
|
|
69
69
|
pi-worktree prune
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
`create` 是幂等接口;`create --json` 供 Extension 和其他宿主使用,返回 `created`、`attached`、`reused` 或 `already-active`,以及绝对路径、分支和 dirty 状态。已有 worktree 会复用;已存在但未挂载的同名分支会挂载;stale 注册、非法名称和路径冲突会显式失败。
|
|
73
73
|
|
|
74
|
+
`remove` 按顺序删除指定 worktree;每个脏 worktree 或未合并分支仍需单独确认。遇到错误或拒绝确认时停止,已经删除的 worktree 不会恢复。
|
|
75
|
+
|
|
74
76
|
Agent 用法见 `skills/pi-worktree/SKILL.md`。测试流程、夹具和结果见 [TESTING.md](TESTING.md)。
|
|
77
|
+
|
|
78
|
+
## Already-active paths
|
|
79
|
+
|
|
80
|
+
`pi-worktree create --json <current-worktree-name>` returns the canonical Git worktree root, even when called from a nested directory. The `already-active` status and whole-worktree `dirty` flag remain unchanged. The extension uses the same CLI result.
|
package/TESTING.md
CHANGED
|
@@ -19,8 +19,13 @@
|
|
|
19
19
|
- 已删除的 CLI `start` 和 `prepare` 会显式失败。
|
|
20
20
|
- `list` 标记主 checkout 和子 worktree。
|
|
21
21
|
- `info` 报告 clean、branch、base 和 ahead。
|
|
22
|
+
- `remove` 支持多个名称,逐个确认风险;拒绝时停止且保留后续 worktree。补全支持后续名称。
|
|
22
23
|
- postinstall 把可执行 CLI 与 completion 复制到隔离 HOME,并保持执行权限。
|
|
23
24
|
|
|
24
25
|
## 最近验证结果
|
|
25
26
|
|
|
26
27
|
验收要求全部 Node/shell 断言通过,Extension 能被 Pi 单独加载,且 `npm pack --dry-run` 包含 `bin/`、`extensions/`、`skills/` 和 `scripts/install.mjs`。
|
|
28
|
+
|
|
29
|
+
## Review regressions
|
|
30
|
+
|
|
31
|
+
The CLI integration suite also calls `create --json` from a nested linked-worktree directory. It asserts `already-active`, the canonical worktree root, and the whole-worktree dirty flag. Load the extension with `pi -ne -ns --no-session -e ./packages/worktree/extensions/worktree.ts`; this package has no `load-test` npm script.
|
package/bin/pi-worktree
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# pi-worktree -l | --list # list worktrees (main checkout marked "main checkout")
|
|
7
7
|
# pi-worktree -i <name> # show base commit, ahead/behind, unique commits
|
|
8
8
|
# pi-worktree -o | --out # cd back to the main checkout
|
|
9
|
-
# pi-worktree -r <name>
|
|
9
|
+
# pi-worktree -r <name> [<name> ...] # remove worktrees (confirms dirty or unmerged)
|
|
10
10
|
# pi-worktree -p | --prune # drop stale worktree registrations
|
|
11
11
|
set -euo pipefail
|
|
12
12
|
|
|
@@ -150,7 +150,14 @@ cmd_info() {
|
|
|
150
150
|
|
|
151
151
|
cmd_remove() {
|
|
152
152
|
require_repo
|
|
153
|
-
[[ $# -
|
|
153
|
+
[[ $# -ge 1 ]] || die "usage: pi-worktree -r <name> [<name> ...]"
|
|
154
|
+
local name
|
|
155
|
+
for name in "$@"; do
|
|
156
|
+
remove_one "$name"
|
|
157
|
+
done
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
remove_one() {
|
|
154
161
|
local dir; dir="$(wt_dir "$1")"
|
|
155
162
|
local branch registered rm_anyway=0 force=0
|
|
156
163
|
if [[ ! -d "$dir" ]]; then
|
|
@@ -246,7 +253,7 @@ create_wt() {
|
|
|
246
253
|
[[ "$current_branch" == "$name" ]] \
|
|
247
254
|
|| die "already inside linked worktree '$current_branch'; return to the main checkout first"
|
|
248
255
|
CREATE_STATUS="already-active"
|
|
249
|
-
CREATE_DIR=$(pwd -P)
|
|
256
|
+
CREATE_DIR=$(cd "$(git rev-parse --show-toplevel)" && pwd -P)
|
|
250
257
|
CREATE_BRANCH="$current_branch"
|
|
251
258
|
CREATE_DIRTY=false
|
|
252
259
|
if [[ -n "$(git status --porcelain)" ]]; then CREATE_DIRTY=true; fi
|
|
@@ -23,9 +23,11 @@ _pi_worktree() {
|
|
|
23
23
|
fi
|
|
24
24
|
|
|
25
25
|
case "$first" in
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
-r|--remove|remove|rm)
|
|
27
|
+
COMPREPLY=($(compgen -W "$wts" -- "$cur"))
|
|
28
|
+
;;
|
|
29
|
+
-i|--info|info|create)
|
|
30
|
+
# info and create accept one name
|
|
29
31
|
if (( COMP_CWORD == 2 )); then
|
|
30
32
|
COMPREPLY=($(compgen -W "$wts" -- "$cur"))
|
|
31
33
|
else
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ Installed by the package postinstall hook to `~/.local/bin/pi-worktree`, with ba
|
|
|
19
19
|
| `pi-worktree list` | All worktrees; the main checkout is marked `(main checkout)`, stale registrations are flagged. |
|
|
20
20
|
| `pi-worktree info <name>` | Clean/dirty status, branch and HEAD, base commit, ahead/behind `main`, unique commits. |
|
|
21
21
|
| `pi-worktree out` | Open a shell in the main checkout (for merging). |
|
|
22
|
-
| `pi-worktree remove <name
|
|
22
|
+
| `pi-worktree remove <name> [<name> ...]` | Remove worktrees and branches in order; asks before discarding dirty files or unmerged commits. Stops on failure without undoing earlier removals. |
|
|
23
23
|
| `pi-worktree prune` | Drop registrations whose directory was deleted by hand. |
|
|
24
24
|
|
|
25
25
|
## Isolating a task
|