Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pi/.pi/agent/extensions/delegate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
*.tgz
13 changes: 13 additions & 0 deletions pi/.pi/agent/extensions/delegate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## [0.1.0]

Initial standalone package for the existing delegate extension.

- Preserve the `delegate` tool, model/settings resolution, three-child FIFO queue,
streamed results, cancellation, trust handling, and compact tool rendering.
- Include optional tmux monitors and their dependency-free viewer in the package.
- Load TypeScript directly through an explicit Pi manifest, without a build step
or bundled Pi host dependencies.
- Add package-local tests, type-checking, a development lockfile, and an explicit
npm tarball allowlist.
22 changes: 22 additions & 0 deletions pi/.pi/agent/extensions/delegate/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2026 Colton Padden
Copyright (c) 2025 Mario Zechner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
98 changes: 92 additions & 6 deletions pi/.pi/agent/extensions/delegate/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
# Delegate
# Pi delegate

Fresh Pi children, streamed results, up to three concurrent runs per session. Extra calls queue; every call waits for completion.
`@colton.padden/pi-delegate`: fresh Pi children, streamed results, up to three
concurrent runs per session. Extra calls queue; every call waits for completion.

## Setup

Requires Node.js 24+ and Pi. The package is tested against Pi 1.5.0. It reuses the
running Pi executable and its configured providers/credentials, not a separately
bundled agent. tmux is optional and needed only for visible monitors; the viewer
uses Node.js (or the current Node/Bun runtime).

In this Stow-managed checkout, run `stow -t "$HOME" pi` from the repository root
if needed, then `/reload`. Pi discovers `delegate/package.json`, which loads
`src/index.ts`. No shim, build step, or settings changes are required.

The directory is also a standalone local Pi package:

```sh
pi install /absolute/path/to/delegate
```

After publication, it can be installed from npm:

```sh
pi install npm:@colton.padden/pi-delegate@0.1.0
```

Use one loading method; do not install a second copy alongside the
Stow-discovered extension. Pi supplies the extension's host APIs, TUI components,
and TypeBox as peers. Runtime code has no other npm dependencies, and `wt` is not
automatically invoked or installed.

## Settings

Expand Down Expand Up @@ -57,12 +86,69 @@ Model IDs must include the provider: `vercel-ai-gateway/openai/gpt-6.1-sol`, not
- Cancellation/reload/shutdown stops children; force-killing Pi may bypass cleanup. No durable background jobs or recursive delegation.
- Results cap at 50 KiB/2,000 lines; overflow files are retained in private temporary storage. Monitor snapshots are bounded and removed after use.

## Tests
## Package layout and development

```text
delegate/
├── package.json
├── package-lock.json
├── tsconfig.json
├── README.md
├── LICENSE
├── CHANGELOG.md
├── src/
│ ├── index.ts
│ ├── runtime.ts
│ ├── queue.ts
│ ├── monitor.ts
│ └── monitor-view.mjs
└── tests/
├── index.test.mjs
├── runtime.test.ts
├── monitor.test.ts
└── package.test.mjs
```

From `pi/`, with Node.js 24+ and the managed Pi installation:
From this directory, with Node.js 24+ and npm:

```sh
node --test .pi/agent/extensions/delegate/{runtime.test.ts,index.test.mjs,monitor.test.ts}
npm ci --ignore-scripts
npm run check # type-check, then tests
npm pack --dry-run # runs checks and previews the publish allowlist
```

Local fake children; no paid requests. Real tmux tests use an isolated server and skip if tmux is unavailable.
The same commands work after copying this directory out of dotfiles. There is
no dependency on the managed Pi installation path, a global Pi executable, or
repository-root configuration. Development dependencies provide a pinned Pi host,
its API/TUI packages, TypeBox, TypeScript, and Node types; none are bundled in the
published package. Dependencies and generated package archives are gitignored.

Tests use local fake children; no model requests, credentials, or paid API calls.
They exercise Pi manifest discovery, queueing, cancellation, usage accounting,
trust handling, rendering, monitor cleanup, and the npm tarball allowlist. The
integration tests resolve Pi's internal loader from the pinned development host.
Real tmux tests use an isolated server and skip if tmux is unavailable. The viewer
stays a dependency-free `.mjs` file so tmux can launch it directly with Node.

## Publishing

Publication is manual; nothing publishes automatically. From this directory:

1. Confirm `npm whoami` reports `colton.padden` and the intended version is unused.
2. Update the version and `CHANGELOG.md` for the release.
3. Run `npm ci --ignore-scripts`, `npm run check`, then `npm publish --dry-run`.
4. Audit the package contents for secrets and runtime state. Only the five files
in `src/`, `CHANGELOG.md`, and npm's automatically included README, license,
and manifest belong in the tarball. The monitor viewer must be included.
5. When ready, publish explicitly with `npm publish --access public`.

Pi loads the TypeScript sources directly; no compilation or installer/prepare
hook is needed. `prepack` runs the checks before packing or publishing. Keep host
packages in peer/development dependencies, never runtime dependencies. npm
versions cannot be overwritten with different contents.

## License

MIT. The subprocess lifecycle is adapted from Pi's
[MIT-licensed subagent example](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/subagent).
The license retains Mario Zechner's upstream copyright notice.
Loading
Loading