@maxiaochao/pi-toolkit 0.5.2 → 0.6.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,11 @@
1
+ ## 2026-09-22 - v0.6.0
2
+
3
+ - bundle the show-me skill for visual explanations (derived from humanlayer/skills, MIT), invoked explicitly with /skill:show-me
4
+
5
+ ## 2026-09-15 - v0.5.3
6
+
7
+ - fix pi-worktree remove: worktrees with initialized submodules now remove via forced retry; dirty worktrees confirm the discard explicitly before removal; worktrees whose directory is already gone now prune their stale registration and clean up the branch
8
+
1
9
  ## 2026-09-11 - v0.5.2
2
10
 
3
11
  - fix btw: side-session and summarize passed a nonexistent `modelRegistry` option to `createAgentSession`, so a fresh ModelRuntime was created that didn't know extension-registered providers (e.g. volcengine-plan) and prompting failed with "No API key found"; now the main session's ModelRuntime is reused via `modelRuntime`
package/README.md CHANGED
@@ -79,6 +79,8 @@ node skills/chrome-cdp/scripts/cdp.mjs eval <target> 'document.title'
79
79
 
80
80
  Note: Chrome does not always write the `DevToolsActivePort` file (e.g. `--remote-debugging-port` launches on Chrome 152); in that case synthesize one from `GET http://127.0.0.1:<port>/json/version` — first line the port, second line the path of `webSocketDebuggerUrl`. WSL auto-discovery of Windows Chrome profiles is not built in; set `CDP_PORT_FILE` as above.
81
81
 
