pi-subagent-manager 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,6 +83,8 @@ A live **Agents** widget sits above the input box. Choose **Full** (the existing
83
83
 
84
84
  Experimental features are marked **[labs]** in settings. Enable **[labs] Nerd Font icons** in `/agents` to show role-specific icons beside agent names (off by default; requires a Nerd Font in your terminal). Loaders appear **before**, never instead of, the role icon. Choose Circle, Braille, or Hourglass under **[labs] Loader style**, with previews of every animation frame and each family's completed, paused, failed, and stopped icons. Custom agent types can set an optional `icon` or use **[labs] Icon** in `/agents types`. See [icon setup](docs/settings.md#labs-nerd-font-icons-nerdfonticons).
85
85
 
86
+ Enable **[labs] Enable subagent extensions** in `/agents settings` to reload configured user and trusted-project extension hooks in each subagent’s separate session. It is off by default and experimental: hooks that assume main-session state can cause bugs or unintended consequences. This is configured-file discovery, **not exact main-session inheritance**; CLI-only, inline, and built-in extensions are not reloaded. See [subagent extension settings](docs/settings.md#labs-enable-subagent-extensions-subagentextensions) and read the [limitations](docs/subagent-extension-limitations.md) before enabling.
87
+
86
88
  Enable **[labs] Final Recap** in `/agents` to automatically ask the idle main agent to summarize detached-agent results, keeping the final response in the main thread. It is off by default and suppressed by Subagent Mode Off. **Enabling it may cause extra model turns and uses more tokens and context.** See [Final Recap](docs/settings.md#labs-final-recap-finalrecap).
87
89
 
88
90
  ## Docs
@@ -1,6 +1,7 @@
1
1
  # Write your own agent
2
2
 
3
- An agent type is one Markdown file: YAML frontmatter on top, system prompt below.
3
+ A full agent type is a Markdown file: YAML frontmatter on top, system prompt below.
4
+ A settings-only customization is a sparse YAML overlay.
4
5
 
5
6
  ## 1. Pick a location
6
7
 
@@ -9,7 +10,8 @@ An agent type is one Markdown file: YAML frontmatter on top, system prompt below
9
10
  | User | `<pi-agent-dir>/subagent-manager/agents/` (normally `~/.pi/agent/subagent-manager/agents/`) |
10
11
  | Project | `<cwd>/.pi/agent/subagent-manager/agents/` — loaded only when pi trusts the project |
11
12
 
12
- Precedence: **project > user > bundled**. A file with the same `name` as a bundled agent replaces it.
13
+ Precedence: **project > user > bundled**. Markdown definitions replace lower-layer
14
+ definitions; YAML overlays inherit any fields they do not specify.
13
15
 
14
16
  ## Tweak settings or fork the agent?
15
17
 
@@ -26,7 +28,6 @@ project) cannot hold both a `.md` and a `.yml` for the same name.
26
28
  `~/.pi/agent/subagent-manager/agents/coder.yml`:
27
29
 
28
30
  ```yaml
29
- name: coder
30
31
  thinkingLevel: low
31
32
  tools:
32
33
  allow:
@@ -36,18 +37,34 @@ tools:
36
37
  - agent_pause
37
38
  ```
38
39
 
39
- Only listed fields override; everything else follows the base definition, so
40
- untouched settings keep tracking bundled updates. Set an optional field to
41
- `null` to clear it back to the base state (e.g. `icon: null`). `name`, when
42
- present, must match the filename. Overrides need a base agent to merge onto —
43
- a `.yml` without a matching bundled or forked definition is rejected.
40
+ Only listed fields override; everything else follows the lower-layer definition,
41
+ so untouched models, settings, descriptions, and prompts keep tracking extension
42
+ updates. `tools.allow` and `tools.block` merge independently: changing one does
43
+ not pin the other. Lists replace the corresponding list, rather than appending.
44
+ An empty tool list (`[]`) is an explicit empty list.
45
+
46
+ Omit a field to inherit it. Set an optional field to `null` to **remove** it from
47
+ the effective definition, not to restore the bundled value: `models: null` uses
48
+ the parent/default model; `icon: null` hides the icon; `tools.allow: null` removes
49
+ the allow list while keeping the inherited block list; `tools: null` removes the
50
+ whole policy. To restore inheritance, delete that setting from the YAML file.
51
+ `name` is optional and, when present, must match the filename. `.yml` and `.yaml`
52
+ are both supported. An override needs a matching lower-layer agent — an orphan
53
+ YAML file is rejected. Prompt fields/bodies are not allowed in YAML overlays.
44
54
 
45
55
  In `/agents types`, editing a bundled agent asks you to pick one mode first,
46
- and settings stay locked until you choose. Overrides cannot rename the agent
47
- or edit the system prompt — fork it instead.
56
+ and settings stay locked until you choose. **Tweak settings** starts with an
57
+ empty overlay (`{}` when saved unchanged), not a copy of the definition. Saving
58
+ writes only changed settings and retains existing explicit overrides, even if
59
+ an override currently matches a default. Saving to another scope writes the
60
+ edits into that scope without copying unchanged values from the displayed
61
+ scope. Project overlays inherit user customizations; user overlays inherit
62
+ bundled definitions. Overrides cannot rename the agent or edit the system
63
+ prompt — fork it instead. Full Markdown forks remain full copies.
48
64
 
49
65
  To undo a fork or override, choose **Reset to bundled** (after Save) in the editor.
50
- It deletes the `.md`/`.yml` file after confirmation and the shipped agent applies again.
66
+ It deletes the customization file after confirmation and the lower-layer agent
67
+ applies again (the user customization, if any, or the shipped definition).
51
68
 
52
69
  These are the only locations read. Other packages' `~/.pi/agent/agents` or `.pi/agents` are ignored — use [`/agents import`](importing-agents.md) for those.
53
70
 
@@ -128,7 +145,8 @@ In `/agents types`, select **[labs] Icon** and paste the glyph, then save the ag
128
145
 
129
146
  The model picker lists selected models first, in fallback order. **Enter** toggles a model, **Ctrl+↑/↓** reorders, typing filters. Unselected models are ranked by fuzzy match against `modelSuggestions`, scoped models first.
130
147
 
131
- **External editor** opens the whole file in `$VISUAL`, `$EDITOR`, or `vi`.
148
+ **External editor** opens the whole Markdown definition in `$VISUAL`, `$EDITOR`,
149
+ or `vi` in fork mode. For an overlay, edit its YAML file directly and reload.
132
150
 
133
151
  ## Errors
134
152
 
package/docs/settings.md CHANGED
@@ -21,6 +21,7 @@ All keys are optional. Defaults:
21
21
  "costValue": "subagents",
22
22
  "costIcon": "money",
23
23
  "finalRecap": false,
24
+ "subagentExtensions": false,
24
25
  "modelSelection": "pick-first-scoped",
25
26
  "toolFiltering": "allowed",
26
27
  "maxLevels": 3,
@@ -89,6 +90,16 @@ Both status modes use the same public Pi status API: third-party footers may als
89
90
 
90
91
  See [Subagent dollar totals in pi-footer](pi-footer.md) for step-by-step setup and copy-paste widget configuration, status-key, and event snippets.
91
92
 
93
+ ## [labs] Enable subagent extensions (`subagentExtensions`)
94
+
95
+ Experimental on/off toggle, **off by default**. Enable **[labs] Enable subagent extensions** in `/agents settings` and save, or set `"subagentExtensions": true`.
96
+
97
+ When a subagent session opens, it reloads enabled extension files from user configuration and, only when the main project is trusted, project configuration. Pi package resource filters and disabled-extension settings are respected; missing packages are skipped, never installed. This manager is excluded to avoid starting a second subagent manager inside each child. Each factory receives a child-local runtime and its hooks run against that child's session. Reloaded extension tools take precedence over inherited main-session bridges, including tools registered on `session_start`; tool filtering still applies. Other inherited tools keep their existing bridges.
98
+
99
+ **This is configured-file discovery, not exact main-session inheritance. Bugs and unintended consequences are possible.** Read [subagent extension limitations](subagent-extension-limitations.md) before enabling it: the guide covers excluded extensions, configuration drift, `input` hook bypasses, shared side effects, non-interactive UI, and main-session tool bridges.
100
+
101
+ Save and apply affects newly opened sessions, including retained sessions reopened after reload. Already-open agents keep their extension runtime until disposed. The main agent's extensions and tool set are not changed. Leave this off unless your extensions are safe to run across separate sessions.
102
+
92
103
  ## [labs] Final Recap (`finalRecap`)
93
104
 
94
105
  **[labs] Final Recap** is an experimental on/off toggle, **off by default**. Enable it in `/agents` and save with **Ctrl+S**, or set `"finalRecap": true` in your settings file.
@@ -129,7 +140,7 @@ How the type's `tools.allow` / `tools.block` lists are applied.
129
140
 
130
141
  - "All" includes child-local built-in and manager tools plus the main session's registered non-hidden tools. Exact-name allow/block lists apply to this inventory.
131
142
  - Inherited tools retain exposure and active status. Deferred/codemode tools are discoverable through child-local codemode when permitted; direct tools remain model-facing when active.
132
- - Built-in tools, manager controls, codemode and tool search remain child-local. External calls reuse main-session resources/context rather than loading fresh extensions or MCP connections. Bridged callable tools remain subject to the main session's tool policy; session-mutating external tools are not necessarily isolated to the child. Skills and project context files are not automatically loaded.
143
+ - By default, built-in tools, manager controls, codemode and tool search remain child-local. External calls reuse main-session resources/context rather than loading fresh extensions or MCP connections. With [Enable subagent extensions](#labs-enable-subagent-extensions-subagentextensions), reloaded extension tools execute in the child instead. Bridged callable tools remain subject to the main session's tool policy; session-mutating external tools are not necessarily isolated to the child. Skills and project context files are not automatically loaded.
133
144
  - Other custom **model-only** tools fail closed: the SDK cannot bridge them while preserving root permission/result hooks. Run those in the main session.
134
145
  - UI/command-driven resumes after reopening the main session need a main-session `agent_*` tool call to establish the execution bridge; use `agent_steer` rather than the thread dialog.
135
146
  - Applies to newly started sessions (including retained ones reopened after reload). Already-open sessions keep their selected tools, and the main session's tool set is unchanged.
@@ -0,0 +1,30 @@
1
+ # Subagent extension limitations
2
+
3
+ **[labs] Enable subagent extensions** (`subagentExtensions`) is experimental and **off by default**. It reloads configured extension files into separate subagent sessions. Bugs and unintended consequences are possible; enable it only when your extensions are safe to run in multiple sessions.
4
+
5
+ See [the setting and how to enable it](settings.md#labs-enable-subagent-extensions-subagentextensions).
6
+
7
+ ## Not an exact copy of the main agent's extensions
8
+
9
+ - The public Pi extension API does not expose the main session's loaded-extension inventory. Subagents discover enabled extension files from user configuration and, only when the main project is trusted, project configuration.
10
+ - **CLI-only, inline, and built-in extensions are not reloaded.** Configured file extensions are supported; this manager is excluded to avoid starting another subagent manager inside each child.
11
+ - Configuration changed since the main session loaded can produce a different extension set in a newly opened subagent session. Disabled-extension settings and package resource filters are respected. Missing packages are skipped, never installed.
12
+ - Saving the toggle affects newly opened sessions, including retained sessions reopened after reload. Already-open agents keep their extension runtime until disposed; the main agent's runtime is unchanged.
13
+
14
+ ## Some messages bypass `input` hooks
15
+
16
+ Initial prompts run `input` hooks. **Durable steering and replayed queued mailbox messages bypass `input` hooks** to preserve mailbox delivery semantics. Request-time context hooks still run, but an extension cannot rely on its `input` handler seeing or transforming every subagent message.
17
+
18
+ ## Separate sessions do not isolate every side effect
19
+
20
+ Each reloaded factory receives a child-local runtime, and its hooks operate on that child's session rather than the main session. Hooks that assume main-session state may behave incorrectly. Sessions can run concurrently, so writes to shared files, external services, or other shared state can conflict or produce repeated side effects.
21
+
22
+ Subagents use **non-interactive print mode**, not the main agent's interactive terminal UI. Extensions that require dialogs, confirmations, or other interactive UI may not work as expected. Session shutdown hooks are awaited before child contexts are invalidated, but extensions must still handle their own session-scoped resources safely.
23
+
24
+ ## Some tools still execute through the main session
25
+
26
+ Reloaded extension tools take precedence over inherited main-session bridges, including tools registered on `session_start`; agent tool filtering still applies. Tools that are not reloaded, including built-in MCP tools, retain the existing main-session bridge.
27
+
28
+ **Bridged calls run through both child hooks and the main session's hooks.** They reuse main-session resources and context, so session-mutating tools are not necessarily isolated to the child, and hook side effects can occur in both sessions. Built-in codemode and tool search remain child-local rather than reusing the main agent's implementations.
29
+
30
+ Leave the setting off if your extensions require exact main-session inheritance, interactive UI, or an `input` hook for every delivered message.
@@ -72,7 +72,7 @@ Refreshes every second and keeps your selection, collapse state and scroll posit
72
72
 
73
73
  ### Live agent navigation
74
74
 
75
- The fullscreen watcher renders steer and agent messages (including thinking) as Markdown, same as pi's main transcript. Tool calls and their results share pi's native `ToolExecutionComponent`, with built-in renderers for shell commands, reads, highlighted writes, edit diffs and search tools. Pending, successful and failed executions use pi's active theme colors. Unknown tools use pi's safe generic renderer; nested executions appear beneath their parent. **Ctrl+O** toggles full tool output from either input or transcript focus. **t** cycles detail levels with transcript controls focused: **preview** (default: pi's native tool previews, first three rendered thinking lines), **compact** (one line per call, thinking hidden), **full** (complete tool output and thinking). Successful reads are collapsed by default, just like pi; expand them with **Ctrl+O**. Inherited context is initially collapsed (**c** toggles it with transcript controls focused). Watching alone never starts a turn, switches sessions, or changes model/tool/resource ownership. Extension renderers are never invoked, raw terminal controls are stripped, and images use safe text placeholders. Legacy sessions without reliable inherited-prefix metadata show their whole transcript.
75
+ The fullscreen watcher renders steer and agent messages (including thinking) as Markdown, same as pi's main transcript. Tool calls and their results share pi's native `ToolExecutionComponent`, with built-in renderers for shell commands, reads, highlighted writes, edit diffs and search tools. Pending, successful and failed executions use pi's active theme colors. Unknown tools use pi's safe generic renderer; nested executions appear beneath their parent. **Ctrl+O** cycles all three detail levels in both steer and browse mode: **preview** (default: pi's native tool previews, first three rendered thinking lines), **compact** (one line per call, thinking hidden), **full** (complete tool output and thinking). Successful reads are collapsed by default, just like pi; expand them with **Ctrl+O**. Inherited context is initially collapsed (**c** toggles it with transcript controls focused). Watching alone never starts a turn, switches sessions, or changes model/tool/resource ownership. Extension renderers are never invoked, raw terminal controls are stripped, and images use safe text placeholders. Legacy sessions without reliable inherited-prefix metadata show their whole transcript.
76
76
 
77
77
  - The bottom **Steer** input is focused initially. Type and press **Enter** to send to the inspected agent, including nested descendants, through the same service as `agent_steer`: running agents receive queued input; paused/completed/stopped agents resume their retained session. Empty input is ignored. Sending leaves the viewer open; failures are shown and preserve the draft for retry.
78
78
  - **Tab** switches between steering input and transcript controls. While typing, **c/t/l/r** are ordinary text and **Home/End** move the input cursor. Pasting never submits by itself.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagent-manager",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Hierarchical, steerable subagent threads for pi",
5
5
  "type": "module",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -452,6 +452,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
452
452
  () => limits.modelSelection,
453
453
  () => limits.toolFiltering,
454
454
  () => inheritedTools.snapshot(),
455
+ () => limits.subagentExtensions,
455
456
  );
456
457
  let driverFactory = makeDriverFactory();
457
458
  const toolsFor = (path: string) =>
@@ -0,0 +1,56 @@
1
+ import { realpath, readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { DefaultPackageManager, SettingsManager } from "@earendil-works/pi-coding-agent";
5
+
6
+ const MANAGER_ENTRY = fileURLToPath(new URL("../index.ts", import.meta.url));
7
+
8
+ async function canonical(file: string): Promise<string> {
9
+ return realpath(file).catch(() => path.resolve(file));
10
+ }
11
+
12
+ /** Exclude this manager before executing factories, including installed copies and symlinks. */
13
+ async function isManagerExtension(file: string, packageRoot?: string): Promise<boolean> {
14
+ const resolved = await canonical(file);
15
+ if (resolved === (await canonical(MANAGER_ENTRY))) return true;
16
+ // Explicit paths and auto-discovered symlinks may not have package metadata.
17
+ let directory = packageRoot ?? path.dirname(resolved);
18
+ while (true) {
19
+ try {
20
+ const manifest = JSON.parse(await readFile(path.join(directory, "package.json"), "utf8"));
21
+ return manifest.name === "pi-subagent-manager";
22
+ } catch {
23
+ const parent = path.dirname(directory);
24
+ if (parent === directory) return false;
25
+ directory = parent;
26
+ }
27
+ }
28
+ }
29
+
30
+ /**
31
+ * The public ExtensionAPI cannot inspect the main session's resource loader. This is
32
+ * deliberately configured-file discovery, not exact main-set inheritance: CLI-only,
33
+ * inline and built-in extensions are not reloaded. Missing packages are never installed.
34
+ */
35
+ export async function discoverSubagentExtensions(options: {
36
+ cwd: string;
37
+ agentDir: string;
38
+ projectTrusted: boolean;
39
+ }): Promise<string[]> {
40
+ const settingsManager = SettingsManager.create(options.cwd, options.agentDir, {
41
+ projectTrusted: options.projectTrusted,
42
+ });
43
+ const packages = new DefaultPackageManager({ ...options, settingsManager });
44
+ const resources = await packages.resolve(async () => "skip");
45
+ const paths: string[] = [];
46
+ const seen = new Set<string>();
47
+ for (const resource of resources.extensions) {
48
+ if (!resource.enabled || resource.path.startsWith("builtin:")) continue;
49
+ if (await isManagerExtension(resource.path, resource.metadata.packageRoot)) continue;
50
+ const resolved = await canonical(resource.path);
51
+ if (seen.has(resolved)) continue;
52
+ seen.add(resolved);
53
+ paths.push(resource.path);
54
+ }
55
+ return paths;
56
+ }
@@ -617,7 +617,7 @@ export class ThreadManager {
617
617
  await record.driver?.abort();
618
618
  await record.initializing?.catch(() => {});
619
619
  await record.run;
620
- record.driver?.dispose();
620
+ await record.driver?.dispose();
621
621
  }),
622
622
  );
623
623
  }
@@ -745,7 +745,7 @@ export class ThreadManager {
745
745
  .then(async (driver) => {
746
746
  if (this.disposed || signal.aborted) {
747
747
  await driver.abort();
748
- driver.dispose();
748
+ await driver.dispose();
749
749
  throw new Error("Driver startup cancelled");
750
750
  }
751
751
  record.driver = driver;
@@ -5,6 +5,10 @@ import { existsSync } from "node:fs";
5
5
  import { mkdir, readFile, realpath } from "node:fs/promises";
6
6
  import {
7
7
  createAgentSession,
8
+ createExtensionRuntime,
9
+ ExtensionRunner,
10
+ ModelRegistry,
11
+ createSyntheticSourceInfo,
8
12
  createCodemodeExtension,
9
13
  createToolSearchExtension,
10
14
  DefaultResourceLoader,
@@ -23,6 +27,7 @@ import {
23
27
  } from "./mailbox.ts";
24
28
  import { selectTools } from "../prefs/config.ts";
25
29
  import { TranscriptChannel } from "./transcript.ts";
30
+ import { discoverSubagentExtensions } from "./extensions.ts";
26
31
  import type { InheritedToolSource } from "./inherited-tools.ts";
27
32
  import type { ModelSelectionMode, ToolFilteringMode } from "../prefs/settings.ts";
28
33
  import {
@@ -143,12 +148,13 @@ async function assertAcceptedSessionFile(
143
148
  }
144
149
  }
145
150
 
146
- /** Isolated SDK sessions with filtered root tool bridges, not reloaded root extensions. */
151
+ /** Isolated SDK sessions; configured extension reload is experimental and opt-in. */
147
152
  export function createDriverFactory(
148
153
  getRootContext: () => ExtensionContext,
149
154
  getModelSelection: () => ModelSelectionMode = () => "pick-first-scoped",
150
155
  getToolFiltering: () => ToolFilteringMode = () => "allowed",
151
156
  getInheritedTools: () => InheritedToolSource = () => ({ tools: [], activeNames: [] }),
157
+ getSubagentExtensions: () => boolean = () => false,
152
158
  ): DriverFactory & {
153
159
  resolveAgentSettings(type: AgentType, parentPath: string): ResolvedAgentSettings;
154
160
  } {
@@ -246,6 +252,7 @@ export function createDriverFactory(
246
252
  const ctx = getRootContext();
247
253
  // Tool policy is a startup snapshot; retained live sessions keep their selected set.
248
254
  const toolFiltering = getToolFiltering();
255
+ const subagentExtensions = getSubagentExtensions();
249
256
  const rootId = ctx.sessionManager.getSessionId();
250
257
  if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(rootId))
251
258
  throw new Error("Unsafe root session id for subagent storage");
@@ -393,10 +400,14 @@ export function createDriverFactory(
393
400
  rootActive.has(name) ||
394
401
  (options.type.tools?.allow?.includes(name) && toolFiltering === "allowed"),
395
402
  );
396
- const customTools = [...options.tools, ...externalTools].filter(
397
- (tool) => allowed.has(tool.name) && tool.name !== "codemode" && tool.name !== "tool_search",
398
- );
399
- const settingsManager = SettingsManager.inMemory({ cacheWarming: "off" });
403
+ const projectTrusted = ctx.isProjectTrusted?.() ?? false;
404
+ const extensionPaths = subagentExtensions
405
+ ? await discoverSubagentExtensions({ cwd: ctx.cwd, agentDir, projectTrusted })
406
+ : [];
407
+ // Keep discovery settings OUT of this loader: reload() resolves packages with
408
+ // auto-install enabled. An empty in-memory package/resource list ensures it
409
+ // only loads the already-resolved files and cannot install missing packages.
410
+ const settingsManager = SettingsManager.inMemory({ cacheWarming: "off" }, { projectTrusted });
400
411
  let parkQueue = () => {};
401
412
  const pauseBoundary = () => {
402
413
  if (!options.shouldPause()) return undefined;
@@ -408,6 +419,38 @@ export function createDriverFactory(
408
419
  agentDir,
409
420
  settingsManager,
410
421
  noExtensions: true,
422
+ additionalExtensionPaths: extensionPaths,
423
+ // Put bridges AFTER file extensions in the runner registry. First registration
424
+ // wins there, including tools registered by file extensions on session_start
425
+ // or later. SDK customTools would always override those child-local tools.
426
+ extensionsOverride: subagentExtensions
427
+ ? (base) => {
428
+ const sourceInfo = createSyntheticSourceInfo("<subagent-inherited-tools>", {
429
+ source: "sdk",
430
+ });
431
+ base.extensions.push({
432
+ path: "<subagent-inherited-tools>",
433
+ resolvedPath: "<subagent-inherited-tools>",
434
+ sourceInfo,
435
+ handlers: new Map(),
436
+ tools: new Map(
437
+ externalTools
438
+ .filter(
439
+ (tool) =>
440
+ allowed.has(tool.name) &&
441
+ tool.name !== "codemode" &&
442
+ tool.name !== "tool_search",
443
+ )
444
+ .map((definition) => [definition.name, { definition, sourceInfo }]),
445
+ ),
446
+ messageRenderers: new Map(),
447
+ commands: new Map(),
448
+ flags: new Map(),
449
+ shortcuts: new Map(),
450
+ });
451
+ return base;
452
+ }
453
+ : undefined,
411
454
  noSkills: true,
412
455
  noPromptTemplates: true,
413
456
  noContextFiles: true,
@@ -430,8 +473,24 @@ export function createDriverFactory(
430
473
  extensionFactories: [
431
474
  // These orchestrators must see the CHILD loadout. Forwarding root codemode would
432
475
  // let scripts discover/call tools outside the child's allow/block policy.
433
- ...(allowed.has("codemode") ? [createCodemodeExtension()] : []),
434
- ...(allowed.has("tool_search") ? [createToolSearchExtension()] : []),
476
+ ...(allowed.has("codemode")
477
+ ? [
478
+ subagentExtensions
479
+ ? { name: "child-codemode", factory: createCodemodeExtension(), replaceable: true }
480
+ : createCodemodeExtension(),
481
+ ]
482
+ : []),
483
+ ...(allowed.has("tool_search")
484
+ ? [
485
+ subagentExtensions
486
+ ? {
487
+ name: "child-tool-search",
488
+ factory: createToolSearchExtension(),
489
+ replaceable: true,
490
+ }
491
+ : createToolSearchExtension(),
492
+ ]
493
+ : []),
435
494
  (pi) => {
436
495
  pi.on("turn_end", pauseBoundary);
437
496
  pi.on("agent_before_settle", pauseBoundary);
@@ -445,22 +504,104 @@ export function createDriverFactory(
445
504
  });
446
505
  options.signal.throwIfAborted();
447
506
  await loader.reload();
448
- options.signal.throwIfAborted();
449
- const { session } = await createAgentSession({
450
- cwd: ctx.cwd,
451
- agentDir,
452
- modelRuntime: runtime,
453
- model,
454
- thinkingLevel,
455
- scopedModels: [...initialScopedModels],
456
- settingsManager,
457
- resourceLoader: loader,
458
- sessionManager,
459
- // SDK `tools` is both a registry allowlist and an initial active list.
460
- // Register every permitted deferred tool, then narrow declarations after bind.
461
- tools: toolNames,
462
- customTools,
463
- });
507
+ const loadedExtensions = loader.getExtensions();
508
+ // Manager controls remain SDK custom tools so loaded extensions cannot replace
509
+ // them. With reload disabled, preserve the existing SDK bridge behavior exactly.
510
+ const customTools = [...options.tools, ...(subagentExtensions ? [] : externalTools)].filter(
511
+ (tool) => allowed.has(tool.name) && tool.name !== "codemode" && tool.name !== "tool_search",
512
+ );
513
+ let session: Awaited<ReturnType<typeof createAgentSession>>["session"];
514
+ try {
515
+ ({ session } = await createAgentSession({
516
+ cwd: ctx.cwd,
517
+ agentDir,
518
+ modelRuntime: runtime,
519
+ model,
520
+ thinkingLevel,
521
+ scopedModels: [...initialScopedModels],
522
+ settingsManager,
523
+ resourceLoader: loader,
524
+ sessionManager,
525
+ // SDK `tools` is both a registry allowlist and an initial active list.
526
+ // Register every permitted deferred tool, then narrow declarations after bind.
527
+ tools: toolNames,
528
+ customTools,
529
+ }));
530
+ } catch (error) {
531
+ if (subagentExtensions) {
532
+ // No session was returned, so normal disposal is unavailable. Give loaded
533
+ // factories a shutdown-only runner with child-local metadata/persistence;
534
+ // unavailable session actions remain throwing stubs, not root bridges.
535
+ await (async () => {
536
+ const runner = new ExtensionRunner(
537
+ loadedExtensions.extensions,
538
+ loadedExtensions.runtime,
539
+ ctx.cwd,
540
+ sessionManager,
541
+ new ModelRegistry(runtime),
542
+ );
543
+ try {
544
+ runner.bindCore(
545
+ {
546
+ ...createExtensionRuntime(),
547
+ appendEntry: (customType, data) =>
548
+ sessionManager.appendCustomEntry(customType, data),
549
+ getSessionName: () => sessionManager.getSessionName(),
550
+ getSettings: () => settingsManager.getSettings(),
551
+ getThinkingLevel: () => clampThinkingLevel(model, thinkingLevel),
552
+ },
553
+ {
554
+ getModel: () => model,
555
+ getScopedModels: () => initialScopedModels,
556
+ isIdle: () => true,
557
+ isProjectTrusted: () => projectTrusted,
558
+ getSignal: () => undefined,
559
+ abort: () => {},
560
+ hasPendingMessages: () => false,
561
+ shutdown: () => {},
562
+ getContextUsage: () => undefined,
563
+ compact: () => {},
564
+ getSystemPrompt: () => loader.getSystemPrompt() ?? "",
565
+ },
566
+ );
567
+ await runner.emit({ type: "session_shutdown", reason: "quit" });
568
+ } finally {
569
+ runner.invalidate();
570
+ }
571
+ })().catch(() => {
572
+ // Best-effort cleanup must not hide the SDK's original startup failure.
573
+ });
574
+ }
575
+ throw error;
576
+ }
577
+ const unsubscribeExtensionErrors = subagentExtensions
578
+ ? session.extensionRunner.onError((error) =>
579
+ options.onEvent({
580
+ kind: "error",
581
+ text: `Extension ${error.extensionPath} (${error.event}): ${error.error}`.slice(
582
+ 0,
583
+ 1000,
584
+ ),
585
+ }),
586
+ )
587
+ : () => {};
588
+ let shutdownPromise: Promise<void> | undefined;
589
+ const disposeSession = () => {
590
+ if (!subagentExtensions) {
591
+ session.dispose();
592
+ return;
593
+ }
594
+ // SDK dispose invalidates contexts but does not emit session_shutdown. Await
595
+ // handlers before invalidation so session-scoped resources can be released.
596
+ return (shutdownPromise ??= (async () => {
597
+ try {
598
+ await session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
599
+ } finally {
600
+ unsubscribeExtensionErrors();
601
+ session.dispose();
602
+ }
603
+ })());
604
+ };
464
605
  let lastScopedModelsKey = "";
465
606
  const updateResolved = () => {
466
607
  const currentModel = session.model;
@@ -530,13 +671,24 @@ export function createDriverFactory(
530
671
  updateResolved();
531
672
  };
532
673
  try {
674
+ // Factories have already run: abort/load failures must use the same awaited
675
+ // shutdown lifecycle as failures during extension binding, without emitting
676
+ // session_start or starting a model turn.
677
+ options.signal.throwIfAborted();
678
+ if (subagentExtensions && loadedExtensions.errors.length) {
679
+ throw new Error(
680
+ `Subagent extension loading failed: ${loadedExtensions.errors
681
+ .map(({ path, error }) => `${path}: ${error}`)
682
+ .join("; ")}`,
683
+ );
684
+ }
533
685
  await enforceScopedModelPolicy();
534
686
  options.signal.throwIfAborted();
535
687
  await session.bindExtensions({ mode: "print" });
536
688
  session.setActiveToolsByName(activeToolNames);
537
689
  options.signal.throwIfAborted();
538
690
  } catch (error) {
539
- session.dispose();
691
+ await disposeSession();
540
692
  throw error;
541
693
  }
542
694
  const streamFunction = session.agent.streamFunction;
@@ -766,13 +918,13 @@ export function createDriverFactory(
766
918
  await abortPromise;
767
919
  },
768
920
  dispose() {
769
- if (disposed) return;
921
+ if (disposed) return shutdownPromise;
770
922
  disposed = true;
771
923
  aborted = true;
772
924
  restoreAppends();
773
925
  transcript.dispose();
774
926
  unsubscribe();
775
- session.dispose();
927
+ return disposeSession();
776
928
  },
777
929
  async sendUpdate(content) {
778
930
  assertOpen();
@@ -186,6 +186,16 @@ function toolPolicy(value: unknown): NonNullable<AgentType["tools"]> {
186
186
  return result;
187
187
  }
188
188
 
189
+ function overrideToolPolicy(value: unknown): NonNullable<AgentSettingsOverride["tools"]> {
190
+ const mapping = record(value, "tools");
191
+ const result: NonNullable<AgentSettingsOverride["tools"]> = {};
192
+ for (const key of Object.keys(mapping)) {
193
+ if (key !== "allow" && key !== "block") throw new Error(`Unknown tools field: ${key}`);
194
+ result[key] = mapping[key] === null ? null : toolNames(mapping[key], `tools.${key}`);
195
+ }
196
+ return result;
197
+ }
198
+
189
199
  export function parseAgentType(content: string, filePath?: string): AgentType {
190
200
  try {
191
201
  const { yaml, body } = frontmatter(content);
@@ -271,7 +281,7 @@ export type AgentCustomizationKind = "fork" | "override";
271
281
  /**
272
282
  * Sparse settings parsed from a `<name>.yml` override file. Plain YAML mapping,
273
283
  * no frontmatter, no Markdown body. Omitted fields follow the base definition;
274
- * explicit `null` on an optional field resets it to the base/inherit state.
284
+ * explicit `null` clears an optional field (rather than inheriting it).
275
285
  */
276
286
  export interface AgentSettingsOverride {
277
287
  name?: string;
@@ -283,7 +293,7 @@ export interface AgentSettingsOverride {
283
293
  thinkingLevel?: AgentType["thinkingLevel"] | null;
284
294
  color?: string | null;
285
295
  icon?: string | null;
286
- tools?: NonNullable<AgentType["tools"]> | null;
296
+ tools?: { allow?: string[] | null; block?: string[] | null } | null;
287
297
  }
288
298
 
289
299
  export const AGENT_OVERRIDE_EXTENSIONS = [".yml", ".yaml"] as const;
@@ -389,7 +399,7 @@ export function parseAgentSettings(
389
399
  return value;
390
400
  });
391
401
  if (Object.hasOwn(data, "tools"))
392
- result.tools = data.tools === null ? null : toolPolicy(data.tools);
402
+ result.tools = data.tools === null ? null : overrideToolPolicy(data.tools);
393
403
  return result;
394
404
  } catch (error) {
395
405
  throw new Error(
@@ -420,16 +430,6 @@ export function serializeAgentSettings(override: AgentSettingsOverride): string
420
430
  return content;
421
431
  }
422
432
 
423
- /** Fields an override may clear back to the base/inherit state with null. */
424
- const CLEARABLE_OVERRIDE_FIELDS = new Set([
425
- "models",
426
- "modelSuggestions",
427
- "thinkingLevel",
428
- "color",
429
- "icon",
430
- "tools",
431
- ]);
432
-
433
433
  /**
434
434
  * Merge a sparse settings override on top of a base definition. Unset fields
435
435
  * follow the base; explicit null clears the field. The prompt body always
@@ -457,24 +457,33 @@ export function mergeAgentSettings(
457
457
  "thinkingLevel",
458
458
  "color",
459
459
  "icon",
460
- "tools",
461
460
  ] as const) {
462
461
  const value = override[key];
463
462
  if (value === undefined) continue;
464
463
  if (value === null) delete merged[key];
465
464
  else (merged[key] as unknown) = structuredClone(value);
466
465
  }
466
+ if (override.tools === null) delete merged.tools;
467
+ else if (override.tools !== undefined) {
468
+ merged.tools ??= {};
469
+ for (const key of ["allow", "block"] as const) {
470
+ const value = override.tools[key];
471
+ if (value === null) delete merged.tools[key];
472
+ else if (value !== undefined) merged.tools[key] = [...value];
473
+ }
474
+ if (!Object.keys(merged.tools).length) delete merged.tools;
475
+ }
467
476
  merged.systemPrompt = base.systemPrompt;
468
477
  return merged;
469
478
  }
470
479
 
471
480
  /**
472
481
  * Diff a draft against its base: only changed settings land in the override
473
- * file, so untouched fields keep tracking bundled updates. Always includes
474
- * the agent name for readability.
482
+ * file, so untouched fields keep tracking bundled updates. The filename
483
+ * identifies the agent; an unchanged draft produces an empty mapping.
475
484
  */
476
485
  export function diffAgentSettings(base: AgentType, draft: AgentType): AgentSettingsOverride {
477
- const override: AgentSettingsOverride = { name: draft.name };
486
+ const override: AgentSettingsOverride = {};
478
487
  if (draft.description !== base.description) override.description = draft.description;
479
488
  const baseModels = getModelPreferences(base);
480
489
  const draftModels = getModelPreferences(draft);
@@ -493,18 +502,64 @@ export function diffAgentSettings(base: AgentType, draft: AgentType): AgentSetti
493
502
  "thinkingLevel",
494
503
  "color",
495
504
  "icon",
496
- "tools",
497
505
  ] as const) {
498
506
  const before = base[key];
499
507
  const after = draft[key];
500
- if (JSON.stringify(before ?? null) === JSON.stringify(after ?? null)) continue;
508
+ if (sameSetting(before, after)) continue;
501
509
  if (after === undefined) override[key] = null as never;
502
510
  else (override[key] as unknown) = structuredClone(after);
503
511
  }
504
- void CLEARABLE_OVERRIDE_FIELDS;
512
+ for (const key of ["allow", "block"] as const) {
513
+ if (sameSetting(base.tools?.[key], draft.tools?.[key])) continue;
514
+ override.tools ??= {};
515
+ override.tools[key] = draft.tools?.[key] === undefined ? null : [...draft.tools[key]!];
516
+ }
505
517
  return override;
506
518
  }
507
519
 
520
+ function sameSetting(before: unknown, after: unknown): boolean {
521
+ return JSON.stringify(before ?? null) === JSON.stringify(after ?? null);
522
+ }
523
+
524
+ /** Retain existing explicit pins; update only settings actually edited in this draft. */
525
+ function updateAgentSettings(
526
+ base: AgentType,
527
+ before: AgentType,
528
+ draft: AgentType,
529
+ existing: AgentSettingsOverride,
530
+ ): AgentSettingsOverride {
531
+ const result = structuredClone(existing);
532
+ const edits = diffAgentSettings(before, draft);
533
+ const desired = diffAgentSettings(base, draft);
534
+ for (const key of [
535
+ "description",
536
+ "models",
537
+ "modelSuggestions",
538
+ "thinkingLevel",
539
+ "color",
540
+ "icon",
541
+ ] as const) {
542
+ if (!Object.hasOwn(edits, key)) continue;
543
+ if (desired[key] === undefined) delete result[key];
544
+ else (result[key] as unknown) = desired[key];
545
+ if (key === "models") delete result.model;
546
+ }
547
+ if (edits.tools) {
548
+ // Whole-policy clears must keep clearing the untouched sibling, too.
549
+ if (result.tools === null) result.tools = { allow: null, block: null };
550
+ const tools = result.tools ?? {};
551
+ for (const key of ["allow", "block"] as const) {
552
+ if (!Object.hasOwn(edits.tools, key)) continue;
553
+ const value = desired.tools?.[key];
554
+ if (value === undefined) delete tools[key];
555
+ else tools[key] = value;
556
+ }
557
+ if (Object.keys(tools).length) result.tools = tools;
558
+ else delete result.tools;
559
+ }
560
+ return result;
561
+ }
562
+
508
563
  export function selectTools(
509
564
  policy: AgentType["tools"],
510
565
  available: string[],
@@ -539,6 +594,8 @@ export class ConfigStore {
539
594
  diagnostics: string[] = [];
540
595
  private types = new Map<string, AgentType>();
541
596
  private bases = new Map<string, AgentType>();
597
+ private scopeBases = new Map<AgentScope, Map<string, AgentType>>();
598
+ private scopeOverrides = new Map<AgentScope, Map<string, AgentSettingsOverride>>();
542
599
  private readonly options: ConfigStoreOptions;
543
600
 
544
601
  constructor(options: ConfigStoreOptions) {
@@ -549,6 +606,8 @@ export class ConfigStore {
549
606
  reload(): void {
550
607
  this.types.clear();
551
608
  this.bases.clear();
609
+ this.scopeBases.clear();
610
+ this.scopeOverrides.clear();
552
611
  this.diagnostics = [];
553
612
  const layers: [string, NonNullable<AgentType["source"]>][] = [
554
613
  [
@@ -573,6 +632,10 @@ export class ConfigStore {
573
632
  ),
574
633
  );
575
634
  for (const [directory, source] of layers) {
635
+ if (source !== "bundled") {
636
+ this.scopeBases.set(source, structuredClone(this.types));
637
+ this.scopeOverrides.set(source, new Map());
638
+ }
576
639
  let files: string[];
577
640
  try {
578
641
  const stat = assertNotSymlinkPath(directory);
@@ -812,6 +875,7 @@ export class ConfigStore {
812
875
  try {
813
876
  const merged = mergeAgentSettings(base, { ...override, name });
814
877
  this.bases.set(name, structuredClone(base));
878
+ this.scopeOverrides.get(scope)!.set(name, structuredClone(override));
815
879
  this.types.set(name, {
816
880
  ...merged,
817
881
  name,
@@ -892,6 +956,12 @@ export class ConfigStore {
892
956
  return base ? structuredClone(base) : undefined;
893
957
  }
894
958
 
959
+ /** Definition below a specific save scope; never includes that scope or higher ones. */
960
+ private getScopeBase(name: string, scope: AgentScope): AgentType | undefined {
961
+ const base = this.scopeBases.get(scope)?.get(name);
962
+ return base ? structuredClone(base) : undefined;
963
+ }
964
+
895
965
  private canPreserveDestination(
896
966
  name: string,
897
967
  scope: AgentScope,
@@ -976,28 +1046,27 @@ export class ConfigStore {
976
1046
  /**
977
1047
  * Save a settings-only `<name>.yml` override merged on top of the base.
978
1048
  * The prompt body always comes from the base; only changed settings are
979
- * written so untouched fields keep tracking bundled updates.
1049
+ * written so untouched fields keep tracking bundled updates. Existing pins
1050
+ * are retained; `original` is the pre-edit snapshot (also used to avoid
1051
+ * copying inherited settings into another scope or from a stale draft).
980
1052
  */
981
1053
  saveOverride(
982
1054
  name: string,
983
1055
  draft: AgentType,
984
1056
  scope: AgentScope,
985
- original?: SaveOrigin,
1057
+ original?: AgentType,
986
1058
  ): AgentType {
987
1059
  if (!NAME.test(name)) throw new Error("Unsafe agent name");
988
1060
  if (draft.name !== name)
989
1061
  throw new Error("Settings overrides cannot rename the agent; fork it instead");
990
- const base = this.getBase(name) ?? (() => {
991
- try {
992
- return this.get(name);
993
- } catch {
994
- return undefined;
995
- }
996
- })();
1062
+ const base = this.getScopeBase(name, scope);
997
1063
  if (!base) throw new Error(`Settings override has no base agent named ${JSON.stringify(name)}`);
998
- if (base.name !== name)
999
- throw new Error(`Settings override has no base agent named ${JSON.stringify(name)}`);
1000
- const override = diffAgentSettings(base, { ...draft, name });
1064
+ const before = original ?? this.get(name);
1065
+ const existing = this.scopeOverrides.get(scope)?.get(name) ?? {};
1066
+ const override =
1067
+ before.customization?.kind === "fork"
1068
+ ? diffAgentSettings(base, draft)
1069
+ : updateAgentSettings(base, before, draft, existing);
1001
1070
  const content = serializeAgentSettings(override);
1002
1071
  parseAgentSettings(content, undefined, name);
1003
1072
  const filePath = this.destination(name, scope, original, "override");
@@ -51,6 +51,7 @@ export interface ManagerSettings {
51
51
  nerdFontIcons: boolean;
52
52
  loaderStyle: LoaderStyle;
53
53
  finalRecap: boolean;
54
+ subagentExtensions: boolean;
54
55
  maxLevels: number;
55
56
  maxConcurrent: number;
56
57
  maxThreads: number;
@@ -71,10 +72,11 @@ export const DEFAULT_MANAGER_SETTINGS: ManagerSettings = {
71
72
  nerdFontIcons: false,
72
73
  loaderStyle: "circle",
73
74
  finalRecap: false,
75
+ subagentExtensions: false,
74
76
  };
75
77
 
76
78
  const KEYS = [
77
- "maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "costDisplay", "costValue", "costIcon", "nerdFontIcons", "loaderStyle", "finalRecap",
79
+ "maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "costDisplay", "costValue", "costIcon", "nerdFontIcons", "loaderStyle", "finalRecap", "subagentExtensions",
78
80
  ] as const;
79
81
  const MAX_LEVELS = 32;
80
82
 
@@ -112,7 +114,7 @@ function positiveSafeInteger(value: unknown): value is number {
112
114
  }
113
115
 
114
116
  function requirement(key: (typeof KEYS)[number]): string {
115
- if (key === "nerdFontIcons" || key === "finalRecap") return `${key} must be a boolean`;
117
+ if (key === "nerdFontIcons" || key === "finalRecap" || key === "subagentExtensions") return `${key} must be a boolean`;
116
118
  if (key === "subagentMode") return "subagentMode must be off, opportunistic or orchestration";
117
119
  if (key === "widgetMode") return "widgetMode must be full or minimal";
118
120
  if (key === "costDisplay") return "costDisplay must be pi-footer-event, pi-footer-status or pi-status";
@@ -151,7 +153,7 @@ function parseSettings(content: string): Partial<ManagerSettings> {
151
153
  for (const key of KEYS) {
152
154
  if (!Object.hasOwn(record, key)) continue;
153
155
  const value = record[key];
154
- if (key === "nerdFontIcons" || key === "finalRecap") {
156
+ if (key === "nerdFontIcons" || key === "finalRecap" || key === "subagentExtensions") {
155
157
  if (typeof value !== "boolean") throw new Error(requirement(key));
156
158
  layer[key] = value;
157
159
  continue;
package/src/types.ts CHANGED
@@ -128,7 +128,7 @@ export interface AgentDriver {
128
128
  observeTranscript?(listener: TranscriptListener): TranscriptObservation;
129
129
  output(): string;
130
130
  abort(): Promise<void>;
131
- dispose(): void;
131
+ dispose(): void | Promise<void>;
132
132
  sendUpdate(content: string): Promise<void> | void;
133
133
  sessionFile?: string;
134
134
  sessionLeafId?: string | null;
@@ -17,7 +17,7 @@ import { AGENT_PROGRESS_INTERVAL, agentProgressIcon, agentTypeLabel } from "./ui
17
17
  import type { LoaderStyle } from "../prefs/settings.ts";
18
18
  import { renderTranscriptTool } from "./transcript-tool.ts";
19
19
 
20
- /** Transcript detail level cycled by the t key: full → preview → compact. */
20
+ /** Transcript detail level cycled by Ctrl+O: full → preview → compact. */
21
21
  export type TranscriptDetail = "full" | "preview" | "compact";
22
22
  const DETAIL_CYCLE: TranscriptDetail[] = ["full", "preview", "compact"];
23
23
 
@@ -260,7 +260,8 @@ export class LiveAgentView {
260
260
  if (matchesKey(data, Key.ctrl("q")) || matchesKey(data, Key.ctrl("c")))
261
261
  return this.done("main");
262
262
  if (matchesKey(data, Key.ctrl("o"))) {
263
- this.viewport.detail = this.detail === "full" ? "preview" : "full";
263
+ this.viewport.detail =
264
+ DETAIL_CYCLE[(DETAIL_CYCLE.indexOf(this.detail) + 1) % DETAIL_CYCLE.length];
264
265
  this.invalidate();
265
266
  this.host.requestRender();
266
267
  return;
@@ -288,10 +289,6 @@ export class LiveAgentView {
288
289
  } else if (data === "c") {
289
290
  this.viewport.showInherited = !this.viewport.showInherited;
290
291
  this.invalidate();
291
- } else if (data === "t") {
292
- this.viewport.detail =
293
- DETAIL_CYCLE[(DETAIL_CYCLE.indexOf(this.detail) + 1) % DETAIL_CYCLE.length];
294
- this.invalidate();
295
292
  } else if (matchesKey(data, Key.home)) this.scroll.scrollTo(0, { disableFollow: true });
296
293
  else if (matchesKey(data, Key.end) || data === "l") this.scroll.scrollToEnd();
297
294
  else return;
@@ -378,7 +375,7 @@ export class LiveAgentView {
378
375
  if (block.type === "image") return ["[Image — text-only observer]"];
379
376
  if (block.type === "thinking") {
380
377
  if (this.detail === "compact")
381
- return [this.theme.fg("dim", "[Thinking hidden · t cycles view]")];
378
+ return [this.theme.fg("dim", "[Thinking hidden · Ctrl+O cycles view]")];
382
379
  // Thinking is model-authored Markdown; preview truncates the rendered lines, not the source.
383
380
  const rendered = this.markdown(String(block.thinking ?? "[redacted thinking]"), width, true);
384
381
  if (this.detail === "full" || rendered.length <= 3) return rendered;
@@ -548,7 +545,7 @@ export class LiveAgentView {
548
545
  this.saveViewport();
549
546
  const footer = this.error
550
547
  ? "Ctrl+R Retry · Tab input/transcript · Esc tree · Ctrl+Q main"
551
- : `${this.editing ? "Enter steer · Tab browse" : `Tab steer · Home/End scroll · c context · t view:${this.detail}`} · Ctrl+O expand tools · Esc tree · Ctrl+Q main · ↑↓/PgUp/PgDn scroll · ${this.viewport.follow ? "following" : "scrolled"}`;
548
+ : `${this.editing ? "Enter steer · Tab browse" : "Tab steer · Home/End scroll · c context"} · Ctrl+O view:${this.detail} · Esc tree · Ctrl+Q main · ↑↓/PgUp/PgDn scroll · ${this.viewport.follow ? "following" : "scrolled"}`;
552
549
  const input = ` ${this.input.render(inner)[0]!}`;
553
550
  const status = this.theme.fg(
554
551
  this.steerStatus ? (this.steerFailed ? "error" : "muted") : this.error ? "error" : "muted",
@@ -302,6 +302,12 @@ async function configureAgentsDialog(
302
302
  value: AGENT_LOADERS[draft.loaderStyle].label,
303
303
  help: "Choose Circle, Braille or Hourglass. Preview every animation frame and settled state for all families.\nRequires [labs] Nerd Font icons On. Circle is the default.\nSave and apply to update the widget immediately.",
304
304
  },
305
+ {
306
+ id: "subagentExtensions",
307
+ label: "[labs] Enable subagent extensions",
308
+ value: draft.subagentExtensions ? "On" : "Off",
309
+ help: "Experimental: reload configured user/trusted-project extension hooks in separate subagent sessions (not CLI-only or inline extensions). Bugs and unintended consequences may occur if hooks assume main-session state.\nRead limitations: https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/subagent-extension-limitations.md\nOff by default. Save and apply affects newly opened sessions, not already-open agents.",
310
+ },
305
311
  {
306
312
  id: "finalRecap",
307
313
  label: "[labs] Final Recap",
@@ -398,6 +404,8 @@ async function configureAgentsDialog(
398
404
  selectedId: draft.loaderStyle,
399
405
  });
400
406
  if (LOADER_STYLES.includes(style as LoaderStyle)) draft.loaderStyle = style as LoaderStyle;
407
+ } else if (action === "subagentExtensions") {
408
+ draft.subagentExtensions = !draft.subagentExtensions;
401
409
  } else if (action === "finalRecap") {
402
410
  draft.finalRecap = !draft.finalRecap;
403
411
  } else if (action === "scope") {
package/src/ui/ui.ts CHANGED
@@ -24,7 +24,6 @@ import {
24
24
  import {
25
25
  AGENT_COLORS,
26
26
  ConfigStore,
27
- diffAgentSettings,
28
27
  parseAgentType,
29
28
  serializeAgentType,
30
29
  } from "../prefs/config.ts";
@@ -980,7 +979,7 @@ async function chooseCustomizationMode(
980
979
  id: "override",
981
980
  label: "Tweak settings",
982
981
  value: `${agentName}.yml`,
983
- help: "Override only settings (models, tools, thinking, color). The prompt stays bundled and keeps receiving updates. System prompt and name stay locked.",
982
+ help: "Start with an empty settings overlay; only changed fields are saved. The prompt stays bundled and keeps receiving updates. System prompt and name stay locked.",
984
983
  },
985
984
  {
986
985
  id: "fork",
@@ -1079,14 +1078,7 @@ async function editAgentTypesDialog(
1079
1078
  editMode = mode;
1080
1079
  }
1081
1080
  while (true) {
1082
- const baseForDiff =
1083
- editMode === "override" && original
1084
- ? (store.getBase(original.name) ?? original)
1085
- : undefined;
1086
- const dirty =
1087
- editMode === "override" && baseForDiff
1088
- ? Object.keys(diffAgentSettings(baseForDiff, draft)).length > 1
1089
- : !original || serializeAgentType(draft) !== originalContent;
1081
+ const dirty = !original || serializeAgentType(draft) !== originalContent;
1090
1082
  const field = await dialogMenu(
1091
1083
  ctx,
1092
1084
  `Edit ${sanitizeText(draft.name)} (unsaved)`,