@herbertgao/pi-extensions 2026.11.14 → 2026.11.16

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 (51) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +7 -7
  3. package/THIRD_PARTY_NOTICES.md +3 -3
  4. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +3 -2
  6. package/node_modules/@herbertgao/pi-cc-extensions/README.md +3 -2
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +5 -0
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +9 -0
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +32 -2
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +26 -21
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/table-copy.ts +753 -0
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/fullscreen-detect.ts +11 -0
  13. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  14. package/node_modules/@herbertgao/pi-impeccable/CHANGELOG.md +6 -0
  15. package/node_modules/@herbertgao/pi-impeccable/README.md +2 -2
  16. package/node_modules/@herbertgao/pi-impeccable/package.json +4 -4
  17. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/SKILL.md +5 -5
  18. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.md +8 -1
  19. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.native.md +8 -1
  20. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/craft-floor.md +3 -3
  21. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/critique.md +8 -6
  22. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
  23. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/doctor.md +5 -1
  24. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/init.md +2 -0
  25. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live.md +1 -1
  26. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work.md +8 -9
  27. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/polish.md +1 -1
  28. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/VERSION +1 -1
  29. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/engine-checksums.txt +5 -5
  30. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/live-browser.js +55 -32
  31. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  32. package/node_modules/@herbertgao/pi-subagents/README.md +18 -16
  33. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
  34. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  35. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +18 -5
  36. package/node_modules/@herbertgao/pi-subagents/src/agent-types.ts +88 -0
  37. package/node_modules/@herbertgao/pi-subagents/src/index.ts +16 -92
  38. package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +6 -2
  39. package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +18 -2
  40. package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +25 -3
  41. package/node_modules/pi-commandcode-provider/CHANGELOG.md +20 -0
  42. package/node_modules/pi-commandcode-provider/README.md +1 -1
  43. package/node_modules/pi-commandcode-provider/index.ts +2 -1
  44. package/node_modules/pi-commandcode-provider/package.json +1 -1
  45. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +9 -2
  46. package/node_modules/pi-commandcode-provider/src/pricing.ts +5 -1
  47. package/node_modules/pi-commandcode-provider/src/responses-compat.ts +24 -1
  48. package/node_modules/pi-commandcode-provider/src/responses-stream.ts +99 -6
  49. package/node_modules/pi-provider-qoder/dist/index.js +50 -10
  50. package/node_modules/pi-provider-qoder/package.json +1 -1
  51. package/package.json +6 -6
@@ -30,6 +30,17 @@
30
30
  window.__IMPECCABLE_LIVE_INIT__ = false; // reset so the real load can init
31
31
  return;
32
32
  }
33
+ // The user just exited this helper's session: a reload in the next minute,
34
+ // before the agent removes the script tag (a carbonize edit reloads the
35
+ // page), must not bring Live back.
36
+ const EXITED_KEY = 'impeccable-live-exited';
37
+ try {
38
+ const [t, at] = (sessionStorage.getItem(EXITED_KEY) || '').split(' ');
39
+ if (t === TOKEN && Date.now() - Number(at) < 60_000) {
40
+ window.__IMPECCABLE_LIVE_INIT__ = false; // reset so a later inject can init
41
+ return;
42
+ }
43
+ } catch { /* storage blocked */ }
33
44
 
34
45
  //
35
46
  // Design tokens
@@ -2715,7 +2726,7 @@
2715
2726
  return el('div', { display: 'none' });
2716
2727
  }
2717
2728
  const row = el('div', {
2718
- display: 'flex', alignItems: 'center', gap: '6px',
2729
+ display: 'flex', alignItems: 'center', gap: touchPrimary() ? '2px' : '6px',
2719
2730
  padding: '1px 2px',
2720
2731
  });
2721
2732
 
@@ -2830,6 +2841,7 @@
2830
2841
  cursor: 'pointer', transition: 'filter 0.12s ease, transform 0.1s ease',
2831
2842
  whiteSpace: 'nowrap',
2832
2843
  });
2844
+ touchTarget(accept);
2833
2845
  accept.textContent = '\u2713 Accept';
2834
2846
  accept.addEventListener('mouseenter', () => accept.style.filter = 'brightness(1.08)');
2835
2847
  accept.addEventListener('mouseleave', () => accept.style.filter = 'none');
@@ -2850,6 +2862,7 @@
2850
2862
  fontFamily: FONT, fontSize: '11px', color: BP.textDim,
2851
2863
  cursor: 'pointer', transition: 'color 0.12s ease, border-color 0.12s ease',
2852
2864
  });
