@jerryan/pi-subagent-tools 0.1.0 → 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,70 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0
4
+
5
+ ### Changed
6
+
7
+ - **Review/explore children now get a sandboxed read-only `bash`** instead of
8
+ the `grep`/`find`/`ls` builtins plus the dedicated `git` tool. The sandbox
9
+ is a just-bash interpreter over a composed filesystem: the project root
10
+ mounted read-only at `/repo` (OverlayFs) over a writable in-memory base
11
+ (MountableFs) providing `/dev/null` and per-call scratch (`/tmp`). Git is
12
+ provided by just-git inside the sandbox (network disabled). Read-only is
13
+ now enforced at the capability layer — the filesystem rejects every write
14
+ to the project (redirects, `rm`, `sed -i`, git object/ref updates) —
15
+ replacing the per-subcommand git policy table. The tool surface shrinks to
16
+ `read` + `bash`; the sandboxed `bash` shadows the builtin (custom tools
17
+ win over builtins), so there is no configuration in which a raw builtin
18
+ bash reaches a read-only child.
19
+ - The dedicated `git` tool is removed; git inspection (log, diff, show,
20
+ blame, grep, ls-files) goes through the sandbox.
21
+ Known limitation: just-git's `.gitignore` parser does not strip carriage
22
+ returns — on Windows (CRLF `.gitignore`) ignore rules silently no-op, so
23
+ `git status` walks the unpruned worktree (slow) and reports ignored paths
24
+ as untracked; the tool description steers agents to targeted commands.
25
+
26
+ ### Added
27
+
28
+ - New runtime dependencies: `just-bash`, `just-git`.
29
+
30
+ ## 0.2.0
31
+
32
+ **Subagents now run in-process** via the pi SDK (`createAgentSession`) instead
33
+ of as spawned `pi` subprocesses. Requires pi >= 0.84.
34
+
35
+ - **New `follow_up` tool.** Every spawn result includes an agent id
36
+ (e.g. `delegate-1`). `follow_up({ agent, task })` continues that agent's
37
+ session with full context — for refining work, asking questions, or
38
+ recovering from incomplete/failed results. Agents keep their original role,
39
+ tools, and cwd for life.
40
+ - **Interactive prompts route to the parent TUI.** Subagent `select` /
41
+ `confirm` / `input` / `editor` requests are bridged to the parent's UI
42
+ instead of silently falling back to defaults (ui-bridge.ts).
43
+ - **Agent lifetime management.** Agents are kept in a registry and disposed
44
+ only after 10+ idle turns (running agents are never disposed), or when the
45
+ owning session ends.
46
+ - Tool errors are now reported by throwing, matching pi >= 0.84 tool semantics.
47
+ - The read-only git tool is fully async (subagents share the parent's event
48
+ loop; a blocking exec would freeze the TUI), and its read-only enforcement
49
+ is now a per-subcommand policy table — mutating flags (`branch -D`,
50
+ `diff --output=...`) and branch creation via positional args are rejected.
51
+
52
+ Breaking changes:
53
+
54
+ - Removed `delegate`'s `context` parameter (was a no-op placeholder).
55
+ - Recursion guard is now structural (child sessions get exactly the tools
56
+ injected by the extension) — the `PI_SUBAGENT_TOOLS_ROLE` env var is gone.
57
+ - Child sessions no longer load user/project extensions (created with
58
+ `noExtensions: true`); skills and system prompts still apply. **Exception:**
59
+ delegate children DO discover user/project extensions (they are workers and
60
+ need the parent's environment, including guard extensions) — with this
61
+ extension itself excluded from discovery (that exclusion is the recursion
62
+ guard) and project-local extensions excluded in untrusted projects.
63
+
64
+ ## 0.1.1
65
+
66
+ - Add delegate system prompt. Subagents now do the work directly instead of discussing plans. Minor uncertainties proceed with stated assumptions; major obstacles are reported back with a suggestion to re-delegate.
67
+
68
+ ## 0.1.0
69
+
70
+ Initial release. Delegate, review, and explore tools via isolated pi subagent processes.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Zerui An
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 CHANGED
@@ -1,14 +1,17 @@
1
1
  # @jerryan/pi-subagent-tools
2
2
 
3
- A minimal pi extension for delegating work to isolated subagent processes. Three tools, one job each. The agent is a **project manager** — delegate by default, dive in only when necessary.
3
+ A minimal pi extension for delegating work to subagents. Four tools, one job each. The agent is a **project manager** — delegate by default, dive in only when necessary.
4
4
 
5
5
  ## What makes this different?
6
6
 
7
- Every subagent is a fresh `pi` process with an isolated context window. No agent definitions to write, no configuration files to maintain, no mode-switching parameters to misconfigure. Each tool's name *is* the contract:
7
+ Every subagent is an isolated `AgentSession` running in-process via the pi SDK — its own context window, its own tools, no configuration files to maintain. Each tool's name *is* the contract:
8
8
 
9
9
  - **`review`** — always read-only, always in the current project. You can't forget to lock it down.
10
10
  - **`explore`** — always read-only, requires a target directory. Picks up the target project's settings, skills, and context.
11
- - **`delegate`** — general-purpose worker. Inherits the parent's tools and system prompt for optimal cache reuse. Optional CWD and skills.
11
+ - **`delegate`** — general-purpose worker with full tool access. Optional CWD and skills.
12
+ - **`follow_up`** — continue any spawned agent's session with full context. No re-explaining, no lost work.
13
+
14
+ Interactive prompts from subagents (confirmations, selections, inputs) appear in your TUI instead of silently falling back to defaults.
12
15
 
13
16
  ## Installation
14
17
 
@@ -16,49 +19,78 @@ Every subagent is a fresh `pi` process with an isolated context window. No agent
16
19
  pi install npm:@jerryan/pi-subagent-tools
17
20
  ```
18
21
 
19
- The extension is available the next time you start a pi session.
22
+ The extension is available the next time you start a pi session. Requires pi >= 0.84.
20
23
 
21
24
  ## Tools
22
25
 
23
26
  ### `review`
24
27
 
25
- Review code, diffs, or files in the current project. The reviewer is always read-only — it cannot modify files or execute commands.
28
+ Review code, diffs, or files in the current project. The reviewer is always read-only: it gets `read` plus a sandboxed bash (just-bash over a read-only mount of your project — grep, find, sed, git log/diff/blame all work; every write fails at the filesystem).
26
29
 
27
30
  | Parameter | Type | Required | Description |
28
31
  |-----------|------|----------|-------------|
29
32
  | `task` | string | Yes | What to review |
30
- | `skills` | string[] | No | Skills to load via `--skill` |
33
+ | `skills` | string[] | No | Skills to load |
31
34
 
32
35
  ### `explore`
33
36
 
34
- Map a project directory. The explorer runs in the target directory, picking up its `.pi/settings.json`, skills, AGENTS.md, and other context files. Always read-only.
37
+ Map a project directory. The explorer runs in the target directory, picking up its `.pi/settings.json`, skills, AGENTS.md, and other context files. Always read-only, with the same sandboxed bash as the reviewer.
35
38
 
36
39
  | Parameter | Type | Required | Description |
37
40
  |-----------|------|----------|-------------|
38
41
  | `task` | string | Yes | What to explore |
39
42
  | `cwd` | string | Yes | Target project directory |
40
- | `skills` | string[] | No | Skills to load via `--skill` |
43
+ | `skills` | string[] | No | Skills to load |
41
44
 
42
45
  ### `delegate`
43
46
 
44
- General-purpose worker. No tool filtering, no system prompt override — the subagent inherits the parent's full environment, enabling cache hits when used with context inheritance (future).
47
+ General-purpose worker. Full tool access (read, bash, edit, write), and loads your user/project extensions like a fresh pi would — custom tools and guard extensions apply to the worker just as they do to you. Uses the parent's current model and thinking level.
45
48
 
46
49
  | Parameter | Type | Required | Description |
47
50
  |-----------|------|----------|-------------|
48
51
  | `task` | string | Yes | Task to delegate |
49
52
  | `cwd` | string | No | Working directory (defaults to parent's CWD) |
50
- | `skills` | string[] | No | Skills to load via `--skill` |
51
- | `context` | `"fresh"` \| `"inherit"` | No | Context mode (not yet implemented) |
53
+ | `skills` | string[] | No | Skills to load |
54
+
55
+ ### `follow_up`
56
+
57
+ Send a follow-up task to a previously spawned subagent, continuing its session with full context. The agent retains its original role, tools, and working directory — a reviewer stays read-only forever.
58
+
59
+ | Parameter | Type | Required | Description |
60
+ |-----------|------|----------|-------------|
61
+ | `agent` | string | Yes | Agent id from a previous result (e.g. `delegate-1`) |
62
+ | `task` | string | Yes | Follow-up task or question |
63
+
64
+ Every spawn and follow-up result ends with the agent's id:
65
+
66
+ ```
67
+ <the subagent's output>
68
+
69
+ ---
70
+ agent: delegate-1
71
+ ```
72
+
73
+ Unknown or expired ids fail loudly with the list of live agents — never a silent fresh spawn.
74
+
75
+ ## Agent lifetime
76
+
77
+ Agents live in a per-session registry. Cleanup is recency-based:
78
+
79
+ - An agent idle for more than **10 turns** of the owning session is disposed.
80
+ - Running agents are never disposed. Recently active agents are never disposed — there is no count cap; a burst of 20 parallel delegates all run to completion.
81
+ - All agents are disposed when the owning session ends.
52
82
 
53
83
  ## Recursion guard
54
84
 
55
- Subagents cannot spawn further subagents beyond one level:
85
+ Subagent nesting is capped structurally — child sessions are created with extension discovery disabled, so they get exactly the tools the extension injects:
86
+
87
+ | Parent role | `review` | `explore` | `delegate` | `follow_up` |
88
+ |-------------|:--:|:--:|:--:|:--:|
89
+ | Parent (normal) | ✓ | ✓ | ✓ | ✓ |
90
+ | Delegate child | ✓ | ✓ | Rejects at runtime | ✓ |
91
+ | Review / explore child | — | — | — | — |
56
92
 
57
- | Parent role | `review` | `explore` | `delegate` |
58
- |-------------|:--:|:--:|:--:|
59
- | Parent (normal) | ✓ | ✓ | ✓ |
60
- | Delegate child | ✓ | ✓ | Rejects at runtime |
61
- | Review / explore child | — | — | — |
93
+ A delegate child's agents live in their own registry with their own ids.
62
94
 
63
95
  ## Related
64
96