@herbertgao/pi-extensions 2026.11.0 → 2026.11.2

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 +768 -0
  2. package/README.md +7 -7
  3. package/THIRD_PARTY_NOTICES.md +2 -2
  4. package/extensions/clef.mjs +1 -1
  5. package/node_modules/@herbertgao/pi-agency/CHANGELOG.md +19 -0
  6. package/node_modules/@herbertgao/pi-agency/package.json +4 -2
  7. package/node_modules/@herbertgao/pi-agency/src/index.ts +1 -1
  8. package/node_modules/@herbertgao/pi-bark/CHANGELOG.md +52 -0
  9. package/node_modules/@herbertgao/pi-bark/package.json +2 -1
  10. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +207 -0
  11. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +7 -5
  12. package/node_modules/@herbertgao/pi-cc-extensions/README.md +10 -7
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +20 -0
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +61 -6
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary/core.ts +11 -16
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary/index.ts +60 -11
  17. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +29 -11
  18. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer-layout.ts +54 -6
  19. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +23 -5
  20. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/session-tokens.ts +52 -0
  21. package/node_modules/@herbertgao/pi-cc-extensions/package.json +5 -4
  22. package/node_modules/@herbertgao/pi-impeccable/CHANGELOG.md +13 -0
  23. package/node_modules/@herbertgao/pi-impeccable/package.json +2 -1
  24. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  25. package/node_modules/@herbertgao/pi-subagents/README.md +43 -33
  26. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +1 -1
  27. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +2 -0
  28. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  29. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +9 -8
  30. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +70 -9
  31. package/node_modules/@herbertgao/pi-subagents/src/agent-record-entry.ts +167 -0
  32. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +156 -13
  33. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +52 -8
  34. package/node_modules/@herbertgao/pi-subagents/src/default-agents.ts +3 -4
  35. package/node_modules/@herbertgao/pi-subagents/src/index.ts +153 -56
  36. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +3 -2
  37. package/node_modules/@herbertgao/pi-subagents/src/status-note.ts +3 -1
  38. package/node_modules/@herbertgao/pi-subagents/src/types.ts +5 -0
  39. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +88 -6
  40. package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +3 -2
  41. package/node_modules/@herbertgao/sol-pi/CHANGELOG.md +84 -0
  42. package/node_modules/@herbertgao/sol-pi/README.md +3 -3
  43. package/node_modules/@herbertgao/sol-pi/THIRD_PARTY_NOTICES.md +4 -4
  44. package/node_modules/@herbertgao/sol-pi/agents-install.md +3 -3
  45. package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +1 -1
  46. package/node_modules/@herbertgao/sol-pi/package.json +2 -1
  47. package/node_modules/pi-provider-qoder/README.md +40 -0
  48. package/node_modules/pi-provider-qoder/dist/index.js +69 -1
  49. package/node_modules/pi-provider-qoder/package.json +4 -3
  50. package/node_modules/pi-typesafe/README.md +3 -3
  51. package/node_modules/pi-typesafe/dist/auth.d.ts +21 -4
  52. package/node_modules/pi-typesafe/dist/auth.js +32 -7
  53. package/node_modules/pi-typesafe/dist/backends.d.ts +2 -2
  54. package/node_modules/pi-typesafe/dist/backends.js +9 -0
  55. package/node_modules/pi-typesafe/dist/client.js +7 -12
  56. package/node_modules/pi-typesafe/dist/errors.d.ts +3 -2
  57. package/node_modules/pi-typesafe/dist/errors.js +12 -10
  58. package/node_modules/pi-typesafe/dist/extension.js +14 -10
  59. package/node_modules/pi-typesafe/package.json +1 -1
  60. package/package.json +10 -9
@@ -4,7 +4,7 @@
4
4
  * 默认第一行:model thinking · ██████░░░░ 45%/200k · 󰆼 42% · $0.01 · pi-usage · 其余 line1 芯片
5
5
  * 默认第二行:cwd in session ·  branch (+16 −1) · 其余 line2 芯片
6
6
  * 第三行:仅当 line3 有可见芯片时出现
7
- * model / context / cache / rate / cost / cwd / git 与插件芯片同一套排布,可换行、调序、隐藏
7
+ * model / context / cache / rate / cost / tokens / cwd / git 与插件芯片同一套排布,可换行、调序、隐藏
8
8
  *
9
9
  * - line1 短芯片,· 分隔;缓存用 zentui 󰆼,费用 success
10
10
  * - line2 用 zentui 句式 in / on + 
