@d3ara1n/pi-subagent 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,8 +32,8 @@ This means:
32
32
 
33
33
  | Role | Model Role | Timeout | Tools | Can Delegate To | Description |
34
34
  |------|-----------|---------|-------|-----------------|-------------|
35
- | `explorer` | fast | 900s | read, find, grep | — | Fast code search (read-only, no bash) |
36
- | `reviewer` | heavy | 3600s | read, bash, grep, find | — | Deep code review (read-only, bash for git/log) |
35
+ | `explorer` | fast | 900s | read, find, grep | — | Fast code exploration (read-only) |
36
+ | `reviewer` | heavy | 3600s | read, bash, grep, find | — | Deep code review, runs git/tests for evidence (read-only) |
37
37
  | `worker` | default | 2400s | all (no whitelist) | explorer, researcher | Implementation — the only role that can modify files; full tool access (web, MCP, everything) |
38
38
  | `researcher` | fast | 2400s | web_search, fetch_content, source_check, get_search_content, read, bash, edit, write, delegate | explorer | Web research + GitHub repo analysis; writes artifacts only inside its temp dir |
39
39
 
@@ -126,7 +126,7 @@ Override, disable, or add subagent roles via `agentOverrides`. Built-in and cust
126
126
  },
127
127
  "tester": {
128
128
  "role": "default",
129
- "description": "Test automation & QA — write and run tests, validate fixes. Tools: read, bash, edit, write, grep. Can delegate to explorer.",
129
+ "description": "Test automation & QA — write and run tests, validate fixes. Can delegate to explorer.",
130
130
  "examples": [
131
131
  "Write unit tests for the auth module",
132
132
  "Run the test suite and fix failing tests"
@@ -177,7 +177,11 @@ Delegate tasks that would generate many tool calls or verbose output to keep you
177
177
 
178
178
  ## Background Delegation
179
179
 
180
- Foreground and background delegation share one async run engine — foreground is simply background-but-blocking. With `background: true`, `subagent_delegate` returns immediately with a run id, and two companion tools collect the outcome:
180
+ Three execution properties, kept separate:
181
+
182
+ - **Foreground** (default): the call blocks until the run finishes and returns the final output directly. (Under the hood foreground and background share one async run engine — foreground is simply background-but-blocking.)
183
+ - **Parallel**: multiple `subagent_delegate` calls in one turn run concurrently — foreground and background alike, no special flag.
184
+ - **Background** (`background: true`): non-blocking — `subagent_delegate` returns immediately with a run id. Use it when you have your own work to do (or a discussion with the user to continue) while the run executes; two companion tools collect the outcome:
181
185
 
182
186
  | Tool | Purpose | Returns to the model |
183
187
  |------|---------|---------------------|
@@ -204,6 +208,7 @@ Typical flow:
204
208
 
205
209
  Semantics worth knowing:
206
210
 
211
+ - **Results are pull-only.** Nothing delivers them to the model — no completion event, no notification, nothing wakes the model up. The model owns the collection point: `subagent_wait`, then `subagent_check` each run. The inbox reminder (below) lists unclaimed runs on every request, but it never pushes results.
207
212
  - **Background runs survive turn cancellation** and are unaffected by a cancelled `subagent_wait` — cancelling the wait never cancels the runs; call `subagent_wait` or `subagent_check` again later.
208
213
  - **Read-once collection:** `subagent_check` on a terminal run returns the result and frees it — the output now lives in the conversation history, and only a lightweight tombstone stays in the registry (`/subagent:status` lists it under "Collected"). Re-checking a collected id explains that its result is already in the history.
209
214
  - **Inbox reminder:** every LLM call carries a `[background subagent runs]` system reminder listing the unclaimed runs (queued, running, and finished-but-unchecked alike), injected at a cache-stable head position. Runs missing from the list were already collected — so a finished run the model forgot to check keeps surfacing until it does.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3ara1n/pi-subagent",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "description": "Role-based subagent orchestration for pi — delegates tasks to specialized pi child processes with configurable model roles",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -149,13 +149,16 @@ export default function subagentExtension(pi: ExtensionAPI) {
149
149
  "",
150
150
  ...exampleLines,
151
151
  "",
152
- "For multiple independent substantial tasks, emit multiple subagent_delegate calls in one turn — they run in parallel.",
152
+ "EXECUTION MODES:",
153
153
  "",
154
- "BACKGROUND DELEGATION start runs now, collect results later:",
154
+ "- Foreground (default): the call blocks until the run finishes and returns the final output directly.",
155
+ "- Parallel: multiple subagent_delegate calls at the same time run concurrently — foreground and background alike, no special flag.",
156
+ "- Background (background: true): non-blocking — returns an id immediately so you can do your own work while the run executes.",
155
157
  "",
156
- "- Typical flow: subagent_delegate(background: true) ×N → keep working → subagent_wait(ids) to block until every listed run finishes (omit ids to wait for all) → subagent_check(id) for each finished run.",
157
- "- A terminal check collects the run — the output is returned once and the run leaves the registry. Mid-run checks are free: peek at progress as often as you like; only terminal checks collect.",
158
- "- Every LLM call carries a [background subagent runs] reminder listing your unclaimed runs (queued, running, and finished-but-unchecked alike). Runs missing from that list were already collected.",
158
+ "BACKGROUND DELEGATION:",
159
+ "",
160
+ "- Use it only when you have your own work this turn (including an ongoing discussion with the user) while the run executes; otherwise let the call block and return the result directly.",
161
+ "- Results are pull-only — no completion event, no notification, nothing wakes you. Dispatching means owning the collection point: finish your own work, then subagent_check(id) for each result. Use subagent_wait(ids) to block until the run finish.",
159
162
  "- Background delegation works only in the top-level session.",
160
163
  );
161
164
  }
