@maxiaochao/pi-toolkit 0.6.1 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2026-09-23 - v0.7.0
2
+
3
+ - bundle the pi-worktree skill documenting the CLI for agents (the isolation loop, and which commands need an interactive terminal); fix pi-worktree: the .gitignore check tested a path form that never matched the directory-only .worktrees/ pattern, so the rule was re-appended on the first run in every repo and that self-inflicted edit then triggered the uncommitted-changes prompt
4
+
1
5
  ## 2026-09-22 - v0.6.1
2
6
 
3
7
  - bundle the pdlog skill for decompressing Pudu .pdlog logs (with bundled ppmd binary)
package/README.md CHANGED
@@ -59,6 +59,8 @@ pi-worktree prune # drop stale registrations for manually deleted dirs
59
59
 
60
60
  Typical loop: `pi-worktree start <name>` to start (Tab completes existing worktree names), commit inside Pi, `pi-worktree out` + `git merge <name>` to land the work, `pi-worktree remove <name>` to clean up. New branches are created from the branch you're currently on (or `HEAD` when detached), and the base commit is recorded in `branch.<name>.base` config so `info` can always tell you where the branch came from. Bash completion covers subcommands and existing worktree names (`pi-worktree feat<Tab>`).
61
61
 
62
+ The bundled `pi-worktree` skill documents the CLI for agents: the `start`/`list`/`info`/`out`/`remove`/`prune` commands, the isolation loop from creating a worktree to landing the merge, and which of those commands need an interactive terminal (so an agent uses `start <name> -p "<task>"` for a headless nested run).
63
+
62
64
  The bundled `web-browser` skill provides reusable scripts for starting Chrome/Chromium with remote debugging, navigating tabs, evaluating JavaScript, emulating devices, taking screenshots, dismissing cookie dialogs, and inspecting browser logs. It auto-detects common Chrome/Chromium installations on macOS and Linux, including Windows Chrome when Pi runs under WSL; set `BROWSER_BIN` when the binary is elsewhere.
63
65
 
64
66
  The browser skill can be loaded explicitly with `/skill:web-browser`. Its scripts are available relative to the skill directory, for example:
package/bin/pi-worktree CHANGED
@@ -63,7 +63,11 @@ resolve_base() {
63
63
  }
64
64
 
65
65
  ensure_gitignore() {
66
- if ! git check-ignore -q .worktrees 2>/dev/null; then
66
+ # The trailing slash is load-bearing: `.worktrees/` is a directory-only
67
+ # pattern, and git check-ignore cannot match it against a path that does not
68
+ # exist yet — so `.worktrees` would look unignored on every first run and the
69
+ # rule would be appended again.
70
+ if ! git check-ignore -q .worktrees/ 2>/dev/null; then
67
71
  printf '.worktrees/\n' >> .gitignore
68
72
  ok "added .worktrees/ to .gitignore"
69
73
  fi
@@ -233,12 +237,12 @@ cd_wt() {
233
237
  fi
234
238
 
235
239
  local dir; dir="$(wt_dir "$name")"
236
- ensure_gitignore
237
240
 
238
241
  if [[ -d "$dir" ]]; then
239
242
  # Reuse: must be a registered worktree for this repo.
240
243
  # Skip the dirty-workspace prompt — the worktree already exists, nothing new to create.
241
244
  git -C "$dir" rev-parse --git-dir >/dev/null 2>&1 || die "$dir exists but is not a git worktree"
245
+ ensure_gitignore
242
246
  ok "reusing existing worktree $dir"
243
247
  else
244
248
  # Dirty workspace: uncommitted changes do NOT follow into the new worktree.
@@ -249,6 +253,9 @@ cd_wt() {
249
253
  [[ "$ans" =~ ^[Yy]$ ]] || die "aborted"
250
254
  fi
251
255
 
256
+ # After the check above, so the tool's own .gitignore edit is not reported
257
+ # as (and does not prompt about) the user's uncommitted work.
258
+ ensure_gitignore
252
259
  mkdir -p .worktrees
253
260
  # Reuse branch if it exists, else create it
254
261
  if git show-ref --verify --quiet "refs/heads/$name"; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxiaochao/pi-toolkit",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Personal pi coding agent toolkit: /todos, /btw, /cache_export extensions, browser automation, and bundled theme/skills.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: pi-worktree
3
+ description: Create, inspect, and clean up git worktrees with the pi-worktree CLI (start/list/info/remove/prune), which also launches Pi inside the worktree. Use when a task warrants isolation in its own worktree, or when the user asks to handle something the worktree way.
4
+ ---
5
+
6
+ # pi-worktree
7
+
8
+ `pi-worktree` wraps git worktree creation and Pi launch into one command. Worktrees live in `.worktrees/<name>` (added to `.gitignore`), each with a branch of the same name, branched from the branch you are on now (or `HEAD` when detached). The base commit is recorded in `branch.<name>.base` / `branch.<name>.baseRef` so `info` can always report where the branch came from.
9
+
10
+ Installed by the package postinstall hook to `~/.local/bin/pi-worktree`, with bash completion for subcommands and existing worktree names.
11
+
12
+ ## Commands
13
+
14
+ | Command | Effect |
15
+ |---|---|
16
+ | `pi-worktree start <name> [pi args...]` | Create or reuse `.worktrees/<name>`, then launch Pi inside it. Already inside a linked worktree, it just launches Pi there. |
17
+ | `pi-worktree start --base <ref> <name> [pi args...]` | Same, but branch from `<ref>` instead of the current branch. |
18
+ | `pi-worktree list` | All worktrees; the main checkout is marked `(main checkout)`, stale registrations are flagged. |
19
+ | `pi-worktree info <name>` | Clean/dirty status, branch and HEAD, base commit, ahead/behind `main`, unique commits. |
20
+ | `pi-worktree out` | Open a shell in the main checkout (for merging). |
21
+ | `pi-worktree remove <name>` | Remove the worktree and its branch; asks before discarding dirty files or unmerged commits. |
22
+ | `pi-worktree prune` | Drop registrations whose directory was deleted by hand. |
23
+
24
+ ## Isolating a task
25
+
26
+ 1. **Survey** — `pi-worktree list`, plus `pi-worktree info <name>` when the name you want is already taken. Reuse is free; a removed worktree is gone for good, because `remove` deletes its branch.
27
+ 2. **Start** — `pi-worktree start <name>` (with `--base <ref>` when the work must not start from the current branch). Done when `list` shows the new worktree on its own branch.
28
+ 3. **Work** — inside the worktree: commit there, and check `pi-worktree info <name>` before claiming progress. `ahead: N commits since base` is the evidence.
29
+ 4. **Land** — `pi-worktree out`, then `git merge <name>` in the main checkout. Done when the worktree's unique commits are in the target branch.
30
+ 5. **Clean up** — `pi-worktree remove <name>`. A merged branch goes without prompting; anything unmerged asks once.
31
+
32
+ ## Driving it from an agent
33
+
34
+ - `start` **execs `pi`** in the worktree, and `out` execs a shell. With no trailing Pi args both want an interactive terminal, so either run `start <name> -p "<task>"` for a headless nested run, or hand the bare `start <name>` to the user to run themselves.
35
+ - `remove` asks before discarding dirty files or unmerged commits, and a non-interactive stdin (EOF) aborts safely. Answer explicitly when the removal is intended: `printf 'y\ny\n' | pi-worktree remove <name>`.
36
+ - Your own working directory cannot change. "Isolate this in a worktree" therefore means launching a nested headless Pi in the worktree, or telling the user to run `pi-worktree start <name>`.