@herbertgao/pi-extensions 2026.11.10 → 2026.11.11

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +6 -6
  3. package/THIRD_PARTY_NOTICES.md +2 -2
  4. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
  6. package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +13 -8
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +58 -15
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-io.ts +0 -5
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +18 -4
  11. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  12. package/node_modules/@herbertgao/pi-impeccable/CHANGELOG.md +6 -0
  13. package/node_modules/@herbertgao/pi-impeccable/README.md +2 -2
  14. package/node_modules/@herbertgao/pi-impeccable/package.json +4 -4
  15. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/SKILL.md +3 -1
  16. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/adapt.md +1 -1
  17. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.md +12 -1
  18. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.native.md +4 -0
  19. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/critique.md +5 -5
  20. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/documenter.md +1 -1
  21. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/finish-reviewer.md +1 -1
  22. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/distill.md +1 -1
  23. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/document.md +3 -1
  24. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/foundations.md +44 -0
  25. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live-setup.md +1 -1
  26. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live.md +26 -12
  27. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work.md +10 -9
  28. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/onboard.md +7 -6
  29. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/overdrive.md +2 -2
  30. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/quieter.md +1 -1
  31. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/visualize.md +1 -1
  32. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/VERSION +1 -1
  33. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/engine-checksums.txt +5 -5
  34. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/impeccable +69 -16
  35. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/impeccable.cmd +55 -7
  36. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/live-browser.js +34 -4
  37. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  38. package/node_modules/@herbertgao/pi-subagents/README.md +27 -9
  39. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +11 -11
  40. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  41. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +13 -0
  42. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +51 -32
  43. package/node_modules/@herbertgao/pi-subagents/src/default-agents.ts +7 -0
  44. package/node_modules/@herbertgao/pi-subagents/src/index.ts +334 -893
  45. package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +4 -1
  46. package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +13 -0
  47. package/node_modules/@herbertgao/pi-subagents/src/schedule-store.ts +18 -13
  48. package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +25 -5
  49. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +215 -69
  50. package/node_modules/@herbertgao/pi-subagents/src/types.ts +17 -0
  51. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +9 -0
  52. package/node_modules/@herbertgao/pi-subagents/src/ui/agents-menu.ts +705 -0
  53. package/node_modules/@herbertgao/pi-subagents/src/ui/settings-menu.ts +361 -0
  54. package/node_modules/@herbertgao/pi-subagents/src/ui/viewer-keys.ts +1 -1
  55. package/node_modules/pi-commandcode-provider/CHANGELOG.md +11 -1
  56. package/node_modules/pi-commandcode-provider/index.ts +2 -1
  57. package/node_modules/pi-commandcode-provider/package.json +5 -4
  58. package/node_modules/pi-commandcode-provider/src/pricing.ts +8 -1
  59. package/node_modules/pi-commandcode-provider/src/responses-compat.ts +137 -0
  60. package/package.json +5 -5
@@ -32,18 +32,23 @@ probe_ok() {
32
32
  return 1
33
33
  }
34
34
  probing=${IMPECCABLE_LAUNCHER_PROBE:-}
35
+ # Space, tab and CR, made once: hooks run this launcher on every edit and turn
36
+ # end, and every process it starts before the engine costs real time on a busy
37
+ # Windows machine (#1237), so the hot path below sticks to shell builtins.
38
+ ws=$(printf ' \t\r')
35
39
 
36
- # Prints the digest engine-checksums.txt records for engine version $1 and
37
- # asset $2 (lines are "<version> <asset> <sha256>"), nothing when there is none.
40
+ # Sets $digest_out to the digest engine-checksums.txt records for engine
41
+ # version $1 and asset $2 (lines are "<version> <asset> <sha256>"), empty when
42
+ # there is none.
38
43
  # A CR is a separator too (CRLF checkouts), and a last line with no newline
39
44
  # still counts.
40
45
  manifest_digest() {
46
+ digest_out=""
41
47
  [ -f "$manifest" ] || return 0
42
- sep=$(printf ' \t\r')
43
- while IFS="$sep" read -r m_version m_asset m_sum _ || [ -n "$m_version" ]; do
48
+ while IFS="$ws" read -r m_version m_asset m_sum _ || [ -n "$m_version" ]; do
44
49
  case "$m_version" in ''|'#'*) continue ;; esac
45
50
  if [ "$m_version" = "$1" ] && [ "$m_asset" = "$2" ]; then
46
- printf '%s' "$m_sum"
51
+ digest_out=$m_sum
47
52
  return 0
48
53
  fi
49
54
  done < "$manifest"