@@ -31,6 +31,7 @@ import {
31
31
  FOOTER_GIT_KEY,
32
32
  FOOTER_MODEL_KEY,
33
33
  FOOTER_RATE_KEY,
34
+ FOOTER_TOKENS_KEY,
34
35
  PI_USAGE_KEY,
35
36
  isBuiltinFooterKey,
36
37
  isSkippedFooterStatusKey,
@@ -39,6 +40,7 @@ import {
39
40
  type FooterChipLayout,
40
41
  } from "./footer-layout.ts";
41
42
  import { createGitStatsRefresher, readGitStats, type GitStats } from "./git-stats.ts";
43
+ import { formatSessionTokenTotal, sessionEntryTokens } from "./session-tokens.ts";
42
44
  import { MCP_STATUS_KEY, buildMcpChip } from "./mcp-chip.ts";
43
45
  import { inputTextIndent } from "./prompt-editor.ts";
44
46
  import { currentTtftMs, displayTokenRate, formatTokenRate } from "./token-rate.ts";
@@ -391,7 +393,12 @@ const createCustomFooterFactory =
391
393
  let statsMemoKey = "";
392
394
  let statsMemoAt = 0;
393
395
  let statsMemo:
394
- | { contextUsage: ReturnType<typeof ctx.getContextUsage>; cost: number; cachePct: number }
396
+ | {
397
+ contextUsage: ReturnType<typeof ctx.getContextUsage>;
398
+ cost: number;
399
+ tokens: number;
400
+ cachePct: number;
401
+ }
395
402
  | undefined;
396
403
  const sessionStats = () => {
397
404
  const model = ctx.model;
@@ -404,19 +411,28 @@ const createCustomFooterFactory =
404
411
  return statsMemo;
405
412
  }
406
413
  let cost = 0;
414
+ let tokens = 0;
407
415
  for (const entry of ctx.sessionManager.getEntries()) {
408
416
  if (entry.type === "message") {
409
417
  const m = entry.message;
410
418
  if (m.role === "assistant") cost += m.usage?.cost?.total || 0;
411
419
  else if (m.role === "toolResult" && m.usage) cost += m.usage.cost?.total || 0;
412
420
  } else if (
413
- (entry.type === "branch_summary" || entry.type === "compaction") &&
421
+ (entry.type === "branch_summary" ||
422
+ entry.type === "compaction" ||
423
+ entry.type === "usage") &&
414
424
  entry.usage
415
425
  ) {
416
426
  cost += entry.usage.cost?.total || 0;
417
427
  }
428
+ tokens += sessionEntryTokens(entry);
418
429
  }
419
- statsMemo = { contextUsage: ctx.getContextUsage(), cost, cachePct: getCachePct() };
430
+ statsMemo = {
431
+ contextUsage: ctx.getContextUsage(),
432
+ cost,
433
+ tokens,
434
+ cachePct: getCachePct(),
435
+ };
420
436
  statsMemoKey = key;
421
437
  statsMemoAt = performance.now();
422
438
  return statsMemo;
@@ -424,7 +440,7 @@ const createCustomFooterFactory =
424
440
 
425
441
  const render = (width: number): string[] => {
426
442
  const model = ctx.model;
427
- const { contextUsage, cost, cachePct } = sessionStats();
443
+ const { contextUsage, cost, tokens, cachePct } = sessionStats();
428
444
  const contextWindow = contextUsage?.contextWindow ?? model?.contextWindow ?? 0;
429
445
  const percent = contextUsage?.percent;
430
446
 
@@ -471,6 +487,7 @@ const createCustomFooterFactory =
471
487
  const costChip = costLabel
472
488
  ? theme.fg("dim", costLabel) + (usingSubscription ? theme.fg("warning", " sub") : "")
473
489
  : "";
490
+ const tokensLabel = config.footerSessionTokens ? formatSessionTokenTotal(tokens) : "";
474
491
 
475
492
  const gitColor = theme.getThinkingBorderColor("medium");
476
493
  let place = theme.fg("accent", cwdLabel);
@@ -508,6 +525,7 @@ const createCustomFooterFactory =
508
525
  [FOOTER_CACHE_KEY, cacheLabel ? theme.fg("dim", cacheLabel) : ""],
509
526
  [FOOTER_RATE_KEY, rateLabel ? theme.fg("dim", rateLabel) : ""],
510
527
  [FOOTER_COST_KEY, costChip],
528
+ [FOOTER_TOKENS_KEY, tokensLabel ? theme.fg("dim", tokensLabel) : ""],
511
529
  [FOOTER_CWD_KEY, place],
512
530
  [FOOTER_GIT_KEY, gitChip],
513
531
  ]);
@@ -0,0 +1,52 @@
1
+ /**
2
+ * footer 的会话累计 token:统计 `sessionManager.getEntries()` 里每条条目的 usage。
3
+ *
4
+ * 口径是 `usage.totalTokens` 累加(输入 + 输出 + 缓存读 + 缓存写),
5
+ * 覆盖 assistant / toolResult 消息,以及 compaction、branch_summary 与 `usage` 条目
6
+ * 自己那次 LLM 调用的开销。整个会话全量累加,不沿当前分支裁剪:
7
+ * 回退/重发放弃的节点也算进「这次对话烧掉了多少 token」。
8
+ */
9
+
10
+ import { formatTokenCount } from "../../utils/format.ts";
11
+
12
+ type UnknownRecord = Record<string, unknown>;
13
+
14
+ function asRecord(value: unknown): UnknownRecord | undefined {
15
+ return value && typeof value === "object" ? (value as UnknownRecord) : undefined;
16
+ }
17
+
18
+ /** `usage.totalTokens` 优先;缺失时用四项相加,非数字一律忽略。 */
19
+ export function usageTokenTotal(usage: unknown): number {
20
+ const record = asRecord(usage);
21
+ if (!record) return 0;
22
+ const total = record.totalTokens;
23
+ if (typeof total === "number" && Number.isFinite(total) && total > 0) return total;
24
+ let sum = 0;
25
+ for (const key of ["input", "output", "cacheRead", "cacheWrite"] as const) {
26
+ const part = record[key];
27
+ if (typeof part === "number" && Number.isFinite(part) && part > 0) sum += part;
28
+ }
29
+ return sum;
30
+ }
31
+
32
+ /** 一条会话条目贡献的 token;user/system/自定义条目不消费 LLM token,返回 0。 */
33
+ export function sessionEntryTokens(entry: unknown): number {
34
+ const record = asRecord(entry);
35
+ if (!record) return 0;
36
+ if (record.type === "message") {
37
+ const message = asRecord(record.message);
38
+ if (!message) return 0;
39
+ if (message.role !== "assistant" && message.role !== "toolResult") return 0;
40
+ return usageTokenTotal(message.usage);
41
+ }
42
+ if (record.type === "compaction" || record.type === "branch_summary" || record.type === "usage") {
43
+ return usageTokenTotal(record.usage);
44
+ }
45
+ return 0;
46
+ }
47
+
48
+ /** 芯片文案:`∑ 402k`;没有数据返回空串(不占位置)。 */
49
+ export function formatSessionTokenTotal(total: number): string {
50
+ if (!Number.isFinite(total) || total <= 0) return "";
51
+ return `∑ ${formatTokenCount(Math.round(total))}`;
52
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-cc-extensions",
3
- "version": "1.0.12-local.1",
3
+ "version": "1.0.13-local.1",
4
4
  "license": "MIT",
5
5
  "description": "A Pi productivity suite with Claude Code-style UI, context inspection, and agent/session references",
6
6
  "type": "module",
@@ -26,6 +26,7 @@
26
26
  "themes",
27
27
  "README.md",
28
28
  "README.en.md",
29
+ "CHANGELOG.md",
29
30
  "LICENSE"
30
31
  ],
