pi-subagent-manager 1.12.0 โ†’ 1.13.1

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
@@ -1,4 +1,4 @@
1
- # pi-subagent-manager
1
+ ![pi-subagent-manager](https://raw.githubusercontent.com/championswimmer/pi-subagent-manager/main/assets/banner.png)
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/pi-subagent-manager.svg)](https://www.npmjs.com/package/pi-subagent-manager)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/pi-subagent-manager.svg)](https://www.npmjs.com/package/pi-subagent-manager)
@@ -8,29 +8,29 @@
8
8
 
9
9
  Let pi hand work to helper agents in parallel. Watch what they're doing, give them more direction, or pick up a finished agent's conversation.
10
10
 
11
- ![Pi running parallel agents, browsing a nested agent tree, steering a writer, and watching passing tests](https://raw.githubusercontent.com/championswimmer/pi-subagent-manager/main/docs/assets/subagent-manager-demo.gif)
11
+ ## Install
12
12
 
13
- A real Pi session with a customized footer and Nerd Font: parallel work, nested delegation, watching, and steering. [Recording details](https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/demo.md) (37 seconds; pauses shortened).
13
+ ```bash
14
+ pi install npm:pi-subagent-manager
15
+ ```
14
16
 
15
- ## Check out my other Pi extensions
17
+ Requires pi **0.99.2+**.
16
18
 
17
- - [![pi-cache-graph](https://img.shields.io/badge/๐Ÿ“Š_pi--cache--graph-orange?style=flat-square)](https://github.com/championswimmer/pi-cache-graph) โ€” Real-time prompt cache hit rates and token metrics.
18
- - [![pi-checklist](https://img.shields.io/badge/โœ…_pi--checklist-teal?style=flat-square)](https://github.com/championswimmer/pi-checklist) โ€” Session task checklist with dependencies and a TUI renderer.
19
- - [![pi-context-decisions](https://img.shields.io/badge/๐Ÿง _pi--context--decisions-indigo?style=flat-square)](https://github.com/championswimmer/pi-context-decisions) โ€” Selects relevant skills and optionally filters tools for each task.
20
- - [![pi-context-prune](https://img.shields.io/badge/โœ‚๏ธ_pi--context--prune-green?style=flat-square)](https://github.com/championswimmer/pi-context-prune) โ€” Prunes verbose tool outputs from context while preserving history.
21
- - [![pi-context-usage](https://img.shields.io/badge/๐ŸชŸ_pi--context--usage-purple?style=flat-square)](https://github.com/championswimmer/pi-context-usage) โ€” Dot-grid visualization of context window token usage.
22
- - [![pi-gauge](https://img.shields.io/badge/โšก_pi--gauge-yellow?style=flat-square)](https://github.com/championswimmer/pi-gauge) โ€” Live tokens/sec and TTFT in the status bar.
23
- - [![pi-subagent-manager](https://img.shields.io/badge/๐Ÿค–_pi--subagent--manager-blue?style=flat-square)](https://github.com/championswimmer/pi-subagent-manager) โ€” Delegate work to parallel subagents and monitor their progress.
19
+ ## Why use it
24
20
 
25
- ## Install
21
+ - Hand independent jobs to helper agents that run in parallel.
22
+ - Watch any agent live in a nested agent tree.
23
+ - Steer a running agent with more direction, or resume it after it finishes.
24
+ - Choose `fork:` to share your conversation or `fresh:` to start clean.
25
+ - Six bundled roles, with per-role model, tools, and instructions you can change, plus custom agents.
26
26
 
27
- Requires pi **0.99.2+**.
27
+ ## How to use
28
28
 
29
- ```sh
30
- pi install npm:pi-subagent-manager
31
- ```
29
+ ![Pi running parallel agents, browsing a nested agent tree, steering a writer, and watching passing tests](https://raw.githubusercontent.com/championswimmer/pi-subagent-manager/main/docs/assets/subagent-manager-demo.gif)
30
+
31
+ A real Pi session with a customized footer and Nerd Font: parallel work, nested delegation, watching, and steering. [Recording details](https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/demo.md) (37 seconds; pauses shortened).
32
32
 
33
- ## Start using it
33
+ ### Start using it
34
34
 
35
35
  Ask pi to delegate in plain language:
36
36
 
@@ -46,7 +46,7 @@ Or start an agent yourself:
46
46
 
47
47
  The **Agents** widget above the input shows what's running. Open `/agents tree`, select an agent, and press **Enter** to watch it. Type in the **Steer** input to give it more direction or resume it after it finishes. Results also return to the main agent.
48
48
 
49
- ## Bundled agents
49
+ ### Bundled agents
50
50
 
51
51
  | Agent | Use it for |
52
52
  | ------------ | --------------------------------------- |
@@ -74,3 +74,13 @@ Agents share your working directory and OS permissions: **tool policies are not
74
74
  - [Development](https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/development.md) ยท [Changelog](CHANGELOG.md)
75
75
 
76
76
  [MIT license](LICENSE)
77
+
78
+ ## Check out my other Pi extensions
79
+
80
+ - [![pi-cache-graph](https://img.shields.io/badge/๐Ÿ“Š_pi--cache--graph-orange?style=flat-square)](https://github.com/championswimmer/pi-cache-graph) โ€” Real-time prompt cache hit rates and token metrics.
81
+ - [![pi-checklist](https://img.shields.io/badge/โœ…_pi--checklist-teal?style=flat-square)](https://github.com/championswimmer/pi-checklist) โ€” Session task checklist with dependencies and a TUI renderer.
82
+ - [![pi-context-decisions](https://img.shields.io/badge/๐Ÿง _pi--context--decisions-indigo?style=flat-square)](https://github.com/championswimmer/pi-context-decisions) โ€” Selects relevant skills and optionally filters tools for each task.
83
+ - [![pi-context-prune](https://img.shields.io/badge/โœ‚๏ธ_pi--context--prune-green?style=flat-square)](https://github.com/championswimmer/pi-context-prune) โ€” Prunes verbose tool outputs from context while preserving history.
84
+ - [![pi-context-usage](https://img.shields.io/badge/๐ŸชŸ_pi--context--usage-purple?style=flat-square)](https://github.com/championswimmer/pi-context-usage) โ€” Dot-grid visualization of context window token usage.
85
+ - [![pi-gauge](https://img.shields.io/badge/โšก_pi--gauge-yellow?style=flat-square)](https://github.com/championswimmer/pi-gauge) โ€” Live tokens/sec and TTFT in the status bar.
86
+ - [![pi-subagent-manager](https://img.shields.io/badge/๐Ÿค–_pi--subagent--manager-blue?style=flat-square)](https://github.com/championswimmer/pi-subagent-manager) โ€” Delegate work to parallel subagents and monitor their progress.
@@ -2,6 +2,7 @@ import { realpath, readFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { DefaultPackageManager, SettingsManager } from "@earendil-works/pi-coding-agent";
5
+ import { AGENT_DIR_EXTENSION_PREFIX } from "../prefs/settings.js";
5
6
  const ENTRY_EXT = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
6
7
  const MANAGER_ENTRY = fileURLToPath(new URL(`../index${ENTRY_EXT}`, import.meta.url));
7
8
  export function extensionDisplayName(file) {
@@ -35,13 +36,18 @@ async function isManagerExtension(file, packageRoot) {
35
36
  }
36
37
  }
37
38
  }
39
+ function relativeWithin(base, file) {
40
+ const relative = path.relative(base, file);
41
+ return relative && !path.isAbsolute(relative) && relative !== ".." &&
42
+ !relative.startsWith(`..${path.sep}`) ? relative : undefined;
43
+ }
38
44
  export async function discoverSubagentExtensions(options) {
39
45
  const settingsManager = SettingsManager.create(options.cwd, options.agentDir, {
40
46
  projectTrusted: options.projectTrusted,
41
47
  });
42
48
  const packages = new DefaultPackageManager({ ...options, settingsManager });
43
49
  const resources = await packages.resolve(async () => "skip");
44
- const paths = [];
50
+ const extensions = [];
45
51
  const seen = new Set();
46
52
  for (const resource of resources.extensions) {
47
53
  if (!resource.enabled || resource.path.startsWith("builtin:"))
@@ -52,15 +58,24 @@ export async function discoverSubagentExtensions(options) {
52
58
  if (seen.has(resolved))
53
59
  continue;
54
60
  seen.add(resolved);
55
- paths.push(resolved);
61
+ const projectFile = resource.metadata.scope === "project"
62
+ ? relativeWithin(options.cwd, resource.path)
63
+ : undefined;
64
+ const agentFile = resource.metadata.scope === "user"
65
+ ? relativeWithin(options.agentDir, resource.path)
66
+ : undefined;
67
+ const id = agentFile
68
+ ? AGENT_DIR_EXTENSION_PREFIX + agentFile.split(path.sep).join("/")
69
+ : projectFile ?? resolved;
70
+ extensions.push({ id, path: resolved });
56
71
  }
57
- return paths;
72
+ return extensions;
58
73
  }
59
74
  export function selectSubagentExtensions(available, selection) {
60
- if (selection === true)
61
- return [...available];
62
75
  if (selection === false)
63
76
  return [];
64
- const selected = new Set(selection);
65
- return available.filter((file) => selected.has(file));
77
+ const selected = new Set(selection === true ? [] : selection);
78
+ return available
79
+ .filter(({ id, path }) => selection === true || selected.has(id) || selected.has(path))
80
+ .map(({ path }) => path);
66
81
  }
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { closeSync, constants, fchmodSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
3
- import { dirname, join, resolve } from "node:path";
3
+ import { dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
4
4
  export const SUBAGENT_MODES = ["off", "opportunistic", "orchestration"];
5
5
  export const WIDGET_MODES = ["full", "minimal"];
6
6
  const COST_DISPLAY_MODES = ["pi-footer-event", "pi-footer-status", "pi-status"];
@@ -20,6 +20,7 @@ export const MODEL_SELECTION_MODES = [
20
20
  "pick-first-scoped",
21
21
  "use-current",
22
22
  ];
23
+ export const AGENT_DIR_EXTENSION_PREFIX = "$PI_CODING_AGENT_DIR/";
23
24
  export function settingsValueEqual(a, b) {
24
25
  return JSON.stringify(a) === JSON.stringify(b);
25
26
  }
@@ -91,9 +92,24 @@ function isSupportedKey(key) {
91
92
  function positiveSafeInteger(value) {
92
93
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
93
94
  }
95
+ function isExtensionSelectionPath(entry) {
96
+ if (typeof entry !== "string" || !entry || entry.includes("\0"))
97
+ return false;
98
+ if (entry.startsWith(AGENT_DIR_EXTENSION_PREFIX)) {
99
+ const suffix = entry.slice(AGENT_DIR_EXTENSION_PREFIX.length);
100
+ return !suffix.includes("\\") &&
101
+ suffix.split("/").every((part) => part && part !== "." && part !== "..");
102
+ }
103
+ if (entry === AGENT_DIR_EXTENSION_PREFIX.slice(0, -1))
104
+ return false;
105
+ if (isAbsolute(entry))
106
+ return resolve(entry) === entry;
107
+ return normalize(entry) === entry &&
108
+ entry !== "." && entry !== ".." && !entry.startsWith(`..${sep}`) && !entry.endsWith(sep);
109
+ }
94
110
  function requirement(key) {
95
111
  if (key === "subagentExtensions")
96
- return "subagentExtensions must be a boolean or an array of absolute file paths";
112
+ return "subagentExtensions must be a boolean or an array of absolute, project-relative, or $PI_CODING_AGENT_DIR paths";
97
113
  if (key === "nerdFontIcons" ||
98
114
  key === "finalRecap" ||
99
115
  key === "checklistIntegration" ||
@@ -159,12 +175,7 @@ function parseSettings(content) {
159
175
  continue;
160
176
  }
161
177
  if (key === "subagentExtensions") {
162
- if (typeof value !== "boolean" &&
163
- !(Array.isArray(value) &&
164
- value.every((entry) => typeof entry === "string" &&
165
- entry.length > 0 &&
166
- resolve(entry) === entry &&
167
- !entry.includes("\0"))))
178
+ if (typeof value !== "boolean" && !(Array.isArray(value) && value.every(isExtensionSelectionPath)))
168
179
  throw new Error(requirement(key));
169
180
  layer.subagentExtensions =
170
181
  typeof value === "boolean" ? value : [...new Set(value)].sort();
@@ -141,12 +141,16 @@ function provenanceLegend(theme) {
141
141
  `${global} Global ยท ${project} Current Project ยท ${global} ${project} Both`);
142
142
  }
143
143
  async function configureSubagentExtensions(ctx, draft, agentDir) {
144
- const available = await discoverSubagentExtensions({
144
+ const discovered = await discoverSubagentExtensions({
145
145
  cwd: ctx.cwd,
146
146
  agentDir,
147
147
  projectTrusted: ctx.isProjectTrusted(),
148
148
  });
149
- const selected = new Set(draft.subagentExtensions === true ? available : draft.subagentExtensions || []);
149
+ const available = new Set(discovered.map(({ id }) => id));
150
+ const idsByPath = new Map(discovered.map(({ path, id }) => [path, id]));
151
+ const selected = new Set(draft.subagentExtensions === true
152
+ ? available
153
+ : (draft.subagentExtensions || []).map((file) => idsByPath.get(file) ?? file));
150
154
  const files = [...new Set([...available, ...selected])].sort();
151
155
  let selectedId;
152
156
  while (true) {
@@ -154,8 +158,8 @@ async function configureSubagentExtensions(ctx, draft, agentDir) {
154
158
  ...files.map((file) => ({
155
159
  id: file,
156
160
  label: `${selected.has(file) ? "[x]" : "[ ]"} ${extensionDisplayName(file)}`,
157
- value: available.includes(file) ? (selected.has(file) ? "On" : "Off") : "Unavailable",
158
- help: `${file}\n${available.includes(file) ? "Reload this extension in newly opened subagent sessions." : "Not currently discoverable/trusted; will not load. Toggle Off to remove the saved selection."}\nSpace/Enter toggles. Changes are saved only with outer Save and apply.`,
161
+ value: available.has(file) ? (selected.has(file) ? "On" : "Off") : "Unavailable",
162
+ help: `${file}\n${available.has(file) ? "Reload this extension in newly opened subagent sessions." : "Not currently discoverable/trusted; will not load. Toggle Off to remove the saved selection."}\nSpace/Enter toggles. Changes are saved only with outer Save and apply.`,
159
163
  })),
160
164
  {
161
165
  id: "back",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagent-manager",
3
- "version": "1.12.0",
3
+ "version": "1.13.1",
4
4
  "description": "Hierarchical, steerable subagent threads for pi",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,7 +42,8 @@
42
42
  "pi": {
43
43
  "extensions": [
44
44
  "./dist/index.js"
45
- ]
45
+ ],
46
+ "image": "https://raw.githubusercontent.com/championswimmer/pi-subagent-manager/main/assets/banner.png"
46
47
  },
47
48
  "scripts": {
48
49
  "build": "rm -rf dist && tsc -p tsconfig.build.json",