@@ -52,10 +57,12 @@ manifest_digest() {
52
57
  # Sets $expected (and, on Windows on ARM, which runs x64 binaries,
53
58
  # $expected_x64) from engine-checksums.txt.
54
59
  read_expected() {
55
- expected=$(manifest_digest "$version" "$asset")
60
+ manifest_digest "$version" "$asset"
61
+ expected=$digest_out
56
62
  expected_x64=""
57
63
  if [ "$os" = windows ] && [ "$arch" = arm64 ]; then
58
- expected_x64=$(manifest_digest "$version" impeccable-windows-x64.exe)
64
+ manifest_digest "$version" impeccable-windows-x64.exe
65
+ expected_x64=$digest_out
59
66
  fi
60
67
  }
61
68
  # Sets $size to the byte count of the cached binary (BSD wc pads it).
@@ -73,7 +80,19 @@ hash_file() {
73
80
  fi
74
81
  }
75
82
 
76
- dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
83
+ # This script's directory without dirname or a subshell: what dirname "$0"
84
+ # gives, made absolute by a cd there and back.
85
+ case $0 in
86
+ */*) dir=${0%/*} ;;
87
+ *) dir=. ;;
88
+ esac
89
+ [ -n "$dir" ] || dir=/
90
+ caller_pwd=$PWD
91
+ CDPATH= cd -- "$dir" || { echo "impeccable: cannot enter the launcher directory $dir" >&2; exit 127; }
92
+ dir=$PWD
93
+ skill_dir=${dir%/*}
94
+ [ -n "$skill_dir" ] || skill_dir=/
95
+ cd -- "$caller_pwd" || { echo "impeccable: cannot return to $caller_pwd" >&2; exit 127; }
77
96
  # VS Code syncs a plugin without the executable bit. Its hooks run this through
78
97
  # sh, so restore the bit for the commands the skill runs directly (#1249).
79
98
  [ -x "$0" ] || chmod +x "$0" 2>/dev/null || :
@@ -86,7 +105,7 @@ manifest="$dir/engine-checksums.txt"
86
105
  # cannot find reference/*.md (so native platform refs never inline) or read its
87
106
  # own version (so UPDATE_AVAILABLE never fires). Setting it here covers every
88
107
  # candidate the launcher can exec.
89
- : "${IMPECCABLE_SKILL_DIR:=$(CDPATH= cd -- "$dir/.." && pwd)}"
108
+ : "${IMPECCABLE_SKILL_DIR:=$skill_dir}"
90
109
  : "${IMPECCABLE_SELF:=$0}"
91
110
  export IMPECCABLE_SKILL_DIR IMPECCABLE_SELF
92
111
 
@@ -94,20 +113,29 @@ if [ -n "${IMPECCABLE_BIN:-}" ] && [ -x "${IMPECCABLE_BIN}" ]; then
94
113
  exec "${IMPECCABLE_BIN}" "$@"
95
114
  fi
96
115
 
97
- case "$(uname -s 2>/dev/null || echo unknown)" in
116
+ # Windows names itself in the environment, which saves a process there; one
117
+ # uname covers the rest. PROCESSOR_ARCHITECTURE is what impeccable.cmd reads,
118
+ # so both launchers pick the same cached engine (AMD64 under x64 Git Bash on
119
+ # ARM64, as uname -m reported before).
120
+ if [ "${OS:-}" = Windows_NT ]; then
121
+ sys="Windows_NT ${PROCESSOR_ARCHITECTURE:-unknown}"
122
+ else
123
+ sys=$(uname -sm 2>/dev/null) || sys="unknown unknown"
124
+ fi
125
+ case "${sys%% *}" in
98
126
  Darwin) os=darwin ;;
99
127
  Linux) os=linux ;;
100
128
  MINGW*|MSYS*|CYGWIN*|Windows_NT) os=windows ;;
101
129
  *) os=unknown ;;
102
130
  esac
103
- case "$(uname -m 2>/dev/null || echo unknown)" in
104
- arm64|aarch64) arch=arm64 ;;
105
- x86_64|amd64) arch=x64 ;;
131
+ case "${sys##* }" in
132
+ arm64|aarch64|ARM64) arch=arm64 ;;
133
+ x86_64|amd64|AMD64) arch=x64 ;;
106
134
  *) arch=unknown ;;
107
135
  esac
108
136
 
109
137
  version=""
110
- [ -f "$dir/VERSION" ] && version=$(tr -d '[:space:]' < "$dir/VERSION")
138
+ [ -f "$dir/VERSION" ] && { IFS="$ws" read -r version _ < "$dir/VERSION" || :; }
111
139
  bin="$dir/bin/$os-$arch/impeccable"
112
140
  [ "$os" = windows ] && bin="$bin.exe"
113
141
 
@@ -136,7 +164,7 @@ if [ -n "$version" ] && [ -x "$cached" ]; then
136
164
  cached_size
137
165
  stamp=""
138
166
  stamp_size=""
139
- { IFS="$(printf ' \t\r')" read -r stamp stamp_size _ < "$cached.verified"; } 2>/dev/null || :
167
+ { IFS="$ws" read -r stamp stamp_size _ < "$cached.verified"; } 2>/dev/null || :
140
168
  if [ -n "$stamp" ] && [ "$stamp_size" = "$size" ] && { [ "$stamp" = "$expected" ] || [ "$stamp" = "$expected_x64" ]; } && [ ! "$cached" -nt "$cached.verified" ]; then
141
169
  exec "$cached" "$@"
142
170
  fi
@@ -160,8 +188,23 @@ setup_help() {
160
188
  echo "Alternatively, set IMPECCABLE_HOME to a writable cache location, or IMPECCABLE_BIN to a preinstalled engine binary." >&2
161
189
  }
162
190
  fetch_url() {
191
+ http_status=""
192
+ download_host=""
163
193
  if command -v curl >/dev/null 2>&1; then
164
- curl -fsSL --retry 2 -o "$tmp" "$1" 2>/dev/null
194
+ fetch_result=0
195
+ metadata=$(curl -fsSL --retry 2 -w '%{http_code} %{url_effective}' -o "$tmp" "$1" 2>/dev/null) || fetch_result=$?
196
+ http_status=${metadata%% *}
197
+ effective_url=${metadata#* }
198
+ # Only the authority is needed, never the signed storage URL's query.
199
+ download_host=${effective_url#*://}
200
+ download_host=${download_host%%/*}
201
+ download_host=${download_host##*@}
202
+ case "$download_host" in
203
+ \[*) download_host=${download_host%%]*}] ;;
204
+ *) download_host=${download_host%%:*} ;;
205
+ esac
206
+ download_host=$(printf '%s' "$download_host" | tr '[:upper:]' '[:lower:]')
207
+ return "$fetch_result"
165
208
  elif command -v wget >/dev/null 2>&1; then
166
209
  wget -q -O "$tmp" "$1" 2>/dev/null
167
210
  else
@@ -256,6 +299,16 @@ if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then
256
299
  exec "$cached" "$@"
257
300
  fi
258
301
  rm -f "$tmp" 2>/dev/null
302
+ case "$http_status" in
303
+ 5[0-9][0-9])
304
+ case "$download_host" in
305
+ github.com|*.github.com|githubusercontent.com|*.githubusercontent.com)
306
+ echo "impeccable: could not download engine $version: GitHub's downloads are failing right now (HTTP $http_status from $download_host). This is an outage on GitHub's side, not a problem with your setup or the CLI, so updating won't help. Check https://www.githubstatus.com and run the same command again once GitHub has recovered." >&2 ;;
307
+ *)
308
+ echo "impeccable: could not download engine $version: $download_host is failing right now (HTTP $http_status), a server error on $download_host's side. Try again later." >&2 ;;
309
+ esac
310
+ exit 127 ;;
311
+ esac
259
312
  echo "impeccable: could not download engine $version from $url; check network access, the release URL, and curl or wget availability." >&2
260
313
  setup_help
261
314
  exit 127
@@ -93,11 +93,26 @@ goto run
93
93
  :no_cache
94
94
 
95
95
  if defined IMPECCABLE_LAUNCHER_PROBE goto download
96
- where impeccable >nul 2>nul
97
- if errorlevel 1 goto download
98
- call :probe impeccable
96
+ rem The first impeccable on PATH, resolved once so the probe and the run see
97
+ rem the same file. A batch shim (npm writes impeccable.cmd) must run under
98
+ rem call to return here (#1240), and call expands % in the arguments a second
99
+ rem time; a real binary runs directly so a target such as a%20b reaches it intact.
100
+ set "path_bin="
101
+ rem where also lists npm's extensionless POSIX shim, which cmd cannot run:
102
+ rem take the first match with a runnable extension.
103
+ rem Loop letters c and k are not path modifiers, so %%~xc reads as the
104
+ rem extension of c and never as a loop variable followed by text.
105
+ for /f "delims=" %%c in ('where impeccable 2^>nul') do if not defined path_bin for %%k in (.exe .com .cmd .bat) do if /I "%%~xc"=="%%k" set "path_bin=%%c"
106
+ if not defined path_bin goto download
107
+ call :probe "%path_bin%"
99
108
  if not "%probe_ok%"=="1" goto download
100
- impeccable %*
109
+ for %%k in ("%path_bin%") do set "path_ext=%%~xk"
110
+ if /I "%path_ext%"==".cmd" goto path_shim
111
+ if /I "%path_ext%"==".bat" goto path_shim
112
+ "%path_bin%" %*
113
+ exit /b %errorlevel%
114
+ :path_shim
115
+ call "%path_bin%" %*
101
116
  exit /b %errorlevel%
102
117
 
103
118
  :download
@@ -139,14 +154,14 @@ rem branch on the command's failure directly.
139
154
  (type nul >"%part%") 2>nul || goto staging_write_failed
140
155
  set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
141
156
  if not defined expected goto fetch_x64
142
- curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul
157
+ call :fetch_url
143
158
  if not errorlevel 1 goto verify
144
159
  :fetch_x64
145
160
  if not defined expected_x64 goto download_failed
146
161
  set "asset=impeccable-windows-x64.exe"
147
162
  set "expected=%expected_x64%"
148
163
  set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
149
- curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul
164
+ call :fetch_url
150
165
  if errorlevel 1 goto download_failed
151
166
 
152
167
  :verify
@@ -172,6 +187,25 @@ call :discard_staging
172
187
  echo impeccable: cannot verify %url% (certutil could not hash it); refusing the unverified download 1>&2
173
188
  exit /b 127
174
189
 
190
+ :fetch_url
191
+ set "http_status="
192
+ set "effective_url="
193
+ set "download_host="
194
+ curl.exe -fsSL --retry 2 -w "%%{http_code} %%{url_effective}" -o "%part%" "%url%" >"%staging%\http.txt" 2>nul
195
+ set "fetch_result=%errorlevel%"
196
+ for /f "usebackq tokens=1" %%a in ("%staging%\http.txt") do set "http_status=%%a"
197
+ for /f "usebackq tokens=2" %%a in ("%staging%\http.txt") do set "effective_url=%%a"
198
+ rem Token 2 is the authority after scheme://. Drop userinfo and the port.
199
+ for /f "tokens=2 delims=/" %%h in ("%effective_url%") do set "download_host=%%h"
200
+ for /f "tokens=1,* delims=@" %%h in ("%download_host%") do if not "%%i"=="" set "download_host=%%i"
201
+ rem Bracketed IPv6 hosts contain colons that are not port separators.
202
+ if "%download_host:~0,1%"=="[" goto fetch_ipv6
203
+ for /f "tokens=1 delims=:" %%h in ("%download_host%") do set "download_host=%%h"
204
+ exit /b %fetch_result%
205
+ :fetch_ipv6
206
+ for /f "tokens=1 delims=]" %%h in ("%download_host%") do set "download_host=%%h]"
207
+ exit /b %fetch_result%
208
+
175
209
  :read_expected
176
210
  rem Sets expected (and, on ARM64, expected_x64: Windows on ARM runs x64
177
211
  rem binaries) from engine-checksums.txt.
@@ -255,11 +289,13 @@ rem Sets probe_ok=1 when %1 answers the engine handshake: prints
255
289
  rem "impeccable-engine <version>" and exits 0, and probe_version to that
256
290
  rem version. The 3.x npm CLI answers any unknown verb with "Unknown command",
257
291
  rem exit 1, so it never passes.
292
+ rem The candidate runs under call: an npm .cmd shim run without it takes
293
+ rem over this script and never returns (#1240).
258
294
  set "probe_ok="
259
295
  set "probe_version="
260
296
  set "probe_tmp=%TEMP%\impeccable-probe-%RANDOM%%RANDOM%.txt"
261
297
  set "IMPECCABLE_LAUNCHER_PROBE=1"
262
- "%~1" engine-probe >"%probe_tmp%" 2>nul
298
+ call "%~1" engine-probe >"%probe_tmp%" 2>nul
263
299
  set "probe_err=%ERRORLEVEL%"
264
300
  set "IMPECCABLE_LAUNCHER_PROBE="
265
301
  if not "%probe_err%"=="0" goto probe_done
@@ -292,6 +328,18 @@ goto setup_failed
292
328
 
293
329
  :download_failed
294
330
  call :discard_staging
331
+ if not "%http_status:~0,1%"=="5" goto download_generic
332
+ if "%http_status:~2,1%"=="" goto download_generic
333
+ if /I "%download_host%"=="github.com" goto download_github
334
+ if /I "%download_host:~-11%"==".github.com" goto download_github
335
+ if /I "%download_host%"=="githubusercontent.com" goto download_github
336
+ if /I "%download_host:~-22%"==".githubusercontent.com" goto download_github
337
+ echo impeccable: could not download engine %version%: %download_host% is failing right now (HTTP %http_status%), a server error on %download_host%'s side. Try again later. 1>&2
338
+ exit /b 127
339
+ :download_github
340
+ echo impeccable: could not download engine %version%: GitHub's downloads are failing right now (HTTP %http_status% from %download_host%). This is an outage on GitHub's side, not a problem with your setup or the CLI, so updating won't help. Check https://www.githubstatus.com and run the same command again once GitHub has recovered. 1>&2
341
+ exit /b 127
342
+ :download_generic
295
343
  echo impeccable: could not download engine %version% from %url%; check network access and the release URL. 1>&2
296
344
 
297
345
  :setup_failed
@@ -7519,8 +7519,25 @@
7519
7519
  let liveBarHiddenByHelper = false;
7520
7520
 
7521
7521
  function applyLiveBarPreference(hidden) {
7522
+ const wasHidden = liveBarHiddenByHelper;
7522
7523
  liveBarHiddenByHelper = hidden === true;
7523
7524
  setLiveBarHidden(liveBarHiddenByHelper);
7525
+ // A hidden bar has no Pick or Insert control, so a choice remembered
7526
+ // from a visible session stops capturing the page's clicks until the
7527
+ // bar is back. The stored prefs stay as they are.
7528
+ if (liveBarHiddenByHelper && !wasHidden && state === 'PICKING') {
7529
+ clearInsertPicking();
7530
+ hideHighlight();
7531
+ setLiveState('IDLE');
7532
+ syncPageInteractionCursor();
7533
+ } else if (!liveBarHiddenByHelper && wasHidden) {
7534
+ enterPickingIfArmed();
7535
+ syncPageInteractionCursor();
7536
+ }
7537
+ }
7538
+
7539
+ function enterPickingIfArmed() {
7540
+ if (state === 'IDLE' && (pickActive || insertActive) && !liveBarHiddenByHelper) setLiveState('PICKING');
7524
7541
  }
7525
7542
 
7526
7543
  // A plain live session must never notice this code: hiding remembers the
@@ -7825,13 +7842,21 @@
7825
7842
  hasProjectContext = !!msg.hasProjectContext;
7826
7843
  // The generate lane runs without PRODUCT.md by design and never
7827
7844
  // sends the user to init, so its quiet chrome skips this notice.
7828
- if (!hasProjectContext && !liveBarHiddenByHelper) showToast(`No PRODUCT.md found. Variants will be brand-agnostic. Run ${IMPECCABLE_COMMAND} init to generate one.`, 7000);
7845
+ // A first session gets the first move instead: what to click
7846
+ // matters more than a missing file, and it shows once.
7847
+ if (liveFirstRun && !liveBarHiddenByHelper) {
7848
+ liveFirstRun = false;
7849
+ if (!insertActive) pickActive = true;
7850
+ saveInteractionPrefs();
7851
+ updateGlobalBarState();
7852
+ showToast('Click anything on the page to restyle it.', 8000);
7853
+ } else if (!hasProjectContext && !liveBarHiddenByHelper) showToast(`No PRODUCT.md found. Variants will be brand-agnostic. Run ${IMPECCABLE_COMMAND} init to generate one.`, 7000);
7829
7854
  console.log('[impeccable] Live mode connected.');
7830
7855
  syncAgentPollingUi(!!msg.agentPolling);
7831
7856
  startAgentStatusPoll();
7832
7857
  restoreFromActiveSessions(msg.activeSessions, 'sse_connected');
7833
7858
  recoverMissedGenerationCompletion(msg.activeSessions);
7834
- if (state === 'IDLE' && (pickActive || insertActive)) setLiveState('PICKING');
7859
+ enterPickingIfArmed();
7835
7860
  syncPageInteractionCursor();
7836
7861
  syncPageChatFocus('sse-connected');
7837
7862
  break;
@@ -10549,7 +10574,11 @@ void main() {
10549
10574
  return { pickActive: !!prefs.pickActive, insertActive: false };
10550
10575
  }
10551
10576
  } catch { /* ignore */ }
