@d3ara1n/pi-subagent 1.1.1 → 1.2.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
@@ -32,10 +32,12 @@ 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) |
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 |
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
+ | `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
 
@@ -124,7 +126,7 @@ Override, disable, or add subagent roles via `agentOverrides`. Built-in and cust
124
126
  },
125
127
  "tester": {
126
128
  "role": "default",
127
- "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.",
128
130
  "examples": [
129
131
  "Write unit tests for the auth module",
130
132
  "Run the test suite and fix failing tests"
@@ -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.1",
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
 
@@ -14,18 +15,18 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
14
15
  fallbackRole: "default",
15
16
  timeout: 900,
16
17
  description:
17
- "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.",
18
19
  examples: ["Find where auth middleware is implemented", "Map the routing structure"],
19
20
  decisionTrigger: "Task finds or maps code without touch?",
20
21
  tools: ["read", "find", "grep"],
21
22
  systemPrompt: [
22
- "Fast code explorer. You have READ-ONLY tools only no commands, no edits.",
23
- "Grep/find to locate → read key sections only → identify types, interfaces, functions.",
24
- "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.",
25
26
  "",
26
- "Output format (keep each section brief):",
27
+ "Output format:",
27
28
  "## Files: file paths with line ranges and one-line descriptions",
28
- "## Findings: key types/functions with minimal code snippets",
29
+ "## Findings: key types/functions with short code snippets",
29
30
  "## Summary: direct answer to the task question",
30
31
  ].join("\n"),
31
32
  },
@@ -34,7 +35,7 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
34
35
  fallbackRole: "default",
35
36
  timeout: 3600,
36
37
  description:
37
- "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.",
38
39
  examples: [
39
40
  "Review the error handling in src/api/ for security issues",
40
41
  "Audit this PR diff for performance regressions",
@@ -43,7 +44,7 @@ export const BUILTIN_ROLES: Record<string, SubagentRole> = {
43
44
  tools: ["read", "bash", "grep", "find"],
44
45
  systemPrompt: [
45
46
  "Senior code reviewer. READ-ONLY — you must NOT modify any file.",
46
- "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.",
47
48
  "Provide evidence-backed findings with file:line references.",
48
49
  "",
49
50
  "Output format (prioritize critical issues first):",
@@ -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 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
+ "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`. */