pi-subagents-j0k3r 1.0.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/.releaserc.json +14 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +433 -0
- package/index.ts +531 -0
- package/package.json +73 -0
- package/scripts/verify-package-files.mjs +41 -0
- package/skills/subagents-configuration/SKILL.md +182 -0
- package/src/config.ts +262 -0
- package/src/debug.ts +38 -0
- package/src/history.ts +254 -0
- package/src/interaction-channel.ts +197 -0
- package/src/manager.ts +533 -0
- package/src/model-profiles-ui.ts +609 -0
- package/src/profile-resolver.ts +60 -0
- package/src/runner.ts +688 -0
- package/src/thread-view.ts +477 -0
- package/src/tools.ts +492 -0
- package/src/types.ts +234 -0
- package/src/ui.ts +399 -0
package/.releaserc.json
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-06-27
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Initial Pi package for markdown-defined subagents, delegated task tools, session history, model profiles, and background handoff UX.
|
|
7
|
+
- GitHub Actions CI and Semantic Release publishing workflow for npm release automation.
|
|
8
|
+
- Package verification script to ensure published package resources are complete.
|
|
9
|
+
|
|
10
|
+
### Improved
|
|
11
|
+
- Background subagent completions notify automatically, stay collapsed by default, expand with `ctrl+o`, and keep the chat available while tasks run.
|
|
12
|
+
- Subagent result and task-mode output keep full responses available to the orchestrator while rendering compactly for users.
|
|
13
|
+
- Subagent task lists default to current-session collapsed summaries.
|
|
14
|
+
- Subagent detail views reuse Pi runtime tool renderers for tools executed inside subagent sessions.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Default detail cancel shortcut is `x` for reliable terminal cancellation.
|
|
18
|
+
- Peer dependencies use wildcard ranges for Pi package compatibility while dev dependencies remain pinned.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 j0k3r
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
# Pi Subagents Extension
|
|
2
|
+
|
|
3
|
+
Pi extension for delegating work to markdown-defined subagents. It registers tools for the orchestrator, runs subagents in isolated in-memory Pi sessions, tracks task history, provides a TUI history panel, and supports per-subagent model/thinking-effort profiles.
|
|
4
|
+
|
|
5
|
+
## What it provides
|
|
6
|
+
|
|
7
|
+
- Markdown-defined subagents loaded from global and project directories.
|
|
8
|
+
- `subagent_run` for task-mode or background delegation to one or many agents.
|
|
9
|
+
- Status/result/list/cancel tools for delegated tasks.
|
|
10
|
+
- Isolated in-memory agent sessions for each subagent run.
|
|
11
|
+
- Subagent markdown used as system prompt, with delegated task/context as the user prompt.
|
|
12
|
+
- Project-scoped task history in a global SQLite data/cache location.
|
|
13
|
+
- TUI history panel via `/subagents` or `ctrl+,`.
|
|
14
|
+
- Claude-mode background handoff via `ctrl+h` by default, configurable in `subagents.json`.
|
|
15
|
+
- TUI execution rendering can expand/collapse tool and rendered component output with `ctrl+o`.
|
|
16
|
+
- Model profile UI via `/subagent-models`.
|
|
17
|
+
- Per-agent/default model and thinking-effort configuration.
|
|
18
|
+
- Tool allowlist filtering that prevents subagents from delegating to other subagents.
|
|
19
|
+
- Generic subagent-to-parent interaction handoff so human decisions happen on the main thread.
|
|
20
|
+
|
|
21
|
+
## Install as a Pi package
|
|
22
|
+
|
|
23
|
+
This repository is an installable Pi package named `pi-subagents-j0k3r`.
|
|
24
|
+
|
|
25
|
+
Install from npm after publishing:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pi install npm:pi-subagents-j0k3r
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Install from a Git repository or tag:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pi install git:https://github.com/<owner>/pi-subagents-j0k3r@<tag-or-commit>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Try a local checkout without installing it permanently:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pi -e ./path/to/pi-subagents-j0k3r
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Install for one project instead of globally with `-l`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pi install -l npm:pi-subagents-j0k3r
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The package manifest exposes:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"pi": {
|
|
54
|
+
"extensions": ["./index.ts"],
|
|
55
|
+
"skills": ["./skills"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The npm metadata includes the `pi-package` keyword required for Pi package gallery discovery. After publishing the npm package, it is eligible to appear on the Pi package page.
|
|
61
|
+
|
|
62
|
+
Use `/reload` after changing extension code, skill files, config, or markdown subagent definitions during an interactive session.
|
|
63
|
+
|
|
64
|
+
## Subagent definitions
|
|
65
|
+
|
|
66
|
+
Subagents are markdown files with optional YAML-like frontmatter.
|
|
67
|
+
|
|
68
|
+
Load order:
|
|
69
|
+
|
|
70
|
+
1. Global user subagents from `$PI_CODING_AGENT_DIR/subagents/*.md`.
|
|
71
|
+
2. Project subagents from `.pi/subagents/*.md`.
|
|
72
|
+
|
|
73
|
+
Project definitions override global definitions with the same normalized name.
|
|
74
|
+
|
|
75
|
+
Default global agent directory:
|
|
76
|
+
|
|
77
|
+
```txt
|
|
78
|
+
~/.pi/agent
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Override with:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
PI_CODING_AGENT_DIR=/path/to/pi-agent-dir
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Definition format
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
|
|
91
|
+
```md
|
|
92
|
+
---
|
|
93
|
+
name: discovery
|
|
94
|
+
description: investigates isolated ideas, code, documentation, and context7 before deciding whether to start prd/sdd
|
|
95
|
+
tools:
|
|
96
|
+
- read
|
|
97
|
+
- bash
|
|
98
|
+
- context7_status
|
|
99
|
+
- context7_search_library
|
|
100
|
+
model: anthropic/claude-sonnet-4-5
|
|
101
|
+
effort: low
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
# Discovery Subagent
|
|
105
|
+
|
|
106
|
+
You are an isolated research executor...
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Supported frontmatter:
|
|
110
|
+
|
|
111
|
+
| Field | Description |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `name` | Subagent name. Defaults to filename stem. Normalized to lowercase. |
|
|
114
|
+
| `description` | Short description shown by `subagent_list_agents`. |
|
|
115
|
+
| `tools` | Tool allowlist for the subagent. When omitted, the definition gets the built-in default tool list. Configured `default_tools` is used by the runner when a definition has an empty tool list. |
|
|
116
|
+
| `model` | Optional model as `provider/model-id`. |
|
|
117
|
+
| `effort`, `thinking_level`, `thinkingLevel` | Optional thinking effort: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`. |
|
|
118
|
+
|
|
119
|
+
The markdown body becomes the subagent instructions.
|
|
120
|
+
|
|
121
|
+
## Project and global config
|
|
122
|
+
|
|
123
|
+
Config files:
|
|
124
|
+
|
|
125
|
+
```txt
|
|
126
|
+
~/.pi/agent/subagents.json # global
|
|
127
|
+
.pi/subagents.json # project
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Config resolves as a cascade: project `.pi/subagents.json` overrides global `~/.pi/agent/subagents.json`; missing project fields fall back to global config; fields missing from both fall back to built-in defaults. Model profiles are merged by normalized lowercase agent name, with project profile fields overriding global profile fields.
|
|
131
|
+
|
|
132
|
+
Example:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"default_model": "anthropic/claude-sonnet-4-5",
|
|
137
|
+
"default_effort": "medium",
|
|
138
|
+
"timeout_ms": 600000,
|
|
139
|
+
"stall_timeout_ms": 120000,
|
|
140
|
+
"max_concurrency": 5,
|
|
141
|
+
"session_resources": "lean",
|
|
142
|
+
"history_panel_shortcut": "ctrl+,",
|
|
143
|
+
"detail_cancel_shortcut": "x",
|
|
144
|
+
"background_handoff_shortcut": "ctrl+h",
|
|
145
|
+
"default_tools": [
|
|
146
|
+
"read",
|
|
147
|
+
"memory_context",
|
|
148
|
+
"memory_search",
|
|
149
|
+
"memory_recall",
|
|
150
|
+
"memory_get"
|
|
151
|
+
],
|
|
152
|
+
"model_profiles": {
|
|
153
|
+
"discovery": {
|
|
154
|
+
"model": "anthropic/claude-haiku-4-5",
|
|
155
|
+
"effort": "low"
|
|
156
|
+
},
|
|
157
|
+
"sdd-apply": {
|
|
158
|
+
"model": "anthropic/claude-sonnet-4-5",
|
|
159
|
+
"effort": "medium"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Config fields
|
|
166
|
+
|
|
167
|
+
| Field | Default | Description |
|
|
168
|
+
|---|---:|---|
|
|
169
|
+
| `default_model` | current orchestrator model | Fallback model for all subagents. Format: `provider/model-id`. |
|
|
170
|
+
| `default_effort` | current orchestrator effort | Fallback thinking effort. Also accepts `default_thinking_level` or `thinkingLevel`. |
|
|
171
|
+
| `model_profiles` | `{}` | Per-agent model/effort overrides. |
|
|
172
|
+
| `timeout_ms` | `600000` | Total timeout per subagent task. |
|
|
173
|
+
| `stall_timeout_ms` | `120000` | Inactivity timeout for a subagent session. |
|
|
174
|
+
| `max_concurrency` | `5` | Max concurrent subagent tasks per cwd/config pair. |
|
|
175
|
+
| `session_resources` | `lean` | SDK resource loading mode. `lean` uses the subagent markdown body as the nested session system prompt, skips skills, prompt templates, themes, and context files, and loads extensions in tools-only/safety-hook mode so allowlisted extension tools remain available without startup context injection. Use explicit `full` only when a subagent intentionally needs the full Pi resource set. Also accepts camelCase `sessionResources`. |
|
|
176
|
+
| `history_panel_shortcut` | `ctrl+,` | OpenCode-mode shortcut used to open the subagents history/detail panel. Accepts `ctrl+<letter>` or `ctrl+,` and also accepts camelCase `historyPanelShortcut`. |
|
|
177
|
+
| `detail_cancel_shortcut` | `x` | Shortcut for the subagents history/detail panel to cancel only the currently selected queued/running subagent. `ctrl+...` values are also registered as a Pi shortcut scoped by the active panel, so they still work when the TUI captures control keys; single-letter values are handled by the panel input. Accepts `ctrl+<letter>`, `ctrl+shift+<letter>`, `ctrl+,`, or one lowercase letter, and also accepts camelCase `detailCancelShortcut`. It is ignored when the panel is not active or the selected subagent is already finished. |
|
|
178
|
+
| `background_handoff_shortcut` | `ctrl+h` | Claude-mode shortcut used to send a running task to the background. Accepts `ctrl+<letter>` and also accepts camelCase `backgroundHandoffShortcut`. |
|
|
179
|
+
| `default_tools` | see below | Fallback tool allowlist used by the runner when an agent definition has an empty tool list. Omitted frontmatter `tools` uses the built-in default list. |
|
|
180
|
+
|
|
181
|
+
Default tools:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
["read", "memory_context", "memory_search", "memory_recall", "memory_get"]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Subagent delegation tools are always blocked from subagent tool allowlists, even if listed:
|
|
188
|
+
|
|
189
|
+
```txt
|
|
190
|
+
subagent_run
|
|
191
|
+
subagent_list_agents
|
|
192
|
+
subagent_status
|
|
193
|
+
subagent_result
|
|
194
|
+
subagent_list_tasks
|
|
195
|
+
subagent_cancel
|
|
196
|
+
any tool starting with subagent_
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Model profile resolution
|
|
200
|
+
|
|
201
|
+
Effective model resolution order:
|
|
202
|
+
|
|
203
|
+
1. `model_profiles[agent].model`
|
|
204
|
+
2. subagent frontmatter `model`
|
|
205
|
+
3. `default_model`
|
|
206
|
+
4. current orchestrator model
|
|
207
|
+
5. unresolved
|
|
208
|
+
|
|
209
|
+
Effective effort resolution order:
|
|
210
|
+
|
|
211
|
+
1. `model_profiles[agent].effort`
|
|
212
|
+
2. subagent frontmatter `effort` / `thinking_level` / `thinkingLevel`
|
|
213
|
+
3. `default_effort`
|
|
214
|
+
4. current orchestrator thinking level
|
|
215
|
+
5. unresolved
|
|
216
|
+
|
|
217
|
+
If a configured model cannot be resolved, the runner reports an error. If a selected model fails or stalls and the current orchestrator model is different, the runner falls back to the current model.
|
|
218
|
+
|
|
219
|
+
## Debug and interaction bridge logs
|
|
220
|
+
|
|
221
|
+
Debug logging is disabled by default. Enable it in global or project `subagents.json`:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"debug": true
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
When enabled, subagents write local debug/audit breadcrumbs to the executing project's `.pi` directory:
|
|
230
|
+
|
|
231
|
+
```txt
|
|
232
|
+
.pi/subagents-debug.log
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The log is intended for runtime debugging of delegated sessions and generic interaction handoff issues. Interaction bridge entries include safe metadata such as task id, agent name, request id, kind, requester, prompt presence, and payload presence. They intentionally avoid storing raw private data beyond the bounded task/history surfaces already captured for debugging.
|
|
236
|
+
|
|
237
|
+
Useful event names:
|
|
238
|
+
|
|
239
|
+
- `runner_event` — compact SDK event shape observed by the subagent runner.
|
|
240
|
+
- `interaction_bridge_payload_detected` — runner found a structured interaction request.
|
|
241
|
+
- `interaction_bridge_payload_recovered_from_channel` — runner recovered a request from the shared interaction channel.
|
|
242
|
+
- `interaction_bridge_request_detected` — manager received an interaction request from the runner.
|
|
243
|
+
- `interaction_bridge_prompt_main_thread` — manager is prompting the main user.
|
|
244
|
+
- `interaction_bridge_user_response` — main user response was published for the subagent to consume.
|
|
245
|
+
|
|
246
|
+
## Tools exposed to the orchestrator
|
|
247
|
+
|
|
248
|
+
| Tool | Purpose |
|
|
249
|
+
|---|---|
|
|
250
|
+
| `subagent_list_agents` | List loaded markdown-defined subagents. |
|
|
251
|
+
| `subagent_run` | Delegate a task to one or more subagents. Supports `task` and `background` mode. |
|
|
252
|
+
| `subagent_status` | Get status for a delegated task. |
|
|
253
|
+
| `subagent_result` | Read the result for a delegated task. |
|
|
254
|
+
| `subagent_list_tasks` | List active and persisted delegated tasks for the current cwd. |
|
|
255
|
+
| `subagent_cancel` | Cancel a running delegated task. |
|
|
256
|
+
|
|
257
|
+
Only the main orchestrator should call these tools. Subagents are explicitly prevented from calling `subagent_*` tools.
|
|
258
|
+
|
|
259
|
+
### `subagent_run`
|
|
260
|
+
|
|
261
|
+
Parameters:
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
{
|
|
265
|
+
agent?: string;
|
|
266
|
+
agents?: string[];
|
|
267
|
+
task: string;
|
|
268
|
+
context?: string;
|
|
269
|
+
mode?: "task" | "background";
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Behavior:
|
|
274
|
+
|
|
275
|
+
- `mode: "task"` waits for completion and returns compact task summaries.
|
|
276
|
+
- `mode: "background"` returns task IDs immediately; use status/result tools later.
|
|
277
|
+
- Multiple agents can run from one request with `agents`.
|
|
278
|
+
- Double Escape during task-mode execution cancels running subagents and aborts the main turn.
|
|
279
|
+
|
|
280
|
+
## Commands and shortcut
|
|
281
|
+
|
|
282
|
+
| Entry point | Description |
|
|
283
|
+
|---|---|
|
|
284
|
+
| `/subagents` | Open the session-focused TUI subagent history panel. |
|
|
285
|
+
| `/subagent-models` | Configure global subagent and SDD phase model profiles. |
|
|
286
|
+
| `ctrl+,` | Open the TUI subagent history panel in OpenCode mode by default. Configurable via `history_panel_shortcut` in `subagents.json`. |
|
|
287
|
+
| `x` | Cancel the currently selected queued/running subagent from the open history/detail panel by default. Configurable via `detail_cancel_shortcut` in `subagents.json`. |
|
|
288
|
+
| `ctrl+h` | Send the running Claude-mode subagent task to the background by default. Configurable via `background_handoff_shortcut` in `subagents.json`. |
|
|
289
|
+
|
|
290
|
+
`/subagent-models` writes global profile changes to:
|
|
291
|
+
|
|
292
|
+
```txt
|
|
293
|
+
~/.pi/agent/subagents.json
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
or `$PI_CODING_AGENT_DIR/subagents.json` when `PI_CODING_AGENT_DIR` is set.
|
|
297
|
+
|
|
298
|
+
In non-TUI environments, edit `model_profiles` manually in that JSON file.
|
|
299
|
+
|
|
300
|
+
## Task history
|
|
301
|
+
|
|
302
|
+
Task history is stored in a global data/cache location, while each row remains scoped by project `cwd`:
|
|
303
|
+
|
|
304
|
+
```txt
|
|
305
|
+
$XDG_DATA_HOME/pi/subagents/subagents-history.sqlite
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Fallback:
|
|
309
|
+
|
|
310
|
+
```txt
|
|
311
|
+
~/.local/share/pi/subagents/subagents-history.sqlite
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Environment overrides:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
PI_SUBAGENTS_HISTORY_DB_PATH=/absolute/path/to/subagents-history.sqlite
|
|
318
|
+
PI_SUBAGENTS_HISTORY_HOME=/absolute/path/to/subagents-history-home
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The history DB stores:
|
|
322
|
+
|
|
323
|
+
- task metadata;
|
|
324
|
+
- status and timestamps;
|
|
325
|
+
- model/effort used;
|
|
326
|
+
- usage stats when available;
|
|
327
|
+
- result/error/output preview;
|
|
328
|
+
- delegated user prompt and subagent system prompt separately;
|
|
329
|
+
- compact thread snapshots;
|
|
330
|
+
- task events.
|
|
331
|
+
|
|
332
|
+
When `debug: true` is configured, the extension also may write debug diagnostics to:
|
|
333
|
+
|
|
334
|
+
```txt
|
|
335
|
+
.pi/subagents-debug.log
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
History and debug logging are best-effort: failures to persist them should not break delegation.
|
|
339
|
+
|
|
340
|
+
## Generic interaction handling
|
|
341
|
+
|
|
342
|
+
Subagents run in isolated sessions, but any human interaction must happen on the main thread. The extension uses one generic protocol for all such cases.
|
|
343
|
+
|
|
344
|
+
A subagent-side tool or extension can publish or return an interaction request:
|
|
345
|
+
|
|
346
|
+
```json
|
|
347
|
+
{
|
|
348
|
+
"type": "interaction_required",
|
|
349
|
+
"requestId": "req-123",
|
|
350
|
+
"kind": "operator-decision",
|
|
351
|
+
"origin": "subagent",
|
|
352
|
+
"requester": { "subagentName": "analyst", "taskId": "subtask_..." },
|
|
353
|
+
"prompt": {
|
|
354
|
+
"title": "Choose strategy",
|
|
355
|
+
"message": "How should the subagent continue?",
|
|
356
|
+
"choices": ["safe", "fast"]
|
|
357
|
+
},
|
|
358
|
+
"payload": { "any": "structured data needed to answer" },
|
|
359
|
+
"response": { "expected": "choice" }
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
The parent manager surfaces the request to the main thread, collects a response with `select`, `confirm`, `input`, or `editor`, publishes:
|
|
364
|
+
|
|
365
|
+
```json
|
|
366
|
+
{
|
|
367
|
+
"type": "interaction_response",
|
|
368
|
+
"requestId": "req-123",
|
|
369
|
+
"status": "answered",
|
|
370
|
+
"value": "safe"
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Then the subagent is retried so the subagent-side tool/extension can consume the response and continue. For unknown or rich interaction kinds, the parent falls back to an editor with the request payload so the user can return arbitrary text or JSON.
|
|
375
|
+
|
|
376
|
+
Background subagent tasks cannot request interactive main-thread handling. Rerun in `task` mode if human interaction is needed.
|
|
377
|
+
|
|
378
|
+
## Prompt and memory behavior
|
|
379
|
+
|
|
380
|
+
In the default `lean` mode, the runner treats the subagent markdown body as the nested session system prompt. The delegated user prompt contains only the orchestrator-provided context and task. The runner does not inject `AGENTS.md`, workflow skills, memory startup context, or generated memory constraints into the delegated user prompt.
|
|
381
|
+
|
|
382
|
+
Extensions are loaded in an isolated tools-only/safety-hook mode for subagents: allowlisted extension tools remain available, while context/prompt lifecycle hooks such as `before_agent_start` and `context` are removed so extensions cannot add hidden startup messages. Tool-safety hooks (`tool_call`, `tool_result`, and `user_bash`) are preserved for runtime guards and interaction handoff.
|
|
383
|
+
|
|
384
|
+
Memory behavior should be specified in each subagent markdown definition. A subagent can use memory only when its tool allowlist includes the relevant memory tools. SDD/PRD phase agents use deterministic `memory_search`/`memory_get` plus `memory_add`/`memory_update` for active-flow state; they intentionally do not receive `memory_context` or `memory_recall`.
|
|
385
|
+
|
|
386
|
+
Context7 access is limited to `discovery`, `tool-smoke`, and `sdd-explore`; downstream SDD phase agents should consume curated evidence from artifacts or orchestrator context instead of performing broad external-doc discovery.
|
|
387
|
+
|
|
388
|
+
## Bundled resources
|
|
389
|
+
|
|
390
|
+
This package bundles:
|
|
391
|
+
|
|
392
|
+
- `index.ts` and `src/**` — the Pi extension runtime.
|
|
393
|
+
- `skills/subagents-configuration/SKILL.md` — configuration guidance for agents that need to create or edit subagent definitions.
|
|
394
|
+
|
|
395
|
+
Subagent definitions are intentionally user/project configuration, not hard-coded package behavior. Add them globally in `$PI_CODING_AGENT_DIR/subagents/*.md` or project-locally in `.pi/subagents/*.md`.
|
|
396
|
+
|
|
397
|
+
## Development
|
|
398
|
+
|
|
399
|
+
Install dependencies once:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
npm install
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Run tests:
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
npm test
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Run typecheck:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
npm run typecheck
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Verify the npm package contents:
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
npm run pack:dry-run
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Run the full local check:
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
npm run check
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Related project docs
|
|
430
|
+
|
|
431
|
+
- `README.md` — package usage, configuration, and development notes.
|
|
432
|
+
- `skills/subagents-configuration/SKILL.md` — subagent configuration policy.
|
|
433
|
+
- Pi package docs — `docs/packages.md` in the Pi coding-agent distribution.
|