@maxiaochao/pi-toolkit 0.13.14 → 0.13.15

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 CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2026-10-27 - v0.13.15
2
+
3
+ - worktree v0.4.2: support removing multiple worktrees in order
4
+ - Allow bundled pi-worktree to remove multiple worktrees in one command.
5
+
1
6
  ## 2026-10-26 - v0.13.14
2
7
 
3
8
  - herdr-subagents v0.7.6: Esc in a child waits abortGraceSeconds (default 30) for a correction before publishing child_aborted
package/README.md CHANGED
@@ -108,4 +108,4 @@ The read-only check verifies remote tag commits, waits for the matching `publish
108
108
 
109
109
  ## Safety and evidence boundaries
110
110
 
111
- Cache Export reports provider/Pi usage, not measured server cache state. Main requests and auxiliary calls are separate; missing reasoning or retention remains unknown. Relative paths use the session cwd. Herdr children get at most one missing-report reminder and report unconfirmed outcomes explicitly. Codex Edit preflights path hierarchy conflicts and preserves executable bits on moves. Account-pool transient refresh errors never justify rotation, and delivered output forbids replay. Worktree reuse always returns the worktree root. Browser profile reset requires Chrome to be stopped.
111
+ Cache Export reports provider/Pi usage, not measured server cache state. Main requests and auxiliary calls are separate; missing reasoning or retention remains unknown. Relative paths use the session cwd. Herdr children get at most one missing-report reminder and report unconfirmed outcomes explicitly. Codex Edit preflights path hierarchy conflicts and preserves executable bits on moves. Account-pool transient refresh errors never justify rotation, and delivered output forbids replay. Worktree reuse always returns the worktree root; `pi-worktree remove` accepts multiple names. Browser profile reset requires Chrome to be stopped.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxiaochao/pi-toolkit",
3
- "version": "0.13.14",
3
+ "version": "0.13.15",
4
4
  "description": "Personal pi coding agent toolkit: background tasks, scheduler, /btw, /cache_export, apply_patch, browser automation, and bundled theme/skills.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -1,5 +1,10 @@
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
+
3
8
  ## 2026-10-23 - v0.4.1
4
9
 
5
10
  - return the worktree root from already-active nested directories
@@ -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,12 +65,14 @@ 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)。
75
77
 
76
78
  ## Already-active paths
@@ -19,6 +19,7 @@
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
  ## 最近验证结果
@@ -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> # remove worktree <name> (must be clean & merged)
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
- [[ $# -eq 1 ]] || die "usage: pi-worktree -r <name>"
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
@@ -23,9 +23,11 @@ _pi_worktree() {
23
23
  fi
24
24
 
25
25
  case "$first" in
26
- -i|--info|info|-r|--remove|remove|rm|create)
27
- # only the second word of info/remove completes worktree names;
28
- # later words offer nothing (info/remove take no further args)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxiaochao/pi-worktree",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Git worktree CLI, Pi extension, and skill for isolated coding tasks.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -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>` | Remove the worktree and its branch; asks before discarding dirty files or unmerged commits. |
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
@@ -127,6 +127,49 @@ mkdir "$ROOT/symlink-repo" "$ROOT/outside-worktrees"
127
127
  )
128
128
 
129
129
  bash "$PACKAGE_DIR/bin/pi-worktree" --help | grep -q 'pi-worktree create'
130
+ bash "$PACKAGE_DIR/bin/pi-worktree" remove feature attachable
131
+ test ! -d .worktrees/feature && test ! -d .worktrees/attachable
132
+ ! git show-ref --verify --quiet refs/heads/feature
133
+ ! git show-ref --verify --quiet refs/heads/attachable
134
+
135
+ bash "$PACKAGE_DIR/bin/pi-worktree" create --json batch-dirty >/dev/null
136
+ bash "$PACKAGE_DIR/bin/pi-worktree" create --json batch-later >/dev/null
137
+ echo dirty >> .worktrees/batch-dirty/tracked.txt
138
+ if printf 'n\n' | bash "$PACKAGE_DIR/bin/pi-worktree" rm batch-dirty batch-later; then
139
+ echo "remove ignored a declined confirmation" >&2
140
+ exit 1
141
+ fi
142
+ test -d .worktrees/batch-dirty && test -d .worktrees/batch-later
143
+ printf 'y\n' | bash "$PACKAGE_DIR/bin/pi-worktree" -r batch-dirty batch-later
144
+ test ! -d .worktrees/batch-dirty && test ! -d .worktrees/batch-later
145
+
146
+ bash "$PACKAGE_DIR/bin/pi-worktree" create --json batch-first >/dev/null
147
+ bash "$PACKAGE_DIR/bin/pi-worktree" create --json batch-last >/dev/null
148
+ if bash "$PACKAGE_DIR/bin/pi-worktree" --remove batch-first missing-name batch-last; then
149
+ echo "remove ignored a missing worktree" >&2
150
+ exit 1
151
+ fi
152
+ test ! -d .worktrees/batch-first && test -d .worktrees/batch-last
153
+ bash "$PACKAGE_DIR/bin/pi-worktree" create --json batch-unmerged >/dev/null
154
+ git -C .worktrees/batch-unmerged commit --allow-empty -qm unmerged
155
+ if printf 'n\n' | bash "$PACKAGE_DIR/bin/pi-worktree" remove batch-unmerged batch-last; then
156
+ echo "remove ignored an unmerged branch confirmation" >&2
157
+ exit 1
158
+ fi
159
+ test -d .worktrees/batch-unmerged && test -d .worktrees/batch-last
160
+ printf 'y\n' | bash "$PACKAGE_DIR/bin/pi-worktree" remove batch-unmerged batch-last
161
+ ! git show-ref --verify --quiet refs/heads/batch-unmerged
162
+ test ! -d .worktrees/batch-last
163
+
164
+ if bash "$PACKAGE_DIR/bin/pi-worktree" remove >/dev/null 2>&1; then
165
+ echo "remove accepted no names" >&2
166
+ exit 1
167
+ fi
168
+ source "$PACKAGE_DIR/bin/pi-worktree-completion.bash"
169
+ COMP_WORDS=(pi-worktree remove prepared f)
170
+ COMP_CWORD=3
171
+ _pi_worktree
172
+ [[ " ${COMPREPLY[*]} " == *" from-subdir "* ]]
130
173
  if bash "$PACKAGE_DIR/bin/pi-worktree" prepare feature >/dev/null 2>&1; then
131
174
  echo "removed prepare command is still accepted" >&2
132
175
  exit 1