10552
- return { pickActive: false, insertActive: false };
10577
+ // Nothing stored: this browser's first Live session here. Pick turns on
10578
+ // when the helper connects with the bar visible (see `connected`), so the
10579
+ // first click on the page already does something; the generate lane hides
10580
+ // the bar, and a Pick nobody can see or turn off would eat app clicks.
10581
+ return { pickActive: false, insertActive: false, firstRun: true };
10553
10582
  }
10554
10583
 
10555
10584
  function saveInteractionPrefs() {
@@ -10567,6 +10596,7 @@ void main() {
10567
10596
  }
10568
10597
 
10569
10598
  let pickActive = loadInteractionPrefs().pickActive;
10599
+ let liveFirstRun = loadInteractionPrefs().firstRun === true;
10570
10600
  let insertActive = loadInteractionPrefs().insertActive;
10571
10601
  let configureKind = 'replace';
10572
10602
  let insertLineEl = null;
@@ -13865,7 +13895,7 @@ void main() {
13865
13895
  scout.observe(document.body, { childList: true, subtree: true });
13866
13896
  }
13867
13897
 
13868
- if (state === 'IDLE' && (pickActive || insertActive)) setLiveState('PICKING');
13898
+ enterPickingIfArmed();
13869
13899
  syncPageInteractionCursor();
13870
13900
  syncPageChatFocus('init-complete');
13871
13901
  }
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.25.0-local.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#377](https://github.com/HerbertGao/pi-extensions/pull/377) [`b02be94`](https://github.com/HerbertGao/pi-extensions/commit/b02be9410f637abc110fd2ee02def0f9d75fd419) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Replay upstream pi-subagents 0.25.0. The built-in general-purpose agent can spawn its own subagents, and Settings writes the global file unless the project already has one. A finished nested agent is dropped with its parent on a session switch. Unconsumed top-level results and a failed worktree cleanup still stay recoverable.
8
+
3
9
  ## 0.24.0-local.1
