@d3ara1n/pi-subagent 1.1.1 → 1.2.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
@@ -34,8 +34,10 @@ This means:
34
34
  |------|-----------|---------|-------|-----------------|-------------|
35
35
  | `explorer` | fast | 900s | read, find, grep | — | Fast code search (read-only, no bash) |
36
36
  | `reviewer` | heavy | 3600s | read, bash, grep, find | — | Deep code review (read-only, bash for git/log) |
37
- | `worker` | default | 2400s | read, bash, edit, write, grep, find, delegate | explorer, researcher | Implementation — the only role that can modify files |
38
- | `researcher` | fast | 2400s | web_search, fetch_content, read, bash, delegate | explorer | Web research + GitHub repo analysis |
37
+ | `worker` | default | 2400s | all (no whitelist) | explorer, researcher | Implementation — the only role that can modify files; full tool access (web, MCP, everything) |
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
+
40
+ **Web tool naming**: `researcher`'s web tools use the community-standard names (`web_search`, `fetch_content`, `source_check`, `get_search_content`) shared by the most popular Pi web extensions — [pi-web-access](https://github.com/nicobailon/pi-web-access), `pi-web-tools`, `pi-browse`, and others. Install any of those and the researcher gets web access out of the box. If your web extension uses different tool names (e.g. `websearch`/`webfetch`) or you renamed the tools via a `toolNames` config, override `researcher.tools` in `agentOverrides` to match.
39
41
 
40
42
  **Nested delegation**: `worker` and `researcher` can spawn their own subagents. This keeps the main model's context clean — a worker can explore unfamiliar code via an `explorer` subagent without returning intermediate results to the main model.
41
43
 
@@ -138,7 +140,7 @@ Override, disable, or add subagent roles via `agentOverrides`. Built-in and cust
138
140
  }
