npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fosterg4/pi-subagent

v1.0.7

Published

Delegate tasks to specialized subagents with isolated context windows, structured JSON handoff, contract schemas, and live TUI streaming

Readme

@fosterg4/pi-subagent

npm version

Delegate complex tasks to specialized sub-agents with isolated context windows, structured JSON handoff, contract schemas, and live TUI streaming — all within pi.

Features

  • Isolated context — Each subagent runs in a separate pi process with its own context window
  • Three execution modes — Single, parallel (max 8, concurrency 4), and chain (sequential with data handoff)
  • Structured JSON handoff — Agents pass typed data between each other, not freeform markdown
  • Contract schemasinputSchema/outputSchema in agent frontmatter ensures valid handoffs
  • Live TUI streaming — Subagent tool calls (read, bash, grep, etc.) stream in real-time
  • Bundled agents — 4 built-in agents ready to use: scout, planner, reviewer, worker
  • Workflow prompts/implement, /scout-and-plan, /implement-and-review commands

Installation

pi install npm:@fosterg4/pi-subagent

For a quick test without installing:

pi -e npm:@fosterg4/pi-subagent

Usage

Single agent

Ask the LLM to use a subagent:

Use scout to find all authentication code in the project

The LLM will call the subagent tool with { agent: "scout", task: "..." }.

Parallel execution

Run 2 scouts in parallel: one to find models, one to find providers

Chained workflow

Use a chain: first have scout find the read tool, then have planner suggest improvements

Workflow prompts

/implement add Redis caching to the session store
/scout-and-plan refactor auth to support OAuth
/implement-and-review add input validation to API endpoints

Bundled Agents

| Agent | Purpose | Default Model | |-------|---------|---------------| | scout | Fast codebase recon — returns structured findings | claude-haiku-4-5 | | planner | Creates implementation plans from context & requirements | claude-sonnet-4-5 | | reviewer | Code review — quality, security, maintainability | claude-sonnet-4-5 | | worker | General-purpose implementation with full capabilities | claude-sonnet-4-5 |

Each agent has a defined inputSchema and outputSchema in its frontmatter, ensuring structured data flows between chained agents.

Tool Parameters

The subagent tool accepts three mutually exclusive modes:

Single mode

{
  "agent": "scout",
  "task": "Find all authentication code",
  "cwd": "/optional/working/directory"
}

Parallel mode

{
  "tasks": [
    { "agent": "scout", "task": "Find models" },
    { "agent": "scout", "task": "Find providers" }
  ]
}

Chain mode

{
  "chain": [
    { "agent": "scout", "task": "Investigate the codebase" },
    { "agent": "planner", "task": "Create a plan from: {previous}" }
  ]
}

Common options

| Option | Type | Default | Description | |--------|------|---------|-------------| | agentScope | "user", "project", "both" | "user" | Which agent directories to search | | confirmProjectAgents | boolean | true | Prompt before running project agents | | cwd | string | current dir | Working directory for subprocess |

Custom Agents

Create your own agents as .md files with YAML frontmatter:

---
name: my-agent
description: What this agent does
tools: read, grep, find, ls, bash
model: claude-haiku-4-5
inputSchema:
  type: object
  properties:
    query:
      type: string
  required: [query]
outputSchema:
  type: object
  properties:
    result:
      type: string
  required: [result]
---

System prompt for the agent goes here.

Agent locations (priority: project > user > bundled):

  • ~/.pi/agent/agents/*.md — User-level (always loaded)
  • .pi/agents/*.md — Project-level (requires agentScope: "project" or "both")
  • Bundled with package — Lowest priority, always available

Security

  • User agents (~/.pi/agent/agents/): Always trusted
  • Project agents (.pi/agents/): Requires confirmation prompt before execution
  • Bundled agents: Trusted by virtue of package installation

Development

# Clone and test locally
git clone https://github.com/fosterg4/pi-subagent.git
cd pi-subagent

# Test with pi
pi -e ./index.ts

# Publish
npm publish --access public

License

MIT