@@ -267,7 +270,7 @@ export default function subagentExtension(pi: ExtensionAPI) {
267
270
  background: Type.Optional(
268
271
  Type.Boolean({
269
272
  description:
270
- "Run asynchronously: returns an id (sub-N) immediately instead of blocking. The run survives turn cancellation.",
273
+ "Non-blocking: returns an id immediately so you can do your own work (or keep discussing with the user) while the run executes — not for parallelism (several foreground calls in one turn already run concurrently). Results are pull-only: nothing delivers them to you or wakes you; fetch with subagent_wait/subagent_check when your own work is done. If the next thing you'd do is wait for the result, omit this and let the call block.",
271
274
  }),
272
275
  ),
273
276
  cwd: Type.Optional(Type.String({ description: "Working directory (defaults to current)" })),
@@ -111,9 +111,9 @@ describe("buildInboxReminder", () => {
111
111
  assert.ok(text.includes(`"${"x".repeat(70)}..."`));
112
112
  });
113
113
 
114
- test("header explains collection semantics", () => {
114
+ test("header explains pull-only collection semantics", () => {
115
115
  const text = buildInboxReminder([entry({ id: "sub-1", state: "running" })])!;
116
- assert.match(text, /^\[background subagent runs — subagent_check claims/);
116
+ assert.match(text, /^\[background subagent runs — results are pull-only/);
117
117
  assert.match(text, /already collected\]/);
118
118
  });
119
119
  });
package/src/reminder.ts CHANGED
@@ -28,7 +28,7 @@ export interface InboxEntry {
28
28
  }
29
29
 
30
30
  const INBOX_HEADER =
31
- "[background subagent runs — subagent_check claims a terminal run's output and removes it from this list; runs missing here were already collected]";
31
+ "[background subagent runs — results are pull-only: nothing notifies you. subagent_wait, then subagent_check to collect each run; a terminal check removes it from this list; runs missing here were already collected]";
32
32
 
33
33
  /** `42s`, `3m12s`, `4m` — whole seconds, no live clocks. */
34
34
  function formatDuration(totalSec: number): string {
package/src/roles.ts CHANGED
@@ -15,18 +15,18 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
15
15
  fallbackRole: "default",
16
16
  timeout: 900,
17
17
  description:
18
- "READ-ONLY codebase exploration — locate files, grep symbols, trace imports, explain structures. Tools: read, find, grep. NO bash, NO edits, NO web access.",
18
+ "READ-ONLY codebase exploration — locate files, grep symbols, trace imports, explain structures.",
19
19
  examples: ["Find where auth middleware is implemented", "Map the routing structure"],
20
20
  decisionTrigger: "Task finds or maps code without touch?",
21
21
  tools: ["read", "find", "grep"],
22
22
  systemPrompt: [
23
- "Fast code explorer. You have READ-ONLY tools only no commands, no edits.",
24
- "Grep/find to locate → read key sections only → identify types, interfaces, functions.",
25
- "Never read entire files. Target specific line ranges.",
23
+ "Code explorer. READ-ONLY locate code, understand it, and report findings; never modify anything.",
24
+ "Search to locate → read the files relevant to the task trace imports, identify types, interfaces, functions.",
25
+ "Skip noise: lockfiles, vendored, minified, and generated files.",
26
26
  "",
27
- "Output format (keep each section brief):",
27
+ "Output format:",
28
28
  "## Files: file paths with line ranges and one-line descriptions",
29
- "## Findings: key types/functions with minimal code snippets",
29
+ "## Findings: key types/functions with short code snippets",
30
30
  "## Summary: direct answer to the task question",
31
31
  ].join("\n"),
32
32
  },
@@ -35,7 +35,7 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
35
35
  fallbackRole: "default",
36
36
  timeout: 3600,
37
37
  description:
38
- "READ-ONLY code review & analysis — audit code, assess architecture, review diffs. Tools: read, bash, grep, find. Has bash (git diff/log, test runs). NO edits, NO web access.",
38
+ "READ-ONLY code review & analysis — audit code, assess architecture, review diffs, run tests for evidence.",
39
39
  examples: [
40
40
  "Review the error handling in src/api/ for security issues",
41
41
  "Audit this PR diff for performance regressions",
@@ -44,7 +44,7 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
44
44
  tools: ["read", "bash", "grep", "find"],
45
45
  systemPrompt: [
46
46
  "Senior code reviewer. READ-ONLY — you must NOT modify any file.",
47
- "bash is for read-only commands only (git diff/log/show, test runs). Never use sed, tee, echo >, or any write command.",
47
+ "Run only read-only commands (git diff/log/show, test runs). Never use sed, tee, echo >, or any write command.",
48
48
  "Provide evidence-backed findings with file:line references.",
49
49
  "",
50
50
  "Output format (prioritize critical issues first):",
@@ -67,8 +67,8 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
67
67
  "After each change, validate: run tests, check syntax, verify behavior.",
68
68
  "",
69
69
  "## Protecting your context",
70
- "You have full tool access (web_search, fetch_content, MCP, ...) plus a `subagent_delegate` tool.",
71
- "Use direct tools for quick lookups — e.g. check library docs/APIs with web_search or context7 before writing third-party code.",
70
+ "You have full tool access plus a `subagent_delegate` tool.",
71
+ "Use direct tools for quick lookups — e.g. search the web for library docs/APIs before writing third-party code.",
72
72
  "Delegate only when the work is substantial:",
73
73
  "- subagent_delegate(role=explorer) when you need to map unfamiliar code before editing",
74
74
  "- subagent_delegate(role=researcher) when the research itself is a multi-step investigation",