82
+ The bundled `show-me` skill (derived from [humanlayer/skills](https://github.com/humanlayer/skills), MIT) explains the current topic with the smallest visual that makes the point — pseudocode, call trees, component or file trees, diffs, Mermaid, or one focused HTML artifact. It is hidden from automatic skill selection, so invoke it explicitly with `/skill:show-me`.
83
+
82
84
  ## Tiny Subagent
83
85
 
84
86
  The tiny subagent is a separate npm package. Install it independently when you want the `tiny_subagents` tool:
package/bin/pi-worktree CHANGED
@@ -141,17 +141,68 @@ cmd_remove() {
141
141
  require_repo
142
142
  [[ $# -eq 1 ]] || die "usage: pi-worktree -r <name>"
143
143
  local dir; dir="$(wt_dir "$1")"
144
- [[ -d "$dir" ]] || die "worktree not found: $dir"
145
- # refuse to remove if the branch is not merged into main
146
- local branch; branch=$(git -C "$dir" branch --show-current)
147
- local rm_anyway=0
148
- if [[ -n "$branch" ]] && ! git merge-base --is-ancestor "$branch" main 2>/dev/null; then
149
- warn "branch '$branch' does not appear merged into 'main' (or no main branch exists)."
150
- read -rp "Remove anyway? [y/N] " ans
151
- [[ "$ans" =~ ^[Yy]$ ]] || die "aborted"
152
- rm_anyway=1
144
+ local branch registered rm_anyway=0 force=0
145
+ if [[ ! -d "$dir" ]]; then
146
+ # Directory already gone but possibly still registered (prunable), or a
147
+ # stale branch left behind by an earlier prune: clean the registration,
148
+ # then fall through to the branch cleanup.
149
+ local registered
150
+ registered=$(git worktree list --porcelain | awk -v p="$(pwd -P)/$dir" '
151
+ $0=="worktree "p {f=1; next}
152
+ f && /^branch / {print substr($0,8); exit}
153
+ f && /^detached/ {print "-"; exit}
154
+ f && /^$/ {exit}')
155
+ if [[ "$registered" == "-" ]]; then
156
+ git worktree prune
157
+ ok "pruned stale registration: $dir (directory already gone)"
158
+ return 0 # detached HEAD, nothing else to clean up
159
+ fi
160
+ if [[ -n "$registered" ]]; then
161
+ branch=${registered#refs/heads/}
162
+ elif git show-ref --verify --quiet "refs/heads/$1"; then
163
+ branch=$1 # registration already pruned; only the stale branch remains
164
+ else
165
+ die "worktree not found: $dir"
166
+ fi
167
+ if [[ -n "$registered" ]]; then
168
+ git worktree prune
169
+ ok "pruned stale registration: $dir (directory already gone)"
170
+ fi
171
+ else
172
+ # dirty worktree: removing discards modified/untracked files, which git
173
+ # refuses to do without --force — so confirm the loss explicitly
174
+ if ! git -C "$dir" diff --quiet 2>/dev/null \
175
+ || ! git -C "$dir" diff --cached --quiet 2>/dev/null \
176
+ || [[ -n "$(git -C "$dir" ls-files --others --exclude-standard)" ]]; then
177
+ warn "worktree contains modified/untracked files that will be discarded:"
178
+ git -C "$dir" status --short | head -10
179
+ read -rp "Discard and remove anyway? [y/N] " ans
180
+ [[ "$ans" =~ ^[Yy]$ ]] || die "aborted"
181
+ force=1
182
+ fi
183
+ branch=$(git -C "$dir" branch --show-current)
184
+ # refuse to remove if the branch is not merged into main
185
+ if [[ -n "$branch" ]] && ! git merge-base --is-ancestor "$branch" main 2>/dev/null; then
186
+ warn "branch '$branch' does not appear merged into 'main' (or no main branch exists)."
187
+ read -rp "Remove anyway? [y/N] " ans
188
+ [[ "$ans" =~ ^[Yy]$ ]] || die "aborted"
189
+ rm_anyway=1
190
+ fi
191
+ local out
192
+ if [[ "$force" == 1 ]]; then
193
+ git worktree remove --force "$dir" && ok "removed: $dir (discarded changes as confirmed)"
194
+ elif out=$(git worktree remove "$dir" 2>&1); then
195
+ ok "removed: $dir"
196
+ elif [[ "$out" == *"submodules cannot be moved or removed"* ]]; then
197
+ # git refuses to remove worktrees with initialized submodules unless
198
+ # --force is used (--force only overrides the submodule check here; the
199
+ # branch deletion below still asks before dropping unmerged commits)
200
+ git worktree remove --force "$dir" && ok "removed: $dir (contained submodules)"
201
+ else
202
+ printf '%s\n' "$out" >&2
203
+ die "failed to remove worktree: $dir"
204
+ fi
153
205
  fi
154
- git worktree remove "$dir" && ok "removed: $dir"
155
206
  # The branch survives `git worktree remove`; recreating the same name would
156
207
  # silently reuse this stale branch. Delete merged branches automatically.
157
208
  if [[ -n "$branch" ]] && git show-ref --verify --quiet "refs/heads/$branch"; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxiaochao/pi-toolkit",
3
- "version": "0.5.2",
3
+ "version": "0.6.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HumanLayer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ show-me skill is derived from humanlayer/skills (plugins/show-me, v1.0.1)
2
+ (https://github.com/humanlayer/skills), MIT License — see LICENSE.
@@ -0,0 +1,133 @@
1
+ ---
2
+ name: show-me
3
+ description: Help the user understand the current topic visually with concise diagrams, code-shape sketches, and focused HTML artifacts.
4
+ license: MIT
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ Help the user understand the current topic of conversation visually. Skip the preamble and keep prose brief. Pick the smallest view that makes the key point clear.
9
+
10
+ - Show logic or an algorithm as pseudocode:
11
+
12
+ ```text
13
+ on(save)
14
+ if content is unchanged
15
+ return cached result
16
+ write new content
17
+ return fresh result
18
+ ```
19
+
20
+ - Show runtime control flow as a call tree:
21
+
22
+ ```text
23
+ submitForm
24
+ createSession
25
+ persistPrompt
26
+ launchAgent
27
+ navigateToSession
28
+ ```
29
+
30
+ - Show UI structure as a component tree, including state and module boundaries that matter:
31
+
32
+ ```tsx
33
+ <SessionPage> (apps/example/src/routes/session.tsx)
34
+ useSessionEvents()
35
+ <SessionToolbar>
36
+ <RunSkillButton> (packages/ui)
37
+ ```
38
+
39
+ - Show file responsibility or a broad refactor as a shallow file tree:
40
+
41
+ ```text
42
+ src/
43
+ ├── commands/ # parses user actions
44
+ ├── sessions/ # owns session state
45
+ └── transport/ # sends API requests
46
+ ```
47
+
48
+ - Show component interaction, control flow, or data flow with Mermaid:
49
+
50
+ ```mermaid
51
+ sequenceDiagram
52
+ participant User
53
+ participant UI
54
+ participant Daemon
55
+ User->>UI: choose command
56
+ UI->>Daemon: send expanded prompt
57
+ Daemon-->>UI: stream result
58
+ ```
59
+
60
+ - Use `diff` when the point is what changes and the surrounding shape already exists. Match the diff shape to the topic.
61
+
62
+ For a component change:
63
+
64
+ ```diff
65
+ <SessionPage>
66
+ useSessionEvents()
67
+ <SessionToolbar>
68
+ + <RunSkillButton />
69
+ <SessionTimeline>
70
+ + <SkillResultCard />
71
+ ```
72
+
73
+ For a file-layout change:
74
+
75
+ ```diff
76
+ src/
77
+ ├── commands/
78
+ +│ └── show-me.ts # expands the slash command
79
+ ├── sessions/
80
+ -└── transport.ts
81
+ +└── transport/
82
+ + ├── client.ts
83
+ + └── stream.ts
84
+ ```
85
+
86
+ For a call-tree or call-stack change:
87
+
88
+ ```diff
89
+ submitForm
90
+ createSession
91
+ persistPrompt
92
+ + expandSkillMention
93
+ launchAgent
94
+ - navigateToSession
95
+ + navigateToSession
96
+ + subscribeToEvents
97
+ ```
98
+
99
+ For a state or control-flow change:
100
+
101
+ ```diff
102
+ on(save)
103
+ - write content
104
+ + if content is unchanged
105
+ + return cached result
106
+ + write new content
107
+ + invalidate cache
108
+ ```
109
+
110
+ - Show the whole block when most of it is new, when omitted context would hide ownership or order, or when the user needs a copyable target shape:
111
+
112
+ ```ts
113
+ function expandSkill(command: string): string {
114
+ const skillName = command.slice(1)
115
+ return `use the ${skillName} skill`
116
+ }
117
+ ```
118
+
119
+ - For a visual UI, layout, state comparison, or concept too dense for Mermaid, write one focused HTML file — a diagram, an infographic, or a short slide deck, whichever fits the point. Match the product's colors, type, spacing, and components; use real labels and data; support desktop and mobile. Follow the project's HTML output convention, or write to `.cache/html/show-me-<description>.html` when none exists. Then open it for the user:
120
+
121
+ ```bash
122
+ open path/to/show-me-<description>.html # macOS
123
+ xdg-open path/to/show-me-<description>.html # Linux
124
+ cmd.exe /c start "" "$(wslpath -w <abs path>)" # WSL
125
+ ```
126
+
127
+ For a heavier standalone artifact, the `html-artifact` skill applies.
128
+
129
+ ### guidance
130
+
131
+ Place each visual next to the short text it supports. Keep only the calls, files, props, states, and boundaries needed to answer the user's current question or the options to resolve the current discussion point.
132
+
133
+ You may use one of these, you may use several, it is unlikely you will use all of them. Use your judgement and don't overwhelm the user.