@narumitw/pi-subagents 0.17.1 → 0.18.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 +37 -1
- package/package.json +1 -1
- package/src/config-ui.ts +27 -5
- package/src/params.ts +2 -1
- package/src/stateful.ts +5 -1
- package/src/subagents.ts +1 -1
package/README.md
CHANGED
|
@@ -335,7 +335,43 @@ You are an API review subagent. Do not edit files. Check compatibility,
|
|
|
335
335
|
test coverage, and migration risks. Report PASS/FAIL/PARTIAL with evidence.
|
|
336
336
|
```
|
|
337
337
|
|
|
338
|
-
|
|
338
|
+
`agentScope` is a top-level tool argument supplied per invocation. It is not a setting in
|
|
339
|
+
`~/.pi/agent/pi-subagents.json` and does not belong in agent frontmatter. The scope selects which
|
|
340
|
+
custom agent directories are loaded; built-in agents remain available in every scope:
|
|
341
|
+
|
|
342
|
+
| `agentScope` | Custom agents loaded |
|
|
343
|
+
| --- | --- |
|
|
344
|
+
| `"user"` (default) | User agents only. |
|
|
345
|
+
| `"project"` | Project-local agents only. |
|
|
346
|
+
| `"both"` | User and project-local agents. Project definitions override same-named user definitions. |
|
|
347
|
+
|
|
348
|
+
For example, invoke a project-local agent with the blocking `subagent` tool:
|
|
349
|
+
|
|
350
|
+
```json
|
|
351
|
+
{
|
|
352
|
+
"agent": "api-reviewer",
|
|
353
|
+
"task": "Review this project's API changes",
|
|
354
|
+
"agentScope": "project"
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Or select the scope when creating a stateful agent with `subagent_spawn`:
|
|
359
|
+
|
|
360
|
+
```json
|
|
361
|
+
{
|
|
362
|
+
"agent": "api-reviewer",
|
|
363
|
+
"task": "Review this project's API changes",
|
|
364
|
+
"agentScope": "project"
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
A stateful agent retains the scope selected by `subagent_spawn` for its follow-ups. Every new
|
|
369
|
+
blocking `subagent` invocation or `subagent_spawn` call that needs project agents must supply
|
|
370
|
+
`agentScope: "project"` or `"both"` again.
|
|
371
|
+
|
|
372
|
+
Project-local agents require a trusted Pi project. Interactive sessions also ask for confirmation
|
|
373
|
+
before using them by default. Passing `confirmProjectAgents: false` as another top-level tool
|
|
374
|
+
argument skips that confirmation dialog, but it does not bypass the project trust requirement.
|
|
339
375
|
|
|
340
376
|
## ⏱️ Runtime limits and thinking levels
|
|
341
377
|
|
package/package.json
CHANGED
package/src/config-ui.ts
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
Container,
|
|
5
5
|
Key,
|
|
6
6
|
matchesKey,
|
|
7
|
-
SelectList,
|
|
8
7
|
type SelectItem,
|
|
8
|
+
SelectList,
|
|
9
9
|
Spacer,
|
|
10
10
|
Text,
|
|
11
11
|
truncateToWidth,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
uniqueToolNames,
|
|
21
21
|
} from "./settings.js";
|
|
22
22
|
|
|
23
|
-
class ToolToggleList {
|
|
23
|
+
export class ToolToggleList {
|
|
24
24
|
private items: { name: string; selected: boolean }[];
|
|
25
25
|
private cursor = 0;
|
|
26
26
|
private cachedWidth?: number;
|
|
@@ -98,6 +98,7 @@ export function registerSubagentConfigCommand(pi: ExtensionAPI) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// Loop: agent selection → tool toggle (Esc in tools returns here)
|
|
101
|
+
let selectedAgentIndex = 0;
|
|
101
102
|
while (true) {
|
|
102
103
|
// Step 1: pick an agent to configure
|
|
103
104
|
const agentItems: SelectItem[] = agents.map((a) => {
|
|
@@ -133,7 +134,20 @@ export function registerSubagentConfigCommand(pi: ExtensionAPI) {
|
|
|
133
134
|
scrollInfo: (t: string) => theme.fg("dim", t),
|
|
134
135
|
noMatch: (t: string) => theme.fg("warning", t),
|
|
135
136
|
});
|
|
136
|
-
selectList.
|
|
137
|
+
selectList.setSelectedIndex(selectedAgentIndex);
|
|
138
|
+
selectList.onSelectionChange = (item) => {
|
|
139
|
+
selectedAgentIndex = Math.max(
|
|
140
|
+
0,
|
|
141
|
+
agentItems.findIndex((candidate) => candidate.value === item.value),
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
selectList.onSelect = (item) => {
|
|
145
|
+
selectedAgentIndex = Math.max(
|
|
146
|
+
0,
|
|
147
|
+
agentItems.findIndex((candidate) => candidate.value === item.value),
|
|
148
|
+
);
|
|
149
|
+
done(item.value);
|
|
150
|
+
};
|
|
137
151
|
selectList.onCancel = () => done(null);
|
|
138
152
|
container.addChild(selectList);
|
|
139
153
|
container.addChild(
|
|
@@ -193,7 +207,11 @@ export function registerSubagentConfigCommand(pi: ExtensionAPI) {
|
|
|
193
207
|
);
|
|
194
208
|
container.addChild(new Spacer(1));
|
|
195
209
|
container.addChild(
|
|
196
|
-
new Text(
|
|
210
|
+
new Text(
|
|
211
|
+
theme.fg("muted", "Toggle tools with Enter/Space. S to save, Esc to cancel."),
|
|
212
|
+
1,
|
|
213
|
+
0,
|
|
214
|
+
),
|
|
197
215
|
);
|
|
198
216
|
container.addChild(new Spacer(1));
|
|
199
217
|
|
|
@@ -206,7 +224,11 @@ export function registerSubagentConfigCommand(pi: ExtensionAPI) {
|
|
|
206
224
|
|
|
207
225
|
container.addChild(new Spacer(1));
|
|
208
226
|
container.addChild(
|
|
209
|
-
new Text(
|
|
227
|
+
new Text(
|
|
228
|
+
theme.fg("dim", "↑↓ navigate · enter/space toggle · S save · esc cancel"),
|
|
229
|
+
1,
|
|
230
|
+
0,
|
|
231
|
+
),
|
|
210
232
|
);
|
|
211
233
|
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
212
234
|
|
package/src/params.ts
CHANGED
|
@@ -37,7 +37,8 @@ const AggregatorItem = Type.Object({
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
const AgentScopeSchema = StringEnum(["user", "project", "both"] as const, {
|
|
40
|
-
description:
|
|
40
|
+
description:
|
|
41
|
+
'Per-invocation custom agent scope. Default: "user". Use "project" for project-local agents or "both" for user and project agents; this is a tool argument, not a pi-subagents.json setting.',
|
|
41
42
|
default: "user",
|
|
42
43
|
});
|
|
43
44
|
|
package/src/stateful.ts
CHANGED
|
@@ -31,7 +31,11 @@ const ContextModeSchema = Type.Union([
|
|
|
31
31
|
StringEnum(["none", "all", "summary"] as const),
|
|
32
32
|
Type.Number({ minimum: 1, description: "Include the most recent N user turns." }),
|
|
33
33
|
]);
|
|
34
|
-
const ScopeSchema = StringEnum(["user", "project", "both"] as const
|
|
34
|
+
const ScopeSchema = StringEnum(["user", "project", "both"] as const, {
|
|
35
|
+
description:
|
|
36
|
+
'Per-invocation custom agent scope for this spawn. Default: "user". Use "project" for project-local agents or "both" for user and project agents; the selected scope is retained for follow-ups.',
|
|
37
|
+
default: "user",
|
|
38
|
+
});
|
|
35
39
|
const MAX_TOOL_MESSAGE_BYTES = 2 * 1024;
|
|
36
40
|
const MAX_COMPLETION_ERROR_BYTES = 512;
|
|
37
41
|
|
package/src/subagents.ts
CHANGED
|
@@ -30,7 +30,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
30
30
|
"Modes: single (agent + task), parallel (tasks array), chain (sequential with {previous} placeholder).",
|
|
31
31
|
"Parallel mode may include an aggregator fan-in step that receives all task outputs.",
|
|
32
32
|
'Default agent scope is "user" (from ~/.pi/agent/agents).',
|
|
33
|
-
'To enable project-local agents in .pi/agents,
|
|
33
|
+
'To enable project-local agents in .pi/agents, pass agentScope: "both" (or "project") as a top-level argument for that call.',
|
|
34
34
|
].join(" "),
|
|
35
35
|
promptSnippet:
|
|
36
36
|
"Decide whether to spawn 0, 1, or multiple subagents for independent research, review, verification, or multi-step work in isolated Pi processes.",
|