31
32
  "pi": {
@@ -71,10 +72,10 @@
71
72
  },
72
73
  "x-upstream": {
73
74
  "package": "pi-cc-extensions",
74
- "version": "1.0.12",
75
- "reviewedVersion": "1.0.12",
75
+ "version": "1.0.13",
76
+ "reviewedVersion": "1.0.13",
76
77
  "repository": "https://github.com/minuque/pi-cc-extensions",
77
- "commit": "90957cd445403bc493e8aaee2231e1932ac26d46",
78
+ "commit": "2ee840f0049be01e352a86f96a6c6e8be9f74670",
78
79
  "trackVersion": true
79
80
  }
80
81
  }
@@ -0,0 +1,13 @@
1
+ # @herbertgao/pi-impeccable
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#346](https://github.com/HerbertGao/pi-extensions/pull/346) [`641894f`](https://github.com/HerbertGao/pi-extensions/commit/641894ff5dc34a38ab41905f27a3077cc865ab91) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Document Pi 1.5.0 as the tested host and publish each package changelog so Pi can show Extension Updates after an update. Agency tools and clef keep the same TypeBox schemas, built from typebox because Pi 1.5 no longer re-exports Type. Peer ranges stay open. The BTW fullscreen handoff resolves `@narumitw/pi-tui-kit@0.68.1` inside the existing `^0.68.0` range.
8
+
9
+ ## 0.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#331](https://github.com/HerbertGao/pi-extensions/pull/331) [`12c8680`](https://github.com/HerbertGao/pi-extensions/commit/12c86808bf7084d4fab6f90d6bac17a2531585ce) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Vendor the official Impeccable 4.8.0 Pi skill as `@herbertgao/pi-impeccable` and include it in the aggregate package.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-impeccable",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "The Impeccable design skill for Pi, vendored from the official release.",
5
5
  "keywords": [
6
6
  "design",
@@ -27,6 +27,7 @@
27
27
  "files": [
28
28
  "skills",
29
29
  "README.md",
30
+ "CHANGELOG.md",
30
31
  "LICENSE",
31
32
  "NOTICE.md"
32
33
  ],
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.23.0-local.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#350](https://github.com/HerbertGao/pi-extensions/pull/350) [`7cda824`](https://github.com/HerbertGao/pi-extensions/commit/7cda82499d91253636153397d00d63ad7d40ace6) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Replay subagents onto upstream 0.23.0. A direct mention of an agent that inherits context now includes the conversation. Resume reopens an evicted agent from its saved session, and a saved result still answers after the live record is gone. Explore uses the session model. Claude Code tool names and bare MCP tool entries select the tools they name. Unconsumed results and a failed worktree cleanup still stay recoverable.
8
+
3
9
  ## 0.22.1-local.1
4
10
 
5
11
  ### Minor Changes
@@ -214,12 +214,12 @@ It is a literal clone — the session's own entries and the same system prompt,
214
214
  | Mode | `@plan sketch the migration`, with no Plan agent running |
215
215
  | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
216
216
  | `model` (default) | a clone of this conversation takes the turn off-screen and calls `Agent`, so the agent starts with a prompt **written from the conversation**. Nothing reaches the chat but a `Prompting @plan…` toast — the wording marks the wait for that turn, where `direct`'s `Started @plan` means it is already running |
217
- | `direct` | the agent starts here, immediately, with your message verbatim as its prompt. No model call at all, so no latency before it begins |
217
+ | `direct` | the agent starts here, immediately, with your message verbatim as its prompt (after this conversation, if its file sets `inherit_context`). No model call at all, so no latency before it begins |
218
218
  | `off` | `@` means only "attach a file" again |
219
219
 
220
- Either way the started agent honours its own frontmatter — `model:`, `thinking:`, `max_turns:` all apply, since neither path passes them and the agent's config wins. Mentioning something as the very first thing in a session works: there is simply no history to carry, and the clone still runs on your model and system prompt. If it cannot deliver at all — a model can always answer in prose instead of calling the tool — the agent is started directly with your text and the toast says so, rather than leaving you with nothing running.
220
+ Either way the started agent honours its own frontmatter — `model:`, `thinking:`, `max_turns:` all apply, since neither path passes them and the agent's config wins, and `inherit_context: true` hands it this conversation even in `direct` mode. Mentioning something as the very first thing in a session works: there is simply no history to carry, and the clone still runs on your model and system prompt. If it cannot deliver at all — a model can always answer in prose instead of calling the tool — the agent is started directly with your text and the toast says so, rather than leaving you with nothing running.
221
221
 
222
- `model` is also the only mode that works outside the TUI: `pi -p '@plan the migration'` clones, spawns, and reports through the normal completion path, where a direct start would have detached the agent and printed nothing. Messaging and resuming stay TUI-only for that reason, in both modes.
222
+ Mentions are TUI-only. In `pi -p '@plan the migration'`, pi itself reads the leading `@plan` as a file to attach and exits with `File not found` before any extension sees the prompt. For a headless run, ask for the agent in plain words so the model calls the `Agent` tool, or use [`--subagents-workflow-file`](#cli-flags).
223
223
 
224
224
  Two things to weigh against `direct`: the clone re-sends the whole conversation, and the agent does not start until that turn finishes.
225
225
 
@@ -269,15 +269,15 @@ Group completions render each agent as a separate block. The LLM receives struct
269
269
 
270
270
  ## Default Agent Types
271
271
 
272
- | Type | Tools | Model | Prompt Mode | Description |
273
- | ----------------- | -------------------------- | ----------------------------- | ---------------------- | ------------------------------------------------------------------------------------- |
274
- | `general-purpose` | all 7 | inherit | `append` (parent twin) | Inherits the parent's full system prompt — same rules, CLAUDE.md, project conventions |
275
- | `Explore` | read, bash, grep, find, ls | haiku (falls back to inherit) | `replace` (standalone) | Fast codebase exploration (read-only) |
276
- | `Plan` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Software architect for implementation planning (read-only) |
272
+ | Type | Tools | Model | Prompt Mode | Description |
273
+ | ----------------- | -------------------------- | ------- | ---------------------- | ------------------------------------------------------------------------------------- |
274
+ | `general-purpose` | all 7 | inherit | `append` (parent twin) | Inherits the parent's full system prompt — same rules, CLAUDE.md, project conventions |
275
+ | `Explore` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Fast codebase exploration (read-only) |
276
+ | `Plan` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Software architect for implementation planning (read-only) |
277
277
 
278
278
  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.
279
279
 
280
- 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.
280
+ 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.
281
281
 
282
282
  ## Custom Agents
283
283
 
@@ -334,12 +334,12 @@ All fields are optional — sensible defaults for everything.
334
334
  | `name` | filename | **The agent's type** — what `subagent_type` and `@handle` address. Claude Code's rule: the filename doesn't have to match, so `blubb.md` with `name: code-review` dispatches as `code-review`. Omit it and the filename is used. Any value works except one containing `:`, which Claude Code reserves for plugin-scoped identifiers — such a file is skipped with a warning. Two files may declare the same name; the later load wins, as a filename clash always did |
335
335
  | `display_name` | the type | Label shown in the UI (widget, agent list, badges) — cosmetic only, and independent of `name`. Claude Code has no equivalent; a file that sets only `name` badges as its type, unchanged |
336
336
  | `color` | — | Background color for the agent name badge in the Agent tool header, widget, FleetView, and conversation viewer. Supports Claude Code's `red`, `blue`, `green`, `yellow`, `purple`, `orange`, `pink`, `cyan` (the values its own default theme uses); quoted six-digit hex such as `"#8B5CF6"`; and Agency Agents aliases (`amber`, `teal`, `indigo`, `gold`, `neon-green`, `neon-cyan`, `metallic-blue`, `violet`, `rose`, `lime`, `gray`/`grey`, `fuchsia`, `slate`, `navy`). Badge text is black or white, whichever clears 4.5:1 against the rendered background — Claude Code uses one inverse color for every badge. Invalid values render no badge and preserve each surface's existing theme foreground |
337
- | `tools` | all 7 | Which tools the agent can call. Built-in names (`read, grep, …`), `*` / `all` (all built-ins), `none`, and `ext:<extension>` / `ext:<extension>/<tool>` selectors for extension tools. See [Tool & extension scoping](#tool--extension-scoping) below |
337
+ | `tools` | all 7 | Which tools the agent can call. Built-in names (`read, grep, …`, or Claude Code's `Read, Glob, …`), `*` / `all` (all built-ins), `none`, `ext:<extension>` / `ext:<extension>/<tool>` selectors for extension tools, and bare `mcp__<server>__<tool>` entries for MCP tools. See [Tool & extension scoping](#tool--extension-scoping) below |
338
338
  | `extensions` | `true` | Which extensions to load for the agent. `true` (all defaults), `false` (none), or an explicit list: `[mcp, "/abs/path.ts", "*"]`. See [Tool & extension scoping](#tool--extension-scoping) below |
339
339
  | `exclude_extensions` | — | Extension denylist applied after `extensions:` — exclude wins. Plain names only (case-insensitive), no paths or `*`. Useful with `extensions: true` to drop one extension (e.g. `pi-notify`) |
340
340
  | `skills` | `true` | `true` inherits the parent's skills; `false` inherits none. A comma-separated list preloads **only** those skills into the system prompt and does not inherit the rest (see [Skill Preloading](#skill-preloading) for discovery locations) |
341
341
  | `memory` | — | Persistent agent memory scope: `project`, `local`, or `user`. Auto-detects read-only agents |
342
- | `disallowed_tools` | — | Comma-separated tools to deny even if extensions provide them |
342
+ | `disallowed_tools` | — | Comma-separated tools to deny even if extensions provide them. Claude Code's `disallowedTools` key and tool names (`Write`, `Glob`) work too |
343
343
  | `isolation` | — | Set to `worktree` to run in an isolated git worktree, or `off` to refuse one even when the caller passes `isolation: "worktree"` (frontmatter is authoritative). Workflow scripts are the exception: as in Claude Code, only their `agent()` option decides. `none`, `no`, and `false` are accepted spellings of `off` |
344
344
  | `model` | inherit parent | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp are interchangeable) and falls back to the same model under another provider if the named one doesn't have it |
345
345
  | `thinking` | inherit | off, minimal, low, medium, high, xhigh, max — actual availability depends on your pi version and model; pi clamps unsupported levels down |
@@ -358,7 +358,7 @@ Frontmatter is authoritative. If an agent file sets `model`, `thinking`, `max_tu
358
358
 
359
359
  - `isolated` holds on every spawn path, including `@handle` mentions, workflows and [cross-extension RPC](https://github.com/HerbertGao/pi-extensions/blob/master/packages/pi-subagents/docs/rpc.md).
360
360
  - `isolation` holds on every path except workflows: as in Claude Code, only the script's `agent()` option decides there.
361
- - `inherit_context` applies only to `Agent` tool and nested spawns, including default-mode `@handle` mentions, which spawn through the `Agent` tool. As in Claude Code, where only a fork inherits the conversation, every other spawn starts fresh unless its caller asks: workflow children and scheduled runs never inherit, and an RPC caller opts in with `inheritContext`.
361
+ - `inherit_context` holds wherever you start the agent from this session: `Agent` tool and nested spawns, and `@handle` mentions in either mode. Spawns another caller starts are its caller's to decide, as in Claude Code, where only a fork inherits the conversation: workflow children and scheduled runs never inherit, and an RPC caller opts in with `inheritContext`.
362
362
 
363
363
  **Forgiving `model:` resolution.** A `model:` pin is matched against pi's model registry tolerantly, so cosmetic id variations don't silently drop the agent back to the parent's model: `.` and `-` are treated as equivalent in version numbers (`claude-haiku-4.5` ≡ `claude-haiku-4-5`), a trailing `-YYYYMMDD` date stamp is optional (`anthropic/claude-haiku-4-5-20251001` matches an undated registry id and vice-versa), and a `provider/modelId` whose named provider doesn't carry that model retries the bare id against every provider. Precedence is **exact → fuzzy under the named provider → same model under any provider → unavailable**, so an exact match always wins and dated snapshots aren't conflated. If nothing resolves, the pin can't run and the agent inherits the parent model — `/agents → Agent types` flags this case as `(unavailable, fallback: inherit)` and shows the resolved target `(→ provider/id)` when resolution lands on a different provider or version than configured. (This is distinct from [Model Scope](#model-scope) enforcement, which matches the `enabledModels` allowlist by _exact_ entry.)
364
364
 
@@ -395,6 +395,8 @@ tools: read, grep, find # narrow to listed built-ins; extensions still load
395
395
  tools: "*" # all 7 built-ins (alias: `all`)
396
396
  tools: none # zero built-ins (alias: `""`)
397
397
  tools: "*, ext:mcp/search" # built-ins plus one extension tool
398
+ tools: Read, Grep, Glob # Claude Code names: read, grep, find
399
+ tools: "read, mcp__radius__*" # read plus the radius MCP server's tools
398
400
 
399
401
  extensions: false # no extensions load
400
402
  extensions: [mcp] # only mcp loads
@@ -416,24 +418,27 @@ A few rules the examples don't make obvious:
416
418
  - `extensions:` is the sole loading authority. `ext:foo` in `tools:` narrows what surfaces; it can't load `foo` on its own. Mismatches fire `extension-error:…` warnings.
417
419
  - Any `ext:` entry flips extension tools to an explicit allowlist — unnamed extensions still load (handlers fire) but expose no tools. So `tools: "*, ext:mcp/search"` exposes only `search` from `mcp`, nothing from any other extension.
418
420
  - Extension names match case-insensitively (`[Mcp]` = `[mcp]`); tool names in `ext:foo/bar` stay case-sensitive.
421
+ - Claude Code agent files work as written. Built-in names match case-insensitively (`Read` = `read`), `Glob` means `find` and `MultiEdit` means `edit`; Claude Code tools pi lacks (`WebFetch`, `Task`) fire a `tools-error:…` warning. `disallowedTools` is read as `disallowed_tools`.
422
+ - Bare `mcp__<server>__<tool>` entries (exact, or `*` patterns like `mcp__radius__*`; a server-level `mcp__radius` means the whole server, as in Claude Code) narrow MCP tools as pi's `--tools` does: only matching MCP tools stay, from whichever extension serves them, and every other extension tool follows the rules above. The `codemode` and `tool_search` bridges that reach MCP tools stay in scope automatically, even under an `ext:` allowlist. With `extensions: false` or `isolated: true` nothing can serve them, and a `tools-error:…` warning says so.
419
423
  - pi's built-in extensions (`builtin:mcp`, `builtin:codemode`, `builtin:tool-search`) load in subagents as they do in the main session, so with `extensions: true` **every subagent starts its own set of `mcp.json` servers**, which stay up until the subagent's session is disposed (on quit, or ~10 minutes after it finishes). Address them by the full `builtin:` name — bare `[mcp]` matches a third-party extension named `mcp`, not the built-in — and narrow their tools with `ext:builtin:mcp/<tool>`. MCP tools are reached through codemode (or `tool_search` for `deferred` servers), so an `ext:` allowlist must name that bridge too, as pi's `--tools read,codemode,'mcp__*'` does: `tools: "read, ext:builtin:codemode, ext:builtin:mcp/mcp__radius__search"`. Opt out per agent with `exclude_extensions: builtin:mcp`, or everywhere with `-builtin:mcp` in pi's `extensions` setting; starting pi with `--no-mcp` keeps MCP out of subagents too, and `--no-extensions` keeps all three built-ins out. MCP tools stay undeclared until codemode or `tool_search` reaches them, as in the main session, and a codemode script can only call tools inside the agent's scope. Out-of-scope tools are blocked but can still appear in codemode's `searchTools()` and `tool_search` results.
420
424
  - Subagents inherit the parent session's **project trust**: in a project you did not trust, a subagent loads none of its `.pi` extensions or settings and never starts the servers in its `.pi/mcp.json`. A subagent spawned into another directory (RPC `cwd`) treats that directory as untrusted.
421
425
  - Extensions that register tools **lazily** work too. MCP-backed extensions typically can't enumerate their tools until their servers connect, so they register from `session_start` or `before_agent_start` rather than at load. Subagent scoping is re-derived as tools appear, so these surface normally — including under `ext:` selectors, which keep narrowing correctly no matter when a tool shows up.
422
426
  - Extensions bound into a subagent see **both ends** of that session's lifecycle: `session_start` when the agent starts, `session_shutdown` (reason `quit`) when its session is disposed — on quit, and when its record is evicted ~10 minutes after it finishes. Release per-session resources there; anything left armed outlives the session it belongs to. Handlers are given three seconds on quit, after which teardown proceeds regardless.
423
427
  - An installed **package** extension matches by its package short name (`@scope/pi-subagents` → `[pi-subagents]`), in addition to its path-derived name (a package whose entry is `src/index.ts` also answers to `[src]`). Prefer the package name — the path-derived one is incidental.
424
428
  - Plain `tools:` typos fail loudly: `tools: reed, grep` fires `tools-error:…` instead of silently producing an under-tooled agent.
429
+ - An agent whose `tools:` resolve to nothing is refused, as in Claude Code: an entry is unknown (or an `ext:` names an extension that did not load), no built-in survives `disallowed_tools`, and no extension could add a tool. That is mostly `extensions: false` or `isolated: true` with only unknown names (`tools: WebFetch`). With extensions loading the agent still starts, since their tools register after spawn.
425
430
  - `exclude_extensions:` wins over `extensions:` and over `ext:` selectors — an excluded extension never loads and a `tools: ext:` entry can't pull it back. Plain names only (no paths, no `*`); a name matching nothing fires an `extension-error:…` warning.
426
431
  - `exclude_extensions:` is **not a sandbox**: excluded extensions' factory code still executes once during loading. Exclusion suppresses their tools and their bound lifecycle hooks (`pi.on` handlers like `session_start` only fire for extensions bound to the session), but not other load-time side effects — a factory that subscribes directly to the shared `pi.events` bus stays live. Don't rely on it to contain an untrusted extension.
427
432
  - Array and string forms are equivalent: `[a, b]` == `"a, b"`.
428
433
 
429
434
  **How an agent's scope is advertised.** The Agent tool description lists every available agent with a `(Tools: …)` suffix, and that suffix is what the orchestrator reads when deciding where to route work. It describes **built-in scope only** — extension tools are resolved when the agent runs (extensions may register lazily, see above), so they can't be enumerated when the description is built:
430
435
 
431
- | `tools:` | suffix |
432
- | ------------------------------------------------------- | ------------------------------------ |
433
- | omitted, `*`, or `all` | `*` |
434
- | a list of built-ins | that list, e.g. `read, grep` |
435
- | `none` with `isolated: true` or `extensions: false` | `none` |
436
- | `none`, or only `ext:` entries, with extensions loading | `no built-ins, extension tools only` |
436
+ | `tools:` | suffix |
437
+ | ----------------------------------------------------------------- | ------------------------------------ |
438
+ | omitted, `*`, or `all` | `*` |
439
+ | a list of built-ins | that list, e.g. `read, grep` |
440
+ | `none` with `isolated: true` or `extensions: false` | `none` |
441
+ | `none`, or only `ext:` / `mcp__` entries, with extensions loading | `no built-ins, extension tools only` |
437
442
 
438
443
  The last two rows are separate because zero built-ins is not zero tools: `tools: none` alongside `extensions:` still surfaces every extension tool, so calling it `none` would understate what the agent can do. Note `*` doesn't enumerate extension tools either — an agent with `tools: "*, ext:mcp/search"` advertises `*`.
439
444
 
@@ -477,20 +482,20 @@ Four rules define the feature:
477
482
 
478
483
  Launch a sub-agent.
479
484
 
480
- | Parameter | Type | Required | Description |
481
- | ------------------- | ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
482
- | `prompt` | string | yes | The task for the agent |
483
- | `description` | string | yes | Short 3-5 word summary (shown in UI) |
484
- | `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 |
485
- | `subagent_type` | string | yes | Agent type (built-in or custom) |
486
- | `model` | string | no | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp interchangeable) with provider fallback |
487
- | `thinking` | string | no | Thinking level: off, minimal, low, medium, high, xhigh, max (availability depends on pi version and model) |
488
- | `max_turns` | number | no | Max agentic turns. Omit for unlimited (default) |
489
- | `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 |
490
- | `resume` | string | no | Agent ID to resume a previous session. The resumed run gets a fresh `max_turns` budget |
491
- | `isolated` | boolean | no | No extension/MCP tools |
492
- | `isolation` | `"off"` \| `"worktree"` | no | `worktree` runs in an isolated git worktree; `off` (the default) does not. Absent from the schema entirely when `worktreeIsolation: false` |
493
- | `inherit_context` | boolean | no | Fork parent conversation into agent |
485
+ | Parameter | Type | Required | Description |
486
+ | ------------------- | ----------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
487
+ | `prompt` | string | yes | The task for the agent |
488
+ | `description` | string | yes | Short 3-5 word summary (shown in UI) |
489
+ | `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 |
490
+ | `subagent_type` | string | yes | Agent type (built-in or custom) |
491
+ | `model` | string | no | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp interchangeable) with provider fallback |
492
+ | `thinking` | string | no | Thinking level: off, minimal, low, medium, high, xhigh, max (availability depends on pi version and model) |
493
+ | `max_turns` | number | no | Max agentic turns. Omit for unlimited (default) |
494
+ | `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 |
495
+ | `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) |
496
+ | `isolated` | boolean | no | No extension/MCP tools |
497
+ | `isolation` | `"off"` \| `"worktree"` | no | `worktree` runs in an isolated git worktree; `off` (the default) does not. Absent from the schema entirely when `worktreeIsolation: false` |
498
+ | `inherit_context` | boolean | no | Fork parent conversation into agent |
494
499
 
495
500
  ### `SubagentWorkflow`
496
501
 
@@ -552,6 +557,8 @@ Check status and retrieve results from a background agent.
552
557
 
553
558
  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.
554
559
 
560
+ 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, without the stats or the conversation (`verbose`).
561
+
555
562
  ### `steer_subagent`
556
563
 
557
564
  Send a steering message to a running agent. The message interrupts after the current tool execution.
@@ -718,7 +725,7 @@ Runtime tuning values set via `/agents` → Settings (max concurrency, max foreg
718
725
 
719
726
  **Background by default** (`backgroundByDefault`, default `true`): what an `Agent` call that doesn't say means. On — following Claude Code — the agent runs detached, the call returns its ID immediately, and a completion notification carries a preview of the result (`get_subagent_result` for the full text). Set `false` to restore the previous behaviour, where an unqualified spawn blocked the turn and returned its output inline. An explicit `run_in_background` on the call, or in an agent file's frontmatter, overrides this in both directions; the setting only decides what "unspecified" means. **Top-level only** — a nested spawn (an agent spawning its own) always defaults to foreground, because a detached child is stopped when its parent settles and has no notification path of its own. Toggle via `/agents → Settings → Background by default`; applied live.
720
727
 
721
- **Remember agents** (`rememberAgents`, default `true`): whether subagents persist their pi session, which is what lets [`@handle`](#agent-mentions) reopen an agent's conversation after its in-memory record has been evicted. Two visible consequences of the default: top-level subagents write a session file, and they nest under the session that spawned them in pi's `/resume`. Agents spawned by another agent are excluded — they get no handle, so nothing could reopen their transcript. A custom agent's `persist_session` frontmatter overrides this per agent, in both directions. Toggle via `/agents → Settings → Remember agents`; with it off, handles expire with their record (roughly ten minutes past completion) and `@explore` then starts a fresh agent rather than resuming — the behaviour before this setting existed.
728
+ **Remember agents** (`rememberAgents`, default `true`): whether subagents persist their pi session, which is what lets [`@handle`](#agent-mentions), `Agent({ resume })` and a workflow's `resume` reopen an agent's conversation after its in-memory record has been evicted. Two visible consequences of the default: top-level subagents write a session file, and they nest under the session that spawned them in pi's `/resume`. Agents spawned by another agent are excluded — they get no handle, so nothing could reopen their transcript. A custom agent's `persist_session` frontmatter overrides this per agent, in both directions. Toggle via `/agents → Settings → Remember agents`; with it off, handles expire with their record (roughly ten minutes past completion) and `@explore` then starts a fresh agent rather than resuming — the behaviour before this setting existed — and a later `resume` is refused because nothing was saved. When pi's `/fork` or `/clone` copies a session, resuming one of its agents from the copy forks that agent's session too, so the two parents never write into one file. That agent's `.output` transcript in the copy starts at the resume.
722
729
 
723
730
  **Output transcript** (`outputTranscript`, default `true`): the project/global default for writing each subagent's `.output` transcript. Toggle via `/agents → Settings → Output transcript`, or set `false` in `subagents.json` to make transcripts opt-in project-wide — useful when run transcripts shouldn't sit on disk for backup or DLP tooling to pick up. A custom agent's `output_transcript` frontmatter overrides this per agent. Applied live at spawn time. Governs only the transcript, not `persist_session`, worktree commits, or memory files.
724
731
 
@@ -978,6 +985,8 @@ The agent gets a full, isolated copy of the repository. The worktree is normally
978
985
  - **Agent committed its own work:** the branch is created at the agent's HEAD, preserving its commits (uncommitted leftovers are committed on top first)
979
986
  - **Preservation failed:** the run reports an error and keeps the worktree. Its path is included in the result so the changes can be recovered manually
980
987
 
988
+ A resumed agent never gets a worktree, as in Claude Code: a fresh copy of HEAD would not hold its earlier edits. This covers `Agent({ resume })` and `@handle` once the record is evicted, and a workflow's `resume`. If its worktree held changes, the resume is refused with "its worktree no longer exists"; the work is on its branch. If the worktree held none, the agent continues in the main checkout without isolation.
989
+
981
990
  The agent's system prompt names the worktree as an isolated copy and tells it to work only there, even if other instructions name the main checkout — otherwise an inherited parent prompt or a task prompt mentioning the project path walks it straight back out of the copy. This is a directive, not a sandbox: an agent with shell access can still `cd` out, so don't rely on `isolation` alone to protect the main checkout.
982
991
 
983
992
  The automatic preservation commit uses `--no-verify` and `--no-gpg-sign`, so local pre-commit hooks and interactive signing configuration can't block it. The commit is local-only and never pushed; pre-push and server-side hooks still apply. Other Git failures keep the worktree intact and report its recovery path instead of deleting the only copy.
@@ -1070,6 +1079,7 @@ src/
1070
1079
  completion-outbox.ts # Deliver completion notifications at the parent's next boundary, coalesced
1071
1080
  group-join.ts # `group` join mode: one notification per turn's batch, with timeout
1072
1081
  status-note.ts # Honest status note + salvaged partial output for non-normal outcomes
1082
+ agent-record-entry.ts # The `subagents:record` session entry a finished agent leaves; get_subagent_result's fallback, and what resume reopens an evicted agent from
1073
1083
  usage.ts # Token usage shapes, accumulators, session-stats readers
1074
1084
 
1075
1085
  # Invocation surface
@@ -130,7 +130,7 @@ Fire-and-forget is the intended use: the reply carries nothing to act on, and th
130
130
 
131
131
  Consumption is not terminal. An `@handle` steer un-consumes the record (the mention handler, `src/index.ts`) because the agent's reply to that message still needs relaying. A background resume (`AgentManager.resume`) does too, because the record is starting a new run, and so does handing a foreground agent to the background (`AgentManager.sendToBackground`), because its result now has to reach the parent as a notification.
132
132
 
133
- One related thing that lives nowhere else: on every top-level settle, pi-subagents writes a session entry — not an event — via `pi.appendEntry("subagents:record", …)` (the manager's completion callback, `src/index.ts`), carrying `id`, `type`, `description`, `status`, `result`, `error`, `startedAt` and `completedAt`. It exists for cross-extension history reconstruction. It is append-only history, not something to react to.
133
+ One related thing that lives nowhere else: on every top-level settle, pi-subagents writes a session entry — not an event — via `pi.appendEntry("subagents:record", …)` (the manager's completion callback, `src/index.ts`, and the Agent tool's foreground `resume` branch, which settles inline without that callback; the shape is `AgentRecordEntryData` in `src/agent-record-entry.ts`), carrying `id`, `type`, `description`, `status`, `result`, `error`, `startedAt` and `completedAt`, plus `sessionFile`, `handle` and `alias` when the agent has them, and `worktreeLost: true` when its work lived in a worktree that has since been removed. `get_subagent_result` answers from it once the live record is gone, `Agent({ resume })` reopens the agent's session from it, and it serves cross-extension history reconstruction. It is append-only history, not something to react to.
134
134
 
135
135
  ## Steering a running agent
136
136
 
@@ -279,6 +279,8 @@ Any other key is rejected **by name** at the call. Note that this checks option
279
279
 
280
280
  Combination rules: `resume` cannot be combined with `agentType`, `model`, `effort`, `isolation`, `gate` or `schema` — a resumed child keeps the agent type, model and tree it was started with, and its session predates the `StructuredOutput` tool.
281
281
 
282
+ 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.
283
+
282
284
  ### `pipeline()` and `parallel()`
283
285
 
284
286
  ```js
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.22.1-local.1",
3
+ "version": "0.23.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.22.1",
73
- "reviewedVersion": "0.22.1",
72
+ "version": "0.23.0",
73
+ "reviewedVersion": "0.23.0",
74
74
  "repository": "https://github.com/tintinweb/pi-subagents",
75
- "commit": "fc089c4b7ab0f1185453b2e53027997c1f637e38",
75
+ "commit": "a60247c47f8b0a17bfe7208f9e248e464eda05f0",
76
76
  "trackVersion": true
77
77
  }
78
78
  }
@@ -263,13 +263,13 @@ ${input.systemPrompt}
263
263
  }
264
264
 
265
265
  /**
266
- * Rebuild the `tools:` CSV from the two halves the loader split it into.
266
+ * Rebuild the `tools:` CSV from the parts the loader split it into.
267
267
  *
268
- * `extSelectors` has to come back with the built-ins: `parseToolsField` splits
269
- * `tools: read, ext:mcp/github` into `["read"]` and `["ext:mcp/github"]`, so
270
- * writing only the first half hands the ejected copy a *narrower* toolset than
271
- * the file it came from. That was invisible while Eject only ever ran on
272
- * built-in defaults, which carry no selectors; a package agent can.
268
+ * `extSelectors` and `mcpToolPatterns` have to come back with the built-ins:
269
+ * `parseToolsField` splits `tools: read, ext:mcp/github` into `["read"]` and
270
+ * `["ext:mcp/github"]`, so writing only the first half hands the ejected copy a
271
+ * *narrower* toolset than the file it came from. That was invisible while Eject
272
+ * only ever ran on built-in defaults, which carry no selectors; a package agent can.
273
273
  *
274
274
  * Zero built-ins with selectors present is not `none` — `none` means no tools at
275
275
  * all, while `ext:` entries alone mean "extension tools only", which the loader
@@ -278,8 +278,9 @@ ${input.systemPrompt}
278
278
  function formatToolsField(
279
279
  tools: string[] | undefined,
280
280
  extSelectors?: string[],
281
+ mcpToolPatterns?: string[],
281
282
  ): string {
282
- const selectors = extSelectors ?? []
283
+ const selectors = [...(extSelectors ?? []), ...(mcpToolPatterns ?? [])]
283
284
  if (tools === undefined)
284
285
  return selectors.length > 0 ? ["*", ...selectors].join(", ") : "all"
285
286
  if (tools.length === 0)
@@ -297,7 +298,7 @@ export function serializeAgentFile(cfg: AgentConfig): string {
297
298
  // `all` for both would hand a deliberately tool-less agent the whole toolbox
298
299
  // the first time it is ejected.
299
300
  fmFields.push(
300
- `tools: ${formatToolsField(cfg.builtinToolNames, cfg.extSelectors)}`,
301
+ `tools: ${formatToolsField(cfg.builtinToolNames, cfg.extSelectors, cfg.mcpToolPatterns)}`,
301
302
  )
302
303
  if (cfg.model) fmFields.push(`model: ${cfg.model}`)
303
304
  if (cfg.thinking) fmFields.push(`thinking: ${cfg.thinking}`)