2865
+ touchTarget(discard);
2853
2866
  discard.textContent = '\u2715';
2854
2867
  discard.title = 'Discard all variants';
2855
2868
  discard.addEventListener('mouseenter', () => { discard.style.color = BP.text; discard.style.borderColor = BP.text; });
@@ -2950,6 +2963,12 @@
2950
2963
  return container;
2951
2964
  }
2952
2965
 
2966
+ /** A finger needs 44px; a mouse keeps the compact bar. */
2967
+ function touchTarget(b) {
2968
+ if (touchPrimary()) Object.assign(b.style, { minWidth: '44px', minHeight: '44px' });
2969
+ return b;
2970
+ }
2971
+
2953
2972
  function navBtn(text) {
2954
2973
  const b = el('button', {
2955
2974
  width: '26px', height: '26px', borderRadius: '5px',
@@ -2962,7 +2981,7 @@
2962
2981
  b.textContent = text;
2963
2982
  b.addEventListener('mouseenter', () => { b.style.borderColor = BP.text; });
2964
2983
  b.addEventListener('mouseleave', () => { b.style.borderColor = BP.hairline; });
2965
- return b;
2984
+ return touchTarget(b);
2966
2985
  }
2967
2986
 
2968
2987
  function actionLabel() {
@@ -7849,7 +7868,7 @@
7849
7868
  saveInteractionPrefs();
7850
7869
  updateGlobalBarState();
7851
7870
  showToast('Click anything on the page to restyle it.', 8000);
7852
- } else if (!hasProjectContext && !liveBarHiddenByHelper) showToast(`No PRODUCT.md found. Variants will be brand-agnostic. Run ${IMPECCABLE_COMMAND} init to generate one.`, 7000);
7871
+ } else if (!hasProjectContext && !liveBarHiddenByHelper && takeContextNotice()) showToast(`No PRODUCT.md found. Variants will be brand-agnostic. Run ${IMPECCABLE_COMMAND} init to generate one.`, 7000);
7853
7872
  console.log('[impeccable] Live mode connected.');
7854
7873
  syncAgentPollingUi(!!msg.agentPolling);
7855
7874
  startAgentStatusPoll();
@@ -10580,6 +10599,20 @@ void main() {
10580
10599
  return { pickActive: false, insertActive: false, firstRun: true };
10581
10600
  }
10582
10601
 
10602
+ // The missing-PRODUCT.md notice shows once per browser: a reconnect, a
10603
+ // reload or the variants arriving would otherwise bring it back each time.
10604
+ const CONTEXT_NOTICE_KEY = 'impeccable-live-context-notice';
10605
+ let contextNoticeShown = false;
10606
+ function takeContextNotice() {
10607
+ if (contextNoticeShown) return false;
10608
+ contextNoticeShown = true;
10609
+ try {
10610
+ if (localStorage.getItem(CONTEXT_NOTICE_KEY)) return false;
10611
+ localStorage.setItem(CONTEXT_NOTICE_KEY, '1');
10612
+ } catch { /* ignore */ }
10613
+ return true;
10614
+ }
10615
+
10583
10616
  function saveInteractionPrefs() {
10584
10617
  try {
10585
10618
  localStorage.setItem(INTERACTION_PREFS_KEY, JSON.stringify({ pickActive, insertActive }));
@@ -10761,13 +10794,11 @@ void main() {
10761
10794
  });
10762
10795
  }
10763
10796
 
10764
- function syncGlobalBarExpandedLabels(expanded = globalBarEl?.matches(':hover')) {
10765
- const expandInactive = !!(expanded && !pageChatExpanded);
10766
- applyGlobalBarLabelState(expandInactive, pageChatExpanded);
10767
-
10768
- if (expandInactive && globalBarEl && globalBarEl.scrollWidth > window.innerWidth - 16) {
10769
- applyGlobalBarLabelState(false);
10770
- }
10797
+ // Only active modes show their label. Hover never widens the bar: it sits
10798
+ // centred, so growing labels slid the icons out from under the pointer and a
10799
+ // click meant for Pick landed on Insert. The title tooltip names the rest.
10800
+ function syncGlobalBarExpandedLabels() {
10801
+ applyGlobalBarLabelState(false, pageChatExpanded);
10771
10802
  }
10772
10803
 
10773
10804
  function pageChatCollapsedWidthPx() {
@@ -11173,7 +11204,7 @@ void main() {
11173
11204
  if (!pageChatEl || !pageChatInput) return false;
11174
11205
  pageChatExpanded = true;
11175
11206
  pageChatEl.dataset.expanded = 'true';
11176
- syncGlobalBarExpandedLabels(false);
11207
+ syncGlobalBarExpandedLabels();
11177
11208
  pageChatEl.style.width = pageChatExpandedWidth();
11178
11209
  pageChatEl.style.cursor = steerLocked ? 'default' : 'text';
11179
11210
  pageChatInput.placeholder = PAGE_CHAT_PLACEHOLDER_EXPANDED;
@@ -11316,6 +11347,7 @@ void main() {
11316
11347
  }
11317
11348
  steerPendingMessage = keepExpanded ? restoreMessage : '';
11318
11349
  steerInputWasFocused = false;
11350
+ syncGlobalBarExpandedLabels();
11319
11351
  syncPageChatChrome();
11320
11352
  syncPageChatFocusRing();
11321
11353
  if (opts?.error) showToast(String(opts.error), 5000);
@@ -11608,7 +11640,7 @@ void main() {
11608
11640
  pageChatEl.dataset.expanded = 'false';
11609
11641
  pageChatEl.style.width = PAGE_CHAT_COLLAPSED_W;
11610
11642
  pageChatEl.style.cursor = 'pointer';
11611
- syncGlobalBarExpandedLabels(globalBarEl?.matches(':hover'));
11643
+ syncGlobalBarExpandedLabels();
11612
11644
  if (blur) {
11613
11645
  pageChatInput.blur();
11614
11646
  pageChatInput.style.pointerEvents = 'none';
@@ -12054,7 +12086,7 @@ void main() {
12054
12086
  inner.id = PREFIX + '-global-bar-inner';
12055
12087
  globalBarEl.appendChild(inner);
12056
12088
 
12057
- // Button factory: icon-only at rest, label slides in on hover/active.
12089
+ // Button factory: icon-only at rest, label slides in while active.
12058
12090
  function makeIconBtn({ id, svg, label, ariaLabel, labelFont, onClick }) {
12059
12091
  const b = el('button', {
12060
12092
  position: 'relative',
@@ -12084,10 +12116,8 @@ void main() {
12084
12116
  if (!labelEl || (!force && b.dataset.active === 'true')) return;
12085
12117
  labelEl.style.maxWidth = '0'; labelEl.style.opacity = '0'; labelEl.style.marginLeft = '0'; labelEl.style.transform = 'translateX(-4px)';
12086
12118
  };
12087
- // Per-button hover only changes color (no layout). The label expand/
12088
- // collapse is driven by the bar-level mouseenter/mouseleave so moving
12089
- // the mouse between adjacent buttons doesn't trigger per-button width
12090
- // thrashing - the whole bar grows once and shrinks once.
12119
+ // Hover only changes color, never layout: the label shows while the
12120
+ // mode is active (see syncGlobalBarExpandedLabels).
12091
12121
  b.addEventListener('mouseenter', () => { if (b.dataset.active !== 'true') b.style.color = P.text; });
12092
12122
  b.addEventListener('mouseleave', () => { if (b.dataset.active !== 'true') b.style.color = P.textDim; });
12093
12123
  b.addEventListener('click', onClick);
@@ -12354,27 +12384,20 @@ void main() {
12354
12384
  color: P.textDim, fontFamily: FONT, fontSize: '0', lineHeight: '0',
12355
12385
  cursor: 'pointer', transition: 'color 0.12s ease, background 0.12s ease',
12356
12386
  });
12387
+ touchTarget(exitBtn);
12357
12388
  exitBtn.id = PREFIX + '-exit';
12358
12389
  exitBtn.innerHTML = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><line x1="3" y1="3" x2="11" y2="11"/><line x1="11" y1="3" x2="3" y2="11"/></svg>';
12359
12390
  exitBtn.title = 'Exit live mode';
12360
12391
  exitBtn.addEventListener('mouseenter', () => { exitBtn.style.color = 'oklch(58% 0.15 35)'; exitBtn.style.background = P.exitHover; });
12361
12392
  exitBtn.addEventListener('mouseleave', () => { exitBtn.style.color = P.textDim; exitBtn.style.background = 'transparent'; });
12362
- exitBtn.addEventListener('click', () => { sendEvent({ type: 'exit' }); teardown(); });
12393
+ // source: 'user' keeps a reconnect (the reload a carbonize edit triggers) from cancelling it.
12394
+ exitBtn.addEventListener('click', () => {
12395
+ try { sessionStorage.setItem(EXITED_KEY, TOKEN + ' ' + Date.now()); } catch { /* storage blocked */ }
12396
+ sendEvent({ type: 'exit', source: 'user' });
12397
+ teardown();
12398
+ });
12363
12399
  inner.appendChild(exitBtn);
12364
12400
 
12365
- // Bar-level hover: expand mode labels unless Steer is using the space.
12366
- // Buttons with dataset.active="true" ignore collapse (their label stays).
12367
- globalBarEl.addEventListener('mouseenter', () => {
12368
- syncGlobalBarExpandedLabels(true);
12369
- syncPageChatExpandedWidth();
12370
- schedulePendingDockPosition();
12371
- setTimeout(schedulePendingDockPosition, 260);
12372
- });
12373
- globalBarEl.addEventListener('mouseleave', () => {
12374
- syncGlobalBarExpandedLabels(false);
12375
- schedulePendingDockPosition();
12376
- setTimeout(schedulePendingDockPosition, 260);
12377
- });
12378
12401
  globalBarEl.addEventListener('pointerdown', () => {
12379
12402
  try { window.focus(); } catch { /* in-app preview may block */ }
12380
12403
  }, true);
@@ -12439,7 +12462,7 @@ void main() {
12439
12462
  // If the bar is currently under the cursor, keep all labels expanded -
12440
12463
  // otherwise clicking a toggle that deactivates (e.g. closing DESIGN.md)
12441
12464
  // would collapse its label while the user's mouse is still on the bar.
12442
- syncGlobalBarExpandedLabels(globalBarEl && globalBarEl.matches(':hover'));
12465
+ syncGlobalBarExpandedLabels();
12443
12466
 
12444
12467
  if (detectBadge) {
12445
12468
  detectBadge.style.display = (detectActive && detectCount > 0) ? 'inline' : 'none';
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.26.1-local.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#392](https://github.com/HerbertGao/pi-extensions/pull/392) [`e233ef6`](https://github.com/HerbertGao/pi-extensions/commit/e233ef6cee8184ff322521eae67bfa2b57bf483d) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Replay upstream pi-subagents 0.26.1. Reopening an agent keeps the model and thinking level from its session, and warns if Pi has to fall back. A mention clone shows the working directory once. The nested Agent tool lists the allowed agent types. A failed worktree cleanup and an unread result still stay recoverable.
8
+
3
9
  ## 0.26.0-local.1
4
10
 
5
11
  ### Minor Changes
@@ -228,7 +228,7 @@ Two things to weigh against `direct`: the clone re-sends the whole conversation,
228
228
 
229
229
  **Named agents.** The `Agent` tool takes an optional `name`, so the orchestrator can call one `auth-audit` instead of leaving you to tell `@explore-2` from `@explore-3`. A name is _additive_: the type-derived handle is still assigned, so `@explore` keeps reaching that agent rather than starting a second one beside it. Both names share one namespace — an alias can never shadow a live handle or the reverse — and the popup shows one row per agent, under its alias, with the type moved into the description. `steer_subagent` and `get_subagent_result` accept a handle too, so you and the model address agents the same way.
230
230
 
231
- **Resuming much later.** Because subagent sessions are persisted by default ([`rememberAgents`](#persistent-settings)), a handle keeps working after the agent's in-memory record is evicted: `@explore anything else?` reopens the conversation from disk. Only the _definition_ is re-resolved, so a continuation runs under the agent type's current frontmatter, not the one the first run used. If the type has since been deleted or disabled, the resume is refused rather than falling back to another agent — re-enable it and the handle works again. Names from an evicted agent stay reserved, so a later Explore becomes `explore-2` rather than shadowing something you can still reach; the 100 most recent are kept, and all of them are forgotten on `/new` and session switch. A resumed agent takes those names back, so `@explore` keeps meaning the same conversation. An agent whose session was only ever in memory leaves nothing to reopen, and the mention starts a fresh one instead; if the session file has since been deleted, the mention says so and frees the handle rather than silently sending your message to a new agent.
231
+ **Resuming much later.** Because subagent sessions are persisted by default ([`rememberAgents`](#persistent-settings)), a handle keeps working after the agent's in-memory record is evicted: `@explore anything else?` reopens the conversation from disk. Only the _definition_ is re-resolved, so a continuation runs under the agent type's current prompt and tools, not the ones the first run used. The model and thinking level are the ones the session recorded; if that model can no longer be used, pi falls back to its default and warns. If the type has since been deleted or disabled, the resume is refused rather than falling back to another agent — re-enable it and the handle works again. Names from an evicted agent stay reserved, so a later Explore becomes `explore-2` rather than shadowing something you can still reach; the 100 most recent are kept, and all of them are forgotten on `/new` and session switch. A resumed agent takes those names back, so `@explore` keeps meaning the same conversation. An agent whose session was only ever in memory leaves nothing to reopen, and the mention starts a fresh one instead; if the session file has since been deleted, the mention says so and frees the handle rather than silently sending your message to a new agent.
232
232
 
233
233
  The grammar mirrors Claude Code's, and is deliberately narrow so nothing gets swallowed by accident:
234
234
 
@@ -379,6 +379,8 @@ allowed_subagents: support-file-finder, support-callsite-tracer # or `all`
379
379
 
380
380
  **The allowlist is a privilege boundary, not just a routing hint.** A child runs with _its own_ `tools:`, `extensions:`, and `isolated:` — the parent's restrictions are not inherited — so delegation grants the parent the union of what the listed agents can do. The read-only agent above can write and run commands through any listed agent that can, and `all` reaches every enabled agent including `general-purpose`. Choose the list as carefully as you would choose `tools:` itself; that is the main reason this is default-off.
381
381
 
382
+ The nested `Agent` tool lists the allowed agent types with their descriptions and tools, as the main session's does, and follows [`toolDescriptionMode`](#persistent-settings) `"compact"`.
383
+
382
384
  `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
385
 
384
386
  `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:
@@ -493,20 +495,20 @@ Four rules define the feature:
493
495
 
494
496
  Launch a sub-agent.
495
497
 
496
- | Parameter | Type | Required | Description |
497
- | ------------------- | ----------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
498
- | `prompt` | string | yes | The task for the agent |
499
- | `description` | string | yes | Short 3-5 word summary (shown in UI) |
500
- | `name` | string | no | Memorable name for this agent (`auth-audit`), addressable as `@name` and accepted by `steer_subagent`/`get_subagent_result`. Additive — the type-derived handle is still assigned |
501
- | `subagent_type` | string | yes | Agent type (built-in or custom) |
502
- | `model` | string | no | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp interchangeable) with provider fallback |
503
- | `thinking` | string | no | Thinking level: off, minimal, low, medium, high, xhigh, max (availability depends on pi version and model) |
504
- | `max_turns` | number | no | Max agentic turns. Omit for unlimited (default) |
505
- | `run_in_background` | boolean | no | Defaults to `true`; `false` blocks and returns the result inline, until [`ctrl+b`](#sending-a-foreground-agent-to-the-background) hands it to the background |
506
- | `resume` | string | no | Agent ID to resume a previous session. The resumed run gets a fresh `max_turns` budget. Works after the agent's record is evicted (about ten minutes after it finishes) or lost to a reload: the agent is reopened from its saved session under the same id, running under its type's current definition and never in a new worktree. Refused, with the reason, when the session was never saved, its file is gone, or it ran in a worktree that held changes (the worktree was removed when the agent finished, and its changes are on the branch named in the result) |
507
- | `isolated` | boolean | no | No extension/MCP tools |
508
- | `isolation` | `"off"` \| `"worktree"` | no | `worktree` runs in an isolated git worktree; `off` (the default) does not. Absent from the schema entirely when `worktreeIsolation: false` |
509
- | `inherit_context` | boolean | no | Fork parent conversation into agent |
498
+ | Parameter | Type | Required | Description |
499
+ | ------------------- | ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
500
+ | `prompt` | string | yes | The task for the agent |
501
+ | `description` | string | yes | Short 3-5 word summary (shown in UI) |
502
+ | `name` | string | no | Memorable name for this agent (`auth-audit`), addressable as `@name` and accepted by `steer_subagent`/`get_subagent_result`. Additive — the type-derived handle is still assigned |
503
+ | `subagent_type` | string | yes | Agent type (built-in or custom) |
504
+ | `model` | string | no | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp interchangeable) with provider fallback |
505
+ | `thinking` | string | no | Thinking level: off, minimal, low, medium, high, xhigh, max (availability depends on pi version and model) |
506
+ | `max_turns` | number | no | Max agentic turns. Omit for unlimited (default) |
507
+ | `run_in_background` | boolean | no | Defaults to `true`; `false` blocks and returns the result inline, until [`ctrl+b`](#sending-a-foreground-agent-to-the-background) hands it to the background |
508
+ | `resume` | string | no | Agent ID to resume a previous session. The resumed run gets a fresh `max_turns` budget. The agent keeps its own type, model and thinking level; only `prompt`, `max_turns` and `run_in_background` apply. Works after the agent's record is evicted (about ten minutes after it finishes) or lost to a reload: the agent is reopened from its saved session under the same id, with its type's current prompt and tools, on the model and thinking level that session recorded, and never in a new worktree. If that model can no longer be used, pi falls back to its default model and warns. Refused, with the reason, when the session was never saved, its file is gone, or it ran in a worktree that held changes (the worktree was removed when the agent finished, and its changes are on the branch named in the result) |
509
+ | `isolated` | boolean | no | No extension/MCP tools |
510
+ | `isolation` | `"off"` \| `"worktree"` | no | `worktree` runs in an isolated git worktree; `off` (the default) does not. Absent from the schema entirely when `worktreeIsolation: false` |
511
+ | `inherit_context` | boolean | no | Fork parent conversation into agent |
510
512
 
511
513
  ### `SubagentWorkflow`
512
514
 
@@ -834,7 +836,7 @@ Leaving it unset is not quite the same as `true`. Unset means _auto_: on, unless
834
836
 
835
837
  The match is on the exact tool names `Workflow` (Claude Code's) and `SubagentWorkflow` (ours), never a substring, so a `list_workflows` or `github_workflow_run` from some CI integration does not silently take the feature down. The check runs at `session_start` and nowhere earlier, because `getAllTools` throws during extension loading and load order means a check at registration time could not see an extension that has not loaded yet — so the tool is registered first and withdrawn from the active set through `setActiveTools`, which rebuilds the system prompt before any turn runs. When the other extension took the `SubagentWorkflow` name itself, pi's first-registration-wins rule already dropped ours, so there is nothing to withdraw and only the menu and the CLI flag come down.
836
838
 
837
- **Tool description** (`toolDescriptionMode`, default `"full"`): which Agent tool description the LLM sees. `"full"` is the rich Claude Code-style prompt (~1,400 tokens with the default agents); `"compact"` is ~75% smaller — one-line agent type list, terse usage notes — for small/local models where tool-spec tokens are expensive. Per-option details stay in the parameter descriptions in every mode (the parameter schema is never customizable). Applies on the next pi session. For the `SubagentWorkflow` tool, the token saving is [`workflowToolExposure`](#persistent-settings) `"skill"` or `"deferred"`, below.
839
+ **Tool description** (`toolDescriptionMode`, default `"full"`): which Agent tool description the LLM sees. `"full"` is the rich Claude Code-style prompt (~1,400 tokens with the default agents); `"compact"` is ~75% smaller — one-line agent type list, terse usage notes — for small/local models where tool-spec tokens are expensive. Per-option details stay in the parameter descriptions in every mode (the parameter schema is never customizable). Applies on the next pi session (to nested `Agent` tools, on the next subagent started). For the `SubagentWorkflow` tool, the token saving is [`workflowToolExposure`](#persistent-settings) `"skill"` or `"deferred"`, below.
838
840
 
839
841
  `"custom"` registers your own description from `<cwd>/.pi/agent-tool-description.md` (project) or `<agentDir>/agent-tool-description.md` (global; project wins). The file is read once at tool registration, so edits also apply on the next pi session. Dynamic parts stay live via placeholders — a static agent list would go stale the moment you add a custom agent:
840
842
 
@@ -288,7 +288,7 @@ Any other key is rejected **by name** at the call. Note that this checks option
288
288
 
289
289
  Combination rules: `resume` cannot be combined with `agentType`, `model`, `effort`, `isolation`, `disallowedTools`, `gate` or `schema` — a resumed child keeps the agent type, model, tools and tree it was started with, and its session predates the `StructuredOutput` tool.
290
290
 
291
- A child stays resumable for the whole run. The manager evicts a finished child's record about ten minutes after it settles, and a review or a merge queue easily takes longer; `resume` then reopens the child's saved session under the same id, still owned by the run. That reopen runs under the agent type's current definition, so the model and tree the script chose for the first run are not carried over. It fails, resolving to `null` with the reason on that agent's row in the card and the inspector, when the child's session was never saved (`rememberAgents` off, or `persist_session: false`), its file is gone, or it ran with `isolation: "worktree"` and left changes: that worktree was removed when the child finished, with its changes on a branch, and continuing the work anywhere else would split it. A child whose worktree held no changes reopens in the run's directory, as in Claude Code.
291
+ A child stays resumable for the whole run. The manager evicts a finished child's record about ten minutes after it settles, and a review or a merge queue easily takes longer; `resume` then reopens the child's saved session under the same id, still owned by the run. That reopen keeps the model and effort the child's session recorded, so the script's choice for the first run carries over. It runs under the agent type's current prompt and tools, and never in a new worktree. It fails, resolving to `null` with the reason on that agent's row in the card and the inspector, when the child's session was never saved (`rememberAgents` off, or `persist_session: false`), its file is gone, or it ran with `isolation: "worktree"` and left changes: that worktree was removed when the child finished, with its changes on a branch, and continuing the work anywhere else would split it. A child whose worktree held no changes reopens in the run's directory, as in Claude Code.
292
292
 
293
293
  ### `agentError(label)`
294
294
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.26.0-local.1",
3
+ "version": "0.26.1-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",
@@ -74,10 +74,10 @@
74
74
  },
75
75
  "x-upstream": {
76
76
  "package": "@tintinweb/pi-subagents",
77
- "version": "0.26.0",
78
- "reviewedVersion": "0.26.0",
77
+ "version": "0.26.1",
78
+ "reviewedVersion": "0.26.1",
79
79
  "repository": "https://github.com/tintinweb/pi-subagents",
80
- "commit": "dbbd769781847f9c0f74ba2a8545ff33c4b26e7c",
80
+ "commit": "14ef1946b439ad2c7e7db618ecdb36f5532052e7",
81
81
  "trackVersion": true
82
82
  }
83
83
  }
@@ -1314,17 +1314,26 @@ export async function runAgent(
1314
1314
  }
1315
1315
  }
1316
1316
 
1317
- // Resolve model: explicit option > config.model > parent model
1317
+ // A reopened conversation carries the model and thinking level it ran with,
1318
+ // and createAgentSession restores both when none is passed — so a reopen keeps
1319
+ // them, as a live resume keeps its session's (#462). Only an explicit option
1320
+ // outranks them; the agent file and the parent do not.
1321
+ const reopening = options.resumeSessionFile !== undefined
1322
+
1323
+ // Resolve model: explicit option > (reopen: the session's own) > config.model > parent model
1318
1324
  const model =
1319
1325
  options.model ??
1320
- resolveDefaultModel(ctx.model, ctx.modelRegistry, agentConfig?.model)
1326
+ (reopening
1327
+ ? undefined
1328
+ : resolveDefaultModel(ctx.model, ctx.modelRegistry, agentConfig?.model))
1321
1329
 
1322
- // Resolve thinking level: explicit option > agent config > parent session level.
1330
+ // Resolve thinking level: explicit option > (reopen: the session's own) > agent config > parent session level.
1323
1331
  // Without the parent step, an unset level falls through to pi's
1324
1332
  // defaultThinkingLevel (e.g. "max") instead of matching the spawning session.
1325
1333
  // Same idiom as mention-clone.ts.
1326
1334
  const thinkingLevel =
1327
- options.thinkingLevel ?? agentConfig?.thinking ?? ctx.thinkingLevel
1335
+ options.thinkingLevel ??
1336
+ (reopening ? undefined : (agentConfig?.thinking ?? ctx.thinkingLevel))
1328
1337
 
1329
1338
  // The `agent({ schema })` contract: this child reports its answer by calling
1330
1339
  // StructuredOutput, and `structuredJson` below is what the caller reads. The
@@ -1536,9 +1545,13 @@ export async function runAgent(
1536
1545
  sessionOpts.thinkingLevel = thinkingLevel
1537
1546
  }
1538
1547
 
1539
- const { session } = await runInChildSessionContext(() =>
1548
+ const { session, modelFallbackMessage } = await runInChildSessionContext(() =>
1540
1549
  createAgentSession(sessionOpts),
1541
1550
  )
1551
+ // Pi could not use the model the reopened conversation recorded and fell back
1552
+ // to its default. Warned the way pi warns at its own session start, and the
1553
+ // way an out-of-scope model is warned: to the user, not the model.
1554
+ if (modelFallbackMessage) ctx.ui.notify(modelFallbackMessage, "warning")
1542
1555
 
1543
1556
  const baseSessionName = agentConfig?.name ?? type
1544
1557
  session.setSessionName(
@@ -10,6 +10,7 @@ import {
10
10
  createReadOnlyTools,
11
11
  } from "@earendil-works/pi-coding-agent"
12
12
  import { DEFAULT_AGENTS } from "./default-agents.js"
13
+ import type { ToolDescriptionMode } from "./settings.js"
13
14
  import type { AgentConfig } from "./types.js"
14
15
 
15
16
  /**
@@ -387,3 +388,90 @@ export function getConfig(type: string): {
387
388
  promptMode: "append",
388
389
  }
389
390
  }
391
+
392
+ /**
393
+ * Which Agent tool description the LLM sees (#91). Module state rather than an
394
+ * index.ts closure because nested `Agent` tools, built per subagent session,
395
+ * follow it too. Read when a tool is built.
396
+ */
397
+ let toolDescriptionMode: ToolDescriptionMode = "full"
398
+
399
+ export function getToolDescriptionMode(): ToolDescriptionMode {
400
+ return toolDescriptionMode
401
+ }
402
+ export function setToolDescriptionMode(mode: ToolDescriptionMode): void {
403
+ toolDescriptionMode = mode
404
+ }
405
+
406
+ /** Derive a short model label from a model string. */
407
+ export function getModelLabelFromConfig(model: string): string {
408
+ // Strip provider prefix (e.g. "anthropic/claude-sonnet-4-6" → "claude-sonnet-4-6")
409
+ const name = model.includes("/") ? model.split("/").pop()! : model
410
+ // Strip trailing date suffix (e.g. "claude-haiku-4-5-20251001" → "claude-haiku-4-5")
411
+ return name.replace(/-\d{8}$/, "")
412
+ }
413
+
414
+ /** First sentence of an agent description — for the compact type list. */
415
+ function firstSentence(text: string): string {
416
+ const match = text.match(/^.*?[.!?](?=\s|$)/s)
417
+ return (match ? match[0] : text).replace(/\s+/g, " ").trim()
418
+ }
419
+
420
+ /**
421
+ * The "Available agent types" list in an Agent tool description, one line per
422
+ * name. Full lines carry the description, the model label and the tool scope;
423
+ * compact lines the description's first sentence and the tool scope.
424
+ */
425
+ export function formatAgentTypeList(
426
+ names: string[],
427
+ lookup: (name: string) => AgentConfig | undefined,
428
+ compact: boolean,
429
+ ): string {
430
+ return names
431
+ .map((name) => {
432
+ const cfg = lookup(name)
433
+ const tools = ` (Tools: ${formatToolsSuffix(cfg)})`
434
+ if (compact)
435
+ return `- ${name}: ${firstSentence(cfg?.description ?? name)}${tools}`
436
+ const model = cfg?.model ? ` (${getModelLabelFromConfig(cfg.model)})` : ""
437
+ return `- ${name}: ${cfg?.description ?? name}${model}${tools}`
438
+ })
439
+ .join("\n")
440
+ }
441
+
442
+ /**
443
+ * Format an agent's tool scope for the Agent tool description.
444
+ *
445
+ * This suffix describes BUILT-IN scope only — extension tools are resolved when
446
+ * the agent runs (extensions can register asynchronously), so they cannot be
447
+ * enumerated while the description is being built. That is why an agent with
448
+ * `tools: "*, ext:mcp/search"` renders "*" and always has.
449
+ *
450
+ * Two distinctions matter, both of them capability claims the orchestrator acts on:
451
+ *
452
+ * - absent vs empty. `builtinToolNames: undefined` means the agent never narrowed
453
+ * its tools (the shipped defaults); `[]` is what `tools: none` and an `ext:`-only
454
+ * `tools:` parse to, and the runtime really does hand those agents no built-ins.
455
+ * Rendering both "*" tells the orchestrator a tool-less agent can run `bash`.
456
+ * - empty-with-extensions vs empty-without. Zero built-ins does NOT imply zero
457
+ * tools: `tools: none` alongside `extensions:` still surfaces every extension
458
+ * tool (see test/fixtures/.pi/agents/tools-none.md, which expects three). Calling
459
+ * that "none" understates the agent instead of overstating it — better, but still
460
+ * wrong, and it would route work away from the only agent able to do it. "none"
461
+ * is therefore reserved for agents that genuinely can call nothing: `isolated`
462
+ * agents and those with `extensions: false`.
463
+ */
464
+ export function formatToolsSuffix(cfg: AgentConfig | undefined): string {
465
+ const tools = cfg?.builtinToolNames
466
+ if (!tools) return "*"
467
+ if (tools.length === 0) {
468
+ // `isolated` overrides extensions to false in the runner, so both mean the
469
+ // agent has no extension tools either — and then it truly has nothing.
470
+ const noExtensionTools = cfg?.isolated === true || cfg?.extensions === false
471
+ return noExtensionTools ? "none" : "no built-ins, extension tools only"
472
+ }
473
+ const isFullSet =
474
+ tools.length === BUILTIN_TOOL_NAMES.length &&
475
+ BUILTIN_TOOL_NAMES.every((t) => tools.includes(t))
476
+ return isFullSet ? "*" : tools.join(", ")
477
+ }