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

pi-faithless-subagents

v0.1.9

Published

PI-native constrained subagent orchestration library

Readme

pi-faithless-subagents

Constrained 4-role subagent workflows for PI:

  • explorer
  • planner
  • worker
  • reviewer

The package does not invent workflows. You provide an explicit workflow spec, and the orchestrator validates and runs it.

What changed

The extension now runs subagent steps through PI's own session runtime by default:

  • it reuses the active PI model
  • it maps role reasoning policy to PI thinking level
  • it runs each step in an isolated in-memory PI session
  • it exposes only the declared host tools for that step

A legacy OpenAI-backed runner still exists as an explicit fallback for non-PI usage.

Install

npm install pi-faithless-subagents

PI extension tools

This package registers exactly two PI tools:

  • pi_subagents_run_workflow
  • pi_subagents_run_step

The package manifest is exposed from pi-extension.ts via the normal PI extension mechanism.

Workflow shape

interface WorkflowSpec {
  id: string;
  steps: StepSpec[];
}

interface StepSpec {
  id: string;
  role: "explorer" | "planner" | "worker" | "reviewer";
  objective: string;
  dependsOn?: string[];
  inputArtifacts?: string[];
  allowedReadPaths?: string[];
  allowedWritePaths?: string[];
  timeoutMs?: number;
  maxTurns?: number;
  retryLimit?: number;
  optionalDependencies?: string[];
}

Role contracts

Explorer

Purpose:

  • inspect the codebase
  • identify relevant files
  • record facts and open questions

Artifact:

  • report.md
  • kind: report

Required sections:

  • ## Goal
  • ## Relevant Files
  • ## Findings
  • ## Open Questions
  • ## Recommended Next Step

Planner

Purpose:

  • turn exploration output into an implementation plan

Artifact:

  • plan.md
  • kind: plan

Required sections:

  • ## Goal
  • ## Constraints
  • ## Implementation Plan
  • ## Acceptance Criteria
  • ## Risks

Worker

Purpose:

  • implement within the declared write scope

Artifact:

  • implementation-report.md
  • kind: implementation-report

Required sections:

  • ## Plan Followed
  • ## Files Changed
  • ## Tests Run
  • ## Known Gaps

Reviewer

Purpose:

  • review worker output and produce a verdict

Artifact:

  • verdict.md
  • kind: verdict

Required sections:

  • ## Verdict
  • ## Findings
  • ## Blocking Issues
  • ## Non-Blocking Issues
  • ## Recommended Disposition

PI-native execution model

By default, createPiExtension() uses the PI-native runner.

For each step it:

  1. creates a fresh in-memory PI session
  2. reuses the active PI model from the calling PI session
  3. maps role reasoning policy to PI thinking level
  4. disables extension/skill/prompt/theme discovery for the child session
  5. exposes only the filtered host tools allowed for that role
  6. injects upstream artifacts into the step prompt
  7. validates the returned artifact before marking the step complete

maxTurns is enforced as a PI tool-call cap for the step.

The runtime also applies bounded-memory safeguards by default:

  • upstream artifacts injected into prompts are capped and truncated with explicit markers
  • serialized tool outputs sent back to models are capped and truncated
  • returned artifacts are size-checked before being accepted
  • timed out steps abort their child execution via AbortSignal

Default host tools

When defaultTools is enabled, the package wires in these host tools:

  • list_files
  • read_file
  • search_text
  • write_file (worker only)
  • run_command (worker/reviewer only, allowlisted)

You can also provide your own host tools through piTools.

Default host tools are bounded as well:

  • read_file returns at most a capped prefix with truncation metadata
  • list_files caps the number of returned entries
  • search_text caps match count and bytes scanned per file
  • run_command caps returned stdout and stderr

You can tune these defaults with defaultTools.maxReadFileBytes, defaultTools.maxListEntries, defaultTools.maxSearchMatches, defaultTools.maxSearchFileBytes, defaultTools.maxSearchLineBytes, and defaultTools.maxCommandOutputBytes.

Policy constraints