139
141
  ```
140
142
 
141
- **Required fields for custom roles:** `role`, `description`, `examples`, `decisionTrigger`, `tools`, `systemPrompt`.
143
+ **Required fields for custom roles:** `role`, `description`, `examples`, `decisionTrigger`, `systemPrompt`. `tools` is optional — absent means all tools, a list restricts to those exact tool names.
142
144
 
143
145
  **Optional fields:** `subagentRoles` (roles this role can spawn via delegate), `timeout` (per-role active-time timeout in seconds; unset or `0` is unlimited, negative values normalize to `0`), `maxTurns` / `maxCost` (per-role budget overrides; unset uses the top-level `maxTurns` / `maxCost` setting, `0` is unlimited, negative values normalize to `0`), `fallbackRole` (backup pi-model-roles role the whole run is retried on after a provider error; unset means no retry — see [Fallback observability](#fallback-observability)).
144
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3ara1n/pi-subagent",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
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
@@ -188,12 +188,12 @@ export default function subagentExtension(pi: ExtensionAPI) {
188
188
  applyAgentOverrides(availableRoles, config.agentOverrides);
189
189
 
190
190
  // Validate custom roles (skip built-in roles — they already have all fields)
191
+ // `tools` is optional — absent means the role gets all tools.
191
192
  const REQUIRED_FIELDS = [
192
193
  "role",
193
194
  "description",
194
195
  "examples",
195
196
  "decisionTrigger",
196
- "tools",
197
197
  "systemPrompt",
198
198
  ] as const;
199
199
  for (const [name, role] of Object.entries(availableRoles)) {
package/src/roles.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * Built-in subagent role definitions.
3
3
  *
4
4
  * Each maps to a pi-model-roles role and has a tailored system prompt
5
- * and tool set. Prompts are in English concise, efficient, task-focused.
5
+ * and tool policy (an explicit allowlist, or all tools when unset).
6
+ * Prompts are in English — concise, efficient, task-focused.
6
7
  * Final output should be accurate and concise, stating conclusions directly.
7
8
  */
8
9
 
@@ -56,10 +57,9 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
56
57
  role: "default",
57
58
  timeout: 2400,
58
59
  description:
59
- "the ONLY role that can MODIFY files edit, write, refactor, fix, implement. Tools: read, bash, edit, write, grep, find, subagent_delegate. Can delegate to explorer/researcher.",
60
+ "Full tool access — the ONLY role that can MODIFY files (edit, write, refactor, fix, implement). Can delegate to explorer/researcher.",
60
61
  examples: ["Rename all snake_case fields to camelCase", "Add input validation to POST /login"],
61
62
  decisionTrigger: "Task modifies files?",
62
- tools: ["read", "bash", "edit", "write", "grep", "find", "subagent_delegate"],
63
63
  subagentRoles: ["explorer", "researcher"],
64
64
  systemPrompt: [
65
65
  "Implementation worker. Work autonomously — all context is in the task description.",
@@ -67,10 +67,12 @@ 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 a `subagent_delegate` tool. Use it to offload exploration and research:",
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.",
72
+ "Delegate only when the work is substantial:",
71
73
  "- subagent_delegate(role=explorer) when you need to map unfamiliar code before editing",
72
- "- subagent_delegate(role=researcher) when you need external docs or library references",
73
- "Don't delegate tasks you can do with a single read or grep.",
74
+ "- subagent_delegate(role=researcher) when the research itself is a multi-step investigation",
75
+ "Don't delegate tasks you can do with a single read, grep, or web search.",
74
76
  "",
75
77
  "Output format (be brief — summarize, don't paste full diffs):",
76
78
  "## Changes: list each file touched and what changed",
@@ -82,23 +84,35 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
82
84
  fallbackRole: "default",
83
85
  timeout: 2400,
84
86
  description:
85
- "the ONLY role with WEB ACCESS — search docs, fetch pages, analyze GitHub repos. Tools: web_search, fetch_content, read, bash, subagent_delegate. Can clone repos & delegate to explorer.",
87
+ "the ONLY role with WEB ACCESS — search docs, fetch pages, verify claims, analyze GitHub repos. Can clone repos & delegate to explorer.",
86
88
  examples: ["Find the React 19 migration guide", "Check GitHub issue #1234 for context"],
87
89
  decisionTrigger: "Task searches web or GitHub?",
88
- tools: ["web_search", "fetch_content", "read", "bash", "subagent_delegate"],
90
+ tools: [
91
+ "web_search",
92
+ "fetch_content",
93
+ "source_check",
94
+ "get_search_content",
95
+ "read",
96
+ "bash",
97
+ "edit",
98
+ "write",
99
+ "subagent_delegate",
100
+ ],
89
101
  subagentRoles: ["explorer"],
90
102
  systemPrompt: [
91
103
  "Web researcher. Search with varied angles, prefer official docs over blogs.",
92
104
  "If first results are insufficient, refine queries and search again.",
93
105
  "",
106
+ "## Research artifacts",
107
+ "You may write files (downloaded docs, notes, intermediate results) — but ONLY under $PI_SUBAGENT_TMPDIR.",
108
+ "Never write anywhere else: project files and other directories are strictly off-limits.",
109
+ "",
94
110
  "## GitHub repo analysis",
95
111
  "When the task requires analyzing a GitHub repo:",
96
- "1. git clone the repo into PI_SUBAGENT_TMPDIR (must exist)",
112
+ "1. Clone the repo into $PI_SUBAGENT_TMPDIR",
97
113
  "2. Use `subagent_delegate` with role=explorer to investigate the cloned codebase — pass the repo path and the research question",
98
114
  "3. Combine explorer findings with any web search results",
99
115
  "",
100
- "bash is for git clone and read-only commands only. Never modify files.",
101
- "",
102
116
  "Output format:",
103
117
  "## Answer: direct answer to the question (2-3 sentences)",
104
118
  "## Sources: list of URLs used",
package/src/types.ts CHANGED
@@ -54,8 +54,11 @@ export interface SubagentRole {
54
54
  decisionTrigger: string;
55
55
  /** System prompt for the subagent */
56
56
  systemPrompt: string;
57
- /** Tools available to this subagent */
58
- tools: string[];
57
+ /**
58
+ * Tools available to this subagent. Empty or absent = all tools (no restriction).
59
+ * When set, only the listed tool names are exposed to the child (exact-name allowlist).
60
+ */
61
+ tools?: string[];
59
62
  /** If this role has `delegate`, restrict which roles it may spawn. undefined = no restriction. */
60
63
  subagentRoles?: string[];
61
64
  /** Per-role active-time timeout in seconds. `0` or unset means unlimited; negative values are normalized to `0`. */