@jerryan/pi-subagent-tools 0.1.1 → 0.4.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 +91 -0
- package/README.md +102 -70
- package/agents.ts +881 -0
- package/index.ts +19 -429
- package/package.json +63 -54
- package/prompts/explore.md +4 -4
- package/prompts/review.md +4 -4
- package/render.ts +87 -0
- package/sandbox-bash.ts +312 -0
- package/sandbox-python.ts +169 -0
- package/tui.ts +73 -66
- package/ui-bridge.ts +198 -0
- package/spawn.ts +0 -262
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **Sandbox bash now uses real-layout mounts instead of a fixed `/repo`.**
|
|
8
|
+
On posix, `$HOME` is mounted at its own path (plus the project root when
|
|
9
|
+
the cwd is outside home — read-only agents may read other projects); on
|
|
10
|
+
Windows, every existing drive is mounted at MSYS form (`C:\` = `/c`).
|
|
11
|
+
Sandbox paths match host paths one-to-one, so paths move verbatim between
|
|
12
|
+
bash and the `read` tool. Everything outside the mounts remains per-call
|
|
13
|
+
in-memory scratch.
|
|
14
|
+
- **Switched `just-bash` for the `@jerryan/just-bash` fork** (^3.10.0),
|
|
15
|
+
which adds the Windows native-spelling path translation the real-layout
|
|
16
|
+
scheme relies on, plus extra default utilities (jq, yq, sqlite3, rg,
|
|
17
|
+
xan).
|
|
18
|
+
- **New sandboxed `python` tool for review/explore children**: stdlib-only
|
|
19
|
+
WASM CPython over the same read-only filesystem, for dependency-free
|
|
20
|
+
analysis scripts. It is a separate tool — NOT a `python3` command in
|
|
21
|
+
the bash sandbox — because a bare `python3` on PATH implies the native
|
|
22
|
+
interpreter (project env, pip), a capability the WASM build doesn't
|
|
23
|
+
have; the dedicated tool makes the stdlib-only contract explicit.
|
|
24
|
+
(The role allowlist must name `python`: pi filters customTools through
|
|
25
|
+
it — a custom-only tool name missing from the allowlist is silently
|
|
26
|
+
dropped.)
|
|
27
|
+
- **`just-git` bumped to ^1.9.0**, which fixes the CRLF `.gitignore`
|
|
28
|
+
parsing quirk (Windows checkouts with `core.autocrlf=true` had ignore
|
|
29
|
+
rules silently no-op inside the sandbox).
|
|
30
|
+
- Trimmed the sandboxed bash tool description to behavioral deltas from
|
|
31
|
+
stock bash (read-only, no network, stateless per call).
|
|
32
|
+
|
|
33
|
+
## 0.3.0
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- **Review/explore children now get a sandboxed read-only `bash`** instead of
|
|
38
|
+
the `grep`/`find`/`ls` builtins plus the dedicated `git` tool. The sandbox
|
|
39
|
+
is a just-bash interpreter over a composed filesystem: the project root
|
|
40
|
+
mounted read-only at `/repo` (OverlayFs) over a writable in-memory base
|
|
41
|
+
(MountableFs) providing `/dev/null` and per-call scratch (`/tmp`). Git is
|
|
42
|
+
provided by just-git inside the sandbox (network disabled). Read-only is
|
|
43
|
+
now enforced at the capability layer — the filesystem rejects every write
|
|
44
|
+
to the project (redirects, `rm`, `sed -i`, git object/ref updates) —
|
|
45
|
+
replacing the per-subcommand git policy table. The tool surface shrinks to
|
|
46
|
+
`read` + `bash`; the sandboxed `bash` shadows the builtin (custom tools
|
|
47
|
+
win over builtins), so there is no configuration in which a raw builtin
|
|
48
|
+
bash reaches a read-only child.
|
|
49
|
+
- The dedicated `git` tool is removed; git inspection (log, diff, show,
|
|
50
|
+
blame, grep, ls-files) goes through the sandbox.
|
|
51
|
+
Known limitation: just-git's `.gitignore` parser does not strip carriage
|
|
52
|
+
returns — on Windows (CRLF `.gitignore`) ignore rules silently no-op, so
|
|
53
|
+
`git status` walks the unpruned worktree (slow) and reports ignored paths
|
|
54
|
+
as untracked; the tool description steers agents to targeted commands.
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- New runtime dependencies: `just-bash`, `just-git`.
|
|
59
|
+
|
|
60
|
+
## 0.2.0
|
|
61
|
+
|
|
62
|
+
**Subagents now run in-process** via the pi SDK (`createAgentSession`) instead
|
|
63
|
+
of as spawned `pi` subprocesses. Requires pi >= 0.84.
|
|
64
|
+
|
|
65
|
+
- **New `follow_up` tool.** Every spawn result includes an agent id
|
|
66
|
+
(e.g. `delegate-1`). `follow_up({ agent, task })` continues that agent's
|
|
67
|
+
session with full context — for refining work, asking questions, or
|
|
68
|
+
recovering from incomplete/failed results. Agents keep their original role,
|
|
69
|
+
tools, and cwd for life.
|
|
70
|
+
- **Interactive prompts route to the parent TUI.** Subagent `select` /
|
|
71
|
+
`confirm` / `input` / `editor` requests are bridged to the parent's UI
|
|
72
|
+
instead of silently falling back to defaults (ui-bridge.ts).
|
|
73
|
+
- **Agent lifetime management.** Agents are kept in a registry and disposed
|
|
74
|
+
only after 10+ idle turns (running agents are never disposed), or when the
|
|
75
|
+
owning session ends.
|
|
76
|
+
- Tool errors are now reported by throwing, matching pi >= 0.84 tool semantics.
|
|
77
|
+
- The read-only git tool is fully async (subagents share the parent's event
|
|
78
|
+
loop; a blocking exec would freeze the TUI), and its read-only enforcement
|
|
79
|
+
is now a per-subcommand policy table — mutating flags (`branch -D`,
|
|
80
|
+
`diff --output=...`) and branch creation via positional args are rejected.
|
|
81
|
+
|
|
82
|
+
Breaking changes:
|
|
83
|
+
|
|
84
|
+
- Removed `delegate`'s `context` parameter (was a no-op placeholder).
|
|
85
|
+
- Recursion guard is now structural (child sessions get exactly the tools
|
|
86
|
+
injected by the extension) — the `PI_SUBAGENT_TOOLS_ROLE` env var is gone.
|
|
87
|
+
- Child sessions no longer load user/project extensions (created with
|
|
88
|
+
`noExtensions: true`); skills and system prompts still apply. **Exception:**
|
|
89
|
+
delegate children DO discover user/project extensions (they are workers and
|
|
90
|
+
need the parent's environment, including guard extensions) — with this
|
|
91
|
+
extension itself excluded from discovery (that exclusion is the recursion
|
|
92
|
+
guard) and project-local extensions excluded in untrusted projects.
|
|
93
|
+
|
|
3
94
|
## 0.1.1
|
|
4
95
|
|
|
5
96
|
- 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.
|
package/README.md
CHANGED
|
@@ -1,70 +1,102 @@
|
|
|
1
|
-
# @jerryan/pi-subagent-tools
|
|
2
|
-
|
|
3
|
-
A minimal pi extension for delegating work to
|
|
4
|
-
|
|
5
|
-
## What makes this different?
|
|
6
|
-
|
|
7
|
-
Every subagent is
|
|
8
|
-
|
|
9
|
-
- **`review`** — always read-only, always in the current project. You can't forget to lock it down.
|
|
10
|
-
- **`explore`** — always read-only, requires a target directory. Picks up the target project's settings, skills, and context.
|
|
11
|
-
- **`delegate`** — general-purpose worker
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
|
50
|
-
|
|
51
|
-
| `
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
# @jerryan/pi-subagent-tools
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
## What makes this different?
|
|
6
|
+
|
|
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
|
+
|
|
9
|
+
- **`review`** — always read-only, always in the current project. You can't forget to lock it down.
|
|
10
|
+
- **`explore`** — always read-only, requires a target directory. Picks up the target project's settings, skills, and context.
|
|
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.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pi install npm:@jerryan/pi-subagent-tools
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The extension is available the next time you start a pi session. Requires pi >= 0.84.
|
|
23
|
+
|
|
24
|
+
## Tools
|
|
25
|
+
|
|
26
|
+
### `review`
|
|
27
|
+
|
|
28
|
+
Review code, diffs, or files in the current project. The reviewer is always read-only: it gets `read`, a sandboxed bash (just-bash over real-layout read-only mounts — your home dir, or all drives on Windows — so grep, find, sed, git log/diff/blame all work and paths match the host verbatim; every write fails at the filesystem), and a sandboxed stdlib-only python for analysis scripts.
|
|
29
|
+
|
|
30
|
+
| Parameter | Type | Required | Description |
|
|
31
|
+
|-----------|------|----------|-------------|
|
|
32
|
+
| `task` | string | Yes | What to review |
|
|
33
|
+
| `skills` | string[] | No | Skills to load |
|
|
34
|
+
|
|
35
|
+
### `explore`
|
|
36
|
+
|
|
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 and python as the reviewer.
|
|
38
|
+
|
|
39
|
+
| Parameter | Type | Required | Description |
|
|
40
|
+
|-----------|------|----------|-------------|
|
|
41
|
+
| `task` | string | Yes | What to explore |
|
|
42
|
+
| `cwd` | string | Yes | Target project directory |
|
|
43
|
+
| `skills` | string[] | No | Skills to load |
|
|
44
|
+
|
|
45
|
+
### `delegate`
|
|
46
|
+
|
|
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.
|
|
48
|
+
|
|
49
|
+
| Parameter | Type | Required | Description |
|
|
50
|
+
|-----------|------|----------|-------------|
|
|
51
|
+
| `task` | string | Yes | Task to delegate |
|
|
52
|
+
| `cwd` | string | No | Working directory (defaults to parent's CWD) |
|
|
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.
|
|
82
|
+
|
|
83
|
+
## Recursion guard
|
|
84
|
+
|
|
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 | — | — | — | — |
|
|
92
|
+
|
|
93
|
+
A delegate child's agents live in their own registry with their own ids.
|
|
94
|
+
|
|
95
|
+
## Related
|
|
96
|
+
|
|
97
|
+
- **[pi-subagents](https://github.com/nicobailon/pi-subagents)** — Feature-rich implementation with agent definitions, background runs, session forking, inter-process communication, and a full management UI. The definitive reference for what's possible, though possibly more than most workflows need.
|
|
98
|
+
- **[pi-subagent-lite](https://github.com/JerryAZR/pi-subagent-lite)** — Ultra-minimal (~250 lines). A single `task` tool with minimal context overhead.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT
|