The orchestrator enforces:

  • only worker steps may declare writable repository paths
  • every worker step must declare at least one writable path
  • writable paths must remain under repoRoot
  • overlapping worker write scopes are rejected
  • inputArtifacts may only reference declared dependencies

Path-based host tools are checked against allowedReadPaths and allowedWritePaths at execution time.

PI usage

Example workflow tool payload:

{
  "workflow": {
    "id": "demo-run",
    "steps": [
      {
        "id": "explore",
        "role": "explorer",
        "objective": "Inspect src and identify the relevant files",
        "allowedReadPaths": ["src"]
      },
      {
        "id": "plan",
        "role": "planner",
        "objective": "Write an implementation plan from the explorer report",
        "dependsOn": ["explore"],
        "allowedReadPaths": ["src"]
      },
      {
        "id": "work",
        "role": "worker",
        "objective": "Implement the approved change",
        "dependsOn": ["plan"],
        "allowedReadPaths": ["src"],
        "allowedWritePaths": ["src"]
      },
      {
        "id": "review",
        "role": "reviewer",
        "objective": "Review the worker output",
        "dependsOn": ["work"],
        "allowedReadPaths": ["src"]
      }
    ]
  },
  "hostContext": {
    "repoRoot": "/absolute/path/to/repo",
    "runRoot": "/absolute/path/to/run-root"
  }
}

Programmatic usage

Full extension

import { createPiExtension } from "pi-faithless-subagents";

const extension = createPiExtension({
  defaultTools: { commandAllowlist: ["npm", "node"] }
});

const result = await extension.toolAdapter.callTool({
  name: "pi_subagents_run_step",
  arguments: {
    runId: "review-pass",
    step: {
      id: "review",
      role: "reviewer",
      objective: "Review the existing implementation",
      allowedReadPaths: ["src", "test"]
    },
    hostContext: {
      repoRoot: "/absolute/path/to/repo",
      runRoot: "/absolute/path/to/run-root"
    }
  }
});

Orchestrator only

import { createPiSubagents, createPiNativeRunner, createDefaultPiHostTools } from "pi-faithless-subagents";

const orchestrator = createPiSubagents({
  runner: createPiNativeRunner({
    piTools: createDefaultPiHostTools({ commandAllowlist: ["npm"] })
  })
});

Legacy OpenAI fallback

import { createPiSubagents, createPiToolBackedOpenAIRunner, createDefaultPiHostTools } from "pi-faithless-subagents";

const orchestrator = createPiSubagents({
  runner: createPiToolBackedOpenAIRunner({
    apiKey: process.env.OPENAI_API_KEY,
    piTools: createDefaultPiHostTools({ commandAllowlist: ["npm"] })
  })
});

Run artifacts

A run with id my-run writes to:

<runRoot>/my-run/

Important files:

  • events.log
  • steps/<stepId>/attempt-1/metadata.json
  • steps/<stepId>/attempt-1/output/<artifact-file>

Typical output files:

  • explorer: report.md
  • planner: plan.md
  • worker: implementation-report.md
  • reviewer: verdict.md

Main exports

  • createPiSubagents
  • createPiExtension
  • createPiNativeRunner
  • createOpenAIRunner
  • createPiToolBackedOpenAIRunner
  • createDefaultPiHostTools
  • PI_TOOL_DEFINITIONS
  • ROLE_POLICIES
  • SYSTEM_PROMPTS

Commands

npm run build
npm test
npm run check
npm run smoke
npm run smoke:pi
npm run smoke:workflow

Important source files

  • src/extension.ts — extension assembly and default runner selection
  • src/pi-runner.ts — PI-native step execution backend
  • src/openai.ts — legacy OpenAI runner
  • src/orchestrator.ts — workflow execution
  • src/pi-tools.ts — host tool adaptation and path enforcement
  • src/tools.ts — PI tool schemas and adapter
  • src/roles.ts — role reasoning and artifact policy
  • src/artifacts.ts — artifact templates and validation
  • src/policy.ts — workflow safety checks