4
10
 
5
11
  ### Minor Changes
@@ -17,7 +17,7 @@ https://github.com/user-attachments/assets/8685261b-9338-4fea-8dfe-1c590d5df543
17
17
  - **Conversation viewer** — select any agent in `/agents` to open a live-scrolling overlay of its full conversation (auto-follows new content, scroll up to pause). In pi's fullscreen mode it is a borderless, full-terminal observer with mouse support. Steer a running agent inline by pressing `Enter` to open a composer, typing, then `Enter` to send (`Esc` or an empty submit returns) — the message appears as a user message and redirects the agent after its current tool. Press `b` on a running foreground `Agent` call to hand that run to the background (see [Sending a foreground agent to the background](#sending-a-foreground-agent-to-the-background)). Stop a still-running agent by pressing `x` (then `x` again to confirm) — steer and stop both work for background agents too. Tool calls render the way they do in pi's own transcript, through the renderers registered in the agent's session: a bash call shows its command and output, `read` its line numbers, `edit` its diff, an extension tool its own renderer, and a tool without one falls back to its arguments plus a bounded output preview. `ctrl+o` (or whatever `app.tools.expand` is bound to) unfolds elided tool output. Assistant text renders as Markdown; `m` cycles that between off, assistant-only and everything (see [Viewer markdown](#persistent-settings))
18
18
  - **Custom agent types** — define agents in `.pi/agents/<name>.md` or `.agents/agents/<name>.md` (project) or globally, with YAML frontmatter: custom system prompts, model selection, thinking levels, tool restrictions, and Claude Code-compatible colored name badges
19
19
  - **Package-shipped agents** — a pi package can declare its own subagents (and workflow scripts) with `"pi": { "subagents": { "agents": ["./agents"] } }` in its `package.json`, so `pi install` is the whole setup: no copying files into `.pi/agents/` on every machine or container start. Only packages pi has actually installed are read (never `node_modules`), package definitions rank below every agent you wrote, and `/agents` shows them read-only with Eject and Disable. Narrow or switch it off with `packageAgents` / `packageWorkflows`. **[Full guide](https://github.com/HerbertGao/pi-extensions/blob/master/packages/pi-subagents/docs/packages.md)**
20
- - **Nested subagents** — opt-in, default-off delegation: a custom agent that sets `allowed_subagents` gets its own ownership-scoped `Agent`, `get_subagent_result`, and `steer_subagent` tools, depth-capped from the main session (default 2). It can control only its own children, they are stopped when it finishes, and their transcripts and token spend roll up to it. The allowlist is a privilege boundary — a child runs with its own tools, so pick it as carefully as `tools:` itself
20
+ - **Nested subagents** — the built-in `general-purpose` agent can delegate to subagents of its own, as in Claude Code; `Explore` and `Plan` cannot, and a custom agent opts in by setting `allowed_subagents`. A delegating agent gets its own ownership-scoped `Agent`, `get_subagent_result`, and `steer_subagent` tools, depth-capped from the main session (default 2). It can control only its own children, they are stopped when it finishes, and their transcripts and token spend roll up to it. The allowlist is a privilege boundary — a child runs with its own tools, so pick it as carefully as `tools:` itself
21
21
  - **Agent mentions** — subagents are first-class: type `@explore also check the RPC path` at the prompt and it goes to that agent instead of the main model, without a word of it entering the chat. One syntax covers the whole lifecycle — message it while it runs, resume it once it has finished, reopen its session from disk long after that, or start it if it never ran. Mentioning an agent that isn't running spawns it through an off-screen clone of the conversation, so it gets Claude Code's context-written prompt and a real `Agent` tool call without a word of it reaching the chat; `direct` mode starts it here from your text instead, with no model call at all. The orchestrator can `name` an agent so you address it as `@auth-audit`, and handles work in `steer_subagent`/`get_subagent_result` too. `@` completes live agents, resumable ones, and startable types alongside pi's file completion; `@main` forces text back to the main model. Toggle via `/agents → Settings → Agent mentions`
22
22
  - **Scripted workflows** — a `SubagentWorkflow` tool that runs a deterministic JavaScript script orchestrating many subagents: `agent()`, `parallel()`, `pipeline()`, `phase()`, `log()` and `args`, with a pure-literal `meta` block declaring the phases. `pipeline()` has no barrier between stages, so one item can be in a later stage while another is still in the first — unlike `parallel()`, which idles every fast agent until the slowest finishes. Runs in the background with a live card, inspectable via `/agents → Workflows` or by selecting the run in FleetView. `agent()` also takes `gate: "npm test"` to verify a child by running a command (inside its worktree, when isolated) rather than asking another model, and `resume: "<label>"` to continue a child instead of re-paying its context. Scripts run in a `node:vm` sandbox on a worker thread where `Date.now()`, `Math.random()` and `eval` throw. On by default, but it stands down for company: if another extension already provides a `Workflow` or `SubagentWorkflow` tool, this one warns and disables itself for the session rather than offering the model two orchestrators. Pin it either way with `"workflowsEnabled"` in `subagents.json` or `/agents → Settings → Workflows`. A script written for Claude Code's `Workflow` tool runs here unchanged: same globals, `schema` returns a validated object exactly as it does there, `budget` is present and always reports no token target (pi has no such directive) so its `budget.total`-guarded patterns still take the branch they were written for, and nested `workflow()` composes saved workflows one level deep. **[Full guide](https://github.com/HerbertGao/pi-extensions/blob/master/packages/pi-subagents/docs/workflows.md)**
23
23
  - **Mid-run steering** — inject messages into running agents to redirect their work without restarting
@@ -278,7 +278,7 @@ Group completions render each agent as a separate block. The LLM receives struct
278
278
  | `Explore` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Fast codebase exploration (read-only) |
279
279
  | `Plan` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Software architect for implementation planning (read-only) |
280
280
 
281
- The `general-purpose` agent is a **parent twin** — it receives the parent's system prompt plus a sub-agent context bridge, so it follows the same rules the parent does. The parent's skill list, cwd and extension sections are left out: the subagent's own session adds them for itself, so its skills follow its `skills` setting. Explore and Plan use standalone prompts tailored to their read-only roles.
281
+ The `general-purpose` agent is a **parent twin** — it receives the parent's system prompt plus a sub-agent context bridge, so it follows the same rules the parent does. The parent's skill list, cwd and extension sections are left out: the subagent's own session adds them for itself, so its skills follow its `skills` setting. When it can [delegate](#nested-subagents), it also gets Claude Code's closing line telling it not to hand its whole assignment to a single child. Explore and Plan use standalone prompts tailored to their read-only roles.
282
282
 
283
283
  Default agents can be **ejected** (`/agents` → select agent → Eject) to export them as `.md` files for customization, **overridden** by creating a `.md` file with the same name (e.g. `.pi/agents/general-purpose.md`), or **disabled** per-project with `enabled: false` frontmatter. To run Explore on a cheaper model, eject it and add `model:` (e.g. `model: anthropic/claude-haiku-4-5`); a pinned model resolves through any provider with a key, not just the session's.
284
284
 
@@ -367,7 +367,7 @@ Frontmatter is authoritative. If an agent file sets `model`, `thinking`, `max_tu
367
367
 
368
368
  ### Nested subagents
369
369
 
370
- Nested delegation is default-off. Set `allowed_subagents` only on a non-isolated custom agent that owns a real fan-out responsibility:
370
+ The built-in `general-purpose` agent delegates out of the box, matching Claude Code: it already has every tool, so a child can do nothing it could not. It does not delegate as a [workflow](#subagentworkflow) `agent()`, where the script does the fanning out — Claude Code's workflow agents have no `Agent` tool either. `Explore` and `Plan` never delegate. For custom agents nesting is default-off — set `allowed_subagents` only on a non-isolated custom agent that owns a real fan-out responsibility:
371
371
 
372
372
  ```yaml
373
373
  ---
@@ -381,7 +381,15 @@ allowed_subagents: support-file-finder, support-callsite-tracer # or `all`
381
381
 
382
382
  `allowed_subagents` is runtime-enforced. A comma-separated list restricts nesting to those types; `all` (or `"*"` / `true`, matching how `extensions:` and `skills:` take booleans) allows any enabled agent; omitted, empty, `none`, or `false` means no nested tools are injected at all. Unknown, disabled, and out-of-list types are rejected rather than falling back — regardless of the project's [fallback agent](#persistent-settings) setting, so a configured fallback can never hand a nested caller an agent outside its allowlist — and a nested `model:` is validated against [Model Scope](#model-scope) exactly like a top-level spawn. Result, resume, and steering operations are ownership-scoped, so a parent can control only its own children. Nested records remain internal to that parent and do not appear in top-level tools, lifecycle events, or agent UI other than [FleetView](#fleetview) (which lists them under their parent with their own usage) and `/agents → Running agents` — so when a parent finishes, is stopped, or ends a resumed turn, its nested children are stopped with it. They do write their own `.output` transcript (subject to the same `output_transcript` gate), filed under the root session's directory alongside their ancestors', so a nested run can still be inspected after the fact. Their token usage is folded into every ancestor's totals up to the top-level agent (lifecycle events, completion notifications, `/agents`), so nested spend stays attributable at any depth on surfaces where the children themselves stay hidden. A nested result that ends `stopped`, `aborted`, or `steered` is labelled as partial, the same guarantee top-level results carry.
383
383
 
384
- The hard cap is depth 2 by default: main session (0) → subagent (1) → nested child (2). Change it project-wide with `maxSubagentDepth` in `subagents.json` (or `/agents → Settings → Nested depth`); `0` or `1` turns nesting off everywhere. An agent already at the cap gets no nested tools at all — not even `get_subagent_result`, since it can never own a child. A child must independently set `allowed_subagents` to delegate again; isolated agents never receive nested tools.
384
+ `maxSubagentDepth` (default `2`) is the deepest level an agent may run at, counted from the main session (0). An agent can spawn only while its own depth is below it:
385
+
386
+ | `maxSubagentDepth` | Main → subagent (1) | Subagent → child (2) | Child → grandchild (3) |
387
+ | --------------------------- | ------------------- | -------------------- | ---------------------- |
388
+ | `0` or `1` | yes | no | no |
389
+ | `2` (default) | yes | yes | no |
390
+ | `3` (Claude Code's default) | yes | yes | yes |
391
+
392
+ **`0` or `1` turns nested subagents off everywhere, even for agents that set `allowed_subagents`** (including the built-in `general-purpose`). No agent gets nested tools or the re-delegation line, so no prompt carries any nesting text; top-level spawns from the main session are unaffected. Set it in `subagents.json` or `/agents → Settings → Nested depth`. An agent already at the cap gets no nested tools at all — not even `get_subagent_result`, since it can never own a child. A child delegates again only if its own agent allows it (`general-purpose` does); isolated agents never receive nested tools.
385
393
 
386
394
  Nested children occupy no slot in either queueing pool — their parent already holds one, and queueing them behind it would deadlock a parent waiting on its own child. They do count toward the [nested limit](#concurrency) `maxConcurrentNested` (default `10`), which bounds how _wide_ nesting goes: a nested spawn over it is refused, not queued, and the parent gets a tool error telling it to do the work itself. The depth cap bounds how _deep_.
387
395
 
@@ -560,7 +568,7 @@ Check status and retrieve results from a background agent.
560
568
 
561
569
  Cancelling a `wait: true` call (for example, with `Esc`) stops only the wait. The background agent keeps running, and its completion notification still arrives normally.
562
570
 
563
- A finished agent's result stays retrievable after its in-memory record is cleaned up (about ten minutes after it finishes) or lost to a reload: the final record is saved in the session as a `subagents:record` entry, and `get_subagent_result` answers from it by id or by handle, without the stats or the conversation (`verbose`).
571
+ A finished agent's result stays retrievable after its in-memory record is cleaned up (about ten minutes after it finishes) or lost to a reload: the final record is saved in the session as a `subagents:record` entry, and `get_subagent_result` answers from it by id or by handle, without the stats or the conversation (`verbose`). That answer states when the run finished and how long ago, since the entry lasts as long as the session and a days-old result would otherwise read as current.
564
572
 
565
573
  ### `steer_subagent`
566
574
 
@@ -713,12 +721,20 @@ When on, each subagent spawn's effective model is validated against pi's own `en
713
721
 
714
722
  Runtime tuning values set via `/agents` → Settings (max background concurrency, max foreground concurrency, max nested concurrency, nested depth, default max turns, grace turns, fallback agent, default join mode, scheduling on/off, scope models on/off, disable defaults on/off, strict agent files on/off, package agents on/off, package workflows on/off, agent mentions on/off, output transcript on/off, tool description full/compact/custom, widget all/background/off, usage reporting on/off, cost display on/off, model display on/off, viewer markdown off/assistant/all) persist across pi restarts. Two files, merged on load:
715
723
 
716
- - **Global:** `~/.pi/agent/subagents.json` — your machine-wide defaults. Edit by hand; the `/agents` menu never writes here.
717
- - **Project:** `<cwd>/.pi/subagents.json` — per-project overrides. Written by `/agents` → Settings.
724
+ - **Global:** `~/.pi/agent/subagents.json` — your machine-wide defaults.
725
+ - **Project:** `<cwd>/.pi/subagents.json` — per-project overrides.
726
+
727
+ `/agents` → Settings writes to the scope named in its header: Project when the project already has a `subagents.json`, Global otherwise. Tab switches it. Choosing Project in a repo without the file creates it on your first change; without that choice the menu never creates one. The list always shows the effective (merged) values, and saving to Global a setting the project file also sets warns that the project value still wins.
728
+
729
+ A save writes only the setting you changed into that file; every other key in it, including ones another pi session saved, is left as it was.
730
+
731
+ Rows are ordered by category: limits, dispatch, features, agent files, display. The filter sits above the first row: typing filters the rows by label from anywhere in the list, ↓ or Enter from the filter moves onto the first row without changing it, ↑ from the first row returns to the filter, and Esc clears it before it closes the menu. The list fits the terminal and scrolls when it has more rows than room.
732
+
733
+ A row whose value comes from a settings file is tagged with that file (`project` or `global`, in a column after the labels); an untagged row is at its built-in default. With the cursor on a tagged row, Delete (or Backspace) removes that setting from the tagged file, so the row shows what the next start would load: the other file's value if it sets one, otherwise the built-in default. With the cursor in the filter, those keys edit the filter instead. Enter on a number row opens an input under the list, with the accepted range: Enter saves, Esc returns to the list, and a value outside the range is refused. The ranges match what loading accepts, so a value the menu saves survives a restart.
718
734
 
719
735
  **Precedence:** project overrides global on any field present in both. Missing fields fall back to the hardcoded defaults (max background concurrency `10`, max foreground concurrency `0` = unlimited, max nested concurrency `10`, default max turns unlimited, grace turns `5`, nested depth `2`, join mode `smart`, defaults enabled).
720
736
 
721
- **Nested depth** (`maxSubagentDepth`, default `2`): the hard ceiling on [nested delegation](#nested-subagents), counted from the main session (main = 0, its subagents = 1). `0` or `1` disables nesting project-wide regardless of any agent's `allowed_subagents`. Read when a subagent session is built, so a change applies to agents started after it.
737
+ **Nested depth** (`maxSubagentDepth`, default `2`): the hard ceiling on [nested delegation](#nested-subagents), counted from the main session (main = 0, its subagents = 1). `0` or `1` disables nested subagents entirely, even for agents that set `allowed_subagents` — see the [depth table](#nested-subagents). Read when a subagent session is built, so a change applies to agents started after it.
722
738
 
723
739
  **Fallback agent** (`fallbackSubagent`, default `general-purpose`): the agent used when a caller-supplied `subagent_type` doesn't resolve to exactly one enabled agent — unknown, disabled, or ambiguous because two agents differ only by case. Name any enabled agent to route those calls there instead, or set `none` for **strict**, fail-closed dispatch: the call is refused with an error listing the available types, and nothing spawns. Strict mode matters most for background and scheduled calls, which would otherwise start executing a substituted agent before the caller learns anything. Also settable from `/agents → Settings → Fallback agent`. The boolean `false` is accepted as a spelling of `none`, because it would otherwise be dropped as the wrong type and silently leave the permissive default in place. Every other value is read as an agent name, so a mistaken `off` fails loudly at dispatch rather than meaning one thing in the settings file and another in the resolver. A fallback agent that is itself unknown or disabled is a misconfiguration and is reported rather than quietly replaced. Note the default is unchanged and stays permissive by design: with `disableDefaultAgents` and no `general-purpose` of your own, an unresolvable type still resolves to a built-in config carrying _all_ tools — set `none` (or name one of your own agents) to close that.
724
740
 
@@ -823,7 +839,7 @@ EOF
823
839
 
824
840
  Every project now starts with concurrency 16 and grace 10, without ever touching the menu. Individual projects can still override via `/agents` → Settings.
825
841
 
826
- **Failure behavior:** missing file is silent; malformed JSON logs a `[pi-subagents] Ignoring malformed settings at …` warning to stderr; invalid/out-of-range field values are dropped per-field; write failures downgrade the `/agents` toast to a warning with `(session only; failed to persist)`.
842
+ **Failure behavior:** missing file is silent; malformed JSON logs a `[pi-subagents] Ignoring malformed settings at …` warning to stderr; invalid/out-of-range field values are dropped per-field; a successful save's `/agents` toast ends with `(saved to global settings)` or `(saved to project settings)`; write failures — including a target file that is malformed or not a JSON object, which is left untouched — downgrade it to a warning with `(session only; failed to persist)`.
827
843
 
828
844
  ## Events
829
845
 
@@ -1130,7 +1146,9 @@ src/
1130
1146
  conversation-viewer.ts # Live conversation overlay for viewing agent sessions
1131
1147
  viewer-keys.ts # Viewer scroll, expand and jump keys, resolved through user keybindings
1132
1148
  agent-mention.ts # `@` roster (running, resumable, and startable agents) + popup rows
1149
+ agents-menu.ts # /agents root menu, running agents, agent types and detail, create wizards
1133
1150
  schedule-menu.ts # /agents → Scheduled jobs submenu
1151
+ settings-menu.ts # /agents → Settings page: filter, focus, number editor, terminal-sized list
1134
1152
  select-item.ts # Collision-safe ctx.ui.select wrapper (numbered rows)
1135
1153
  workflow-card.ts # Inline workflow card (tool result and session entry)
1136
1154
  workflow-dialog.ts # /agents → Workflows two-pane inspector
@@ -263,17 +263,17 @@ Spawns one subagent and resolves to its final text — or, with `schema`, to a v
263
263
 
264
264
  **Returns `null` if the agent failed terminally _or_ if you skipped it from the inspector**, indistinguishably. Filter with `.filter(Boolean)` when a `null` would break a later stage, and be careful with in-script retry loops: retrying on `null` will re-run something you deliberately skipped.
265
265
 
266
- | Option | Type | Notes |
267
- | ----------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
268
- | `label` | string | Display name in the progress tree. Also the handle `resume` addresses |
269
- | `phase` | string | Put this agent in a named group, overriding the ambient `phase()`. **Use it inside `pipeline`/`parallel` stages**, where the ambient phase races |
270
- | `agentType` | string | Which agent definition to use. Defaults to `general-purpose`; built-ins are `general-purpose`, `Explore`, `Plan`, plus your custom agents |
271
- | `model` | string | `provider/modelId`, or fuzzy like `haiku` |
272
- | `effort` | string | `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. Omitted, the agent definition's own `thinking` decides, then the parent's |
273
- | `isolation` | `"worktree"` | Run in a throwaway git worktree. Only when agents write files in parallel and would collide — it costs setup time and disk per agent. Only this option decides, as in Claude Code — an agent file's `isolation:` does not apply to workflow children |
274
- | `gate` | string | A shell command run after the agent finishes; a non-zero exit fails the agent and its output becomes the error |
275
- | `resume` | string | Continue the child that ran under that label instead of starting fresh |
276
- | `schema` | object | A JSON Schema with an object root. Resolves to the validated object instead of text |
266
+ | Option | Type | Notes |
267
+ | ----------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
268
+ | `label` | string | Display name in the progress tree. Also the handle `resume` addresses |
269
+ | `phase` | string | Put this agent in a named group, overriding the ambient `phase()`. **Use it inside `pipeline`/`parallel` stages**, where the ambient phase races |
270
+ | `agentType` | string | Which agent definition to use. Defaults to `general-purpose`; built-ins are `general-purpose`, `Explore`, `Plan`, plus your custom agents. The built-in `general-purpose` gets no nested `Agent` tool here; a custom agent with `allowed_subagents` keeps its own |
271
+ | `model` | string | `provider/modelId`, or fuzzy like `haiku` |
272
+ | `effort` | string | `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. Omitted, the agent definition's own `thinking` decides, then the parent's |
273
+ | `isolation` | `"worktree"` | Run in a throwaway git worktree. Only when agents write files in parallel and would collide — it costs setup time and disk per agent. Only this option decides, as in Claude Code — an agent file's `isolation:` does not apply to workflow children |
274
+ | `gate` | string | A shell command run after the agent finishes; a non-zero exit fails the agent and its output becomes the error |
275
+ | `resume` | string | Continue the child that ran under that label instead of starting fresh |
276
+ | `schema` | object | A JSON Schema with an object root. Resolves to the validated object instead of text |
277
277
 
278
278
  Any other key is rejected **by name** at the call. Note that this checks option _keys_, not option _values_ — an `agentType` that names no known agent falls back to `general-purpose` silently.
279
279
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.24.0-local.1",
3
+ "version": "0.25.0-local.1",
4
4
  "description": "Claude Code-style autonomous subagents and workflow orchestration for Pi, with HerbertGao-maintained UI extensions.",
5
5
  "keywords": [
6
6
  "agent",
@@ -69,10 +69,10 @@
69
69
  },
70
70
  "x-upstream": {
71
71
  "package": "@tintinweb/pi-subagents",
72
- "version": "0.24.0",
73
- "reviewedVersion": "0.24.0",
72
+ "version": "0.25.0",
73
+ "reviewedVersion": "0.25.0",
74
74
  "repository": "https://github.com/tintinweb/pi-subagents",
75
- "commit": "f0b5304bbfcf4598007a85773a2eac8539536fdd",
75
+ "commit": "b8efc069f05efe50b58a4b74140116c1c9a9dcc1",
76
76
  "trackVersion": true
77
77
  }
78
78
  }
@@ -1894,6 +1894,8 @@ export class AgentManager {
1894
1894
  * Called on session start/switch so tasks from a prior session don't persist.
1895
1895
  * Pass skipUnconsumed=true to preserve records the LLM hasn't read yet
1896
1896
  * (resultConsumed=false). The cleanup timer only evicts consumed results.
1897
+ * A nested child is spared only while its parent stays: the parent is its
1898
+ * only reader, and nothing marks it consumed when the parent collects it.
1897
1899
  */
1898
1900
  clearCompleted(skipUnconsumed = false): void {
1899
1901
  for (const [id, record] of this.agents) {
@@ -1901,6 +1903,17 @@ export class AgentManager {
1901
1903
  if (skipUnconsumed && !record.resultConsumed) continue
1902
1904
  this.removeRecord(id, record)
1903
1905
  }
1906
+ // One pass reaches grandchildren too: the map is in spawn order, so a
1907
+ // parent is visited, and removed, before its children.
1908
+ for (const [id, record] of this.agents) {
1909
+ if (record.status === "running" || record.status === "queued") continue
1910
+ if (
1911
+ record.parentAgentId === undefined ||
1912
+ this.agents.has(record.parentAgentId)
1913
+ )
1914
+ continue
1915
+ this.removeRecord(id, record)
1916
+ }
1904
1917
  // Unconditional: both callers are session boundaries (`session_start` and
1905
1918
  // `session_before_switch`), and `skipUnconsumed` only spares records whose
1906
1919
  // results the LLM has yet to read — it does not make the sweep partial in