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

@guyghost/swarm-dao-pi-adapter

v0.1.4

Published

Swarm DAO adapter for the Pi coding agent — multi-agent governance tools, commands, and event hooks

Downloads

539

Readme

@guyghost/swarm-dao-pi-adapter

Bridge Swarm DAO governance to the Pi Coding Agent.

This package exports a Pi extension that registers tools, commands, and event hooks so any Pi user can run multi-agent governance directly inside their coding session.

Installation

As a dependency

# Add the adapter and its peer dependencies
bun add @guyghost/swarm-dao-pi-adapter typebox
bun add --peer @earendil-works/pi-coding-agent @earendil-works/pi-ai

Register with Pi

Create or edit .pi/extensions/swarm-dao.ts in your project:

import swarmDaoExtension from "@guyghost/swarm-dao-pi-adapter";

export default swarmDaoExtension;

Alternatively, point Pi at the built file via package.json:

{
  "pi": {
    "extensions": ["./node_modules/@guyghost/swarm-dao-pi-adapter/dist/index.js"]
  }
}

Usage

Quick Start

Once Pi starts, the extension automatically:

  1. Restores state on session_start — loads .dao/ from your project root
  2. Injects context on before_agent_start — appends DAO status to the system prompt

Inside Pi, use any of the registered tools or the /dao command:

> dao_setup                           # Initialize with 7 default agents
> dao_propose title="Add dark mode"   # Create a proposal
  type="product-feature"
  description="Implement dark mode toggle"
> dao_deliberate proposalId=1         # Run swarm deliberation
> dao_check proposalId=1              # Quality control gates
> dao_ship proposalId=1               # Ship controlled proposal (check deps)

Tools

All tools are registered as MCP tools and can be invoked by the LLM or manually.

| Tool | Description | Key Parameters | |------|-------------|----------------| | dao_setup | Initialize the DAO with 7 default agents | useDefaults?: boolean | | dao_propose | Create a new governance proposal | title, type, description, context?, problemStatement?, acceptanceCriteria?, successMetrics?, rollbackConditions?, affectedPaths? | | dao_deliberate | Run swarm deliberation on a proposal | proposalId | | dao_check | Run quality control gates on an approved proposal | proposalId | | dao_plan | View the delivery plan for a proposal | proposalId | | dao_execute | Execute a controlled/approved proposal | proposalId | | dao_ship | Ship a controlled proposal, with optional dependency cascade | proposalId, cascade?, force? | | dao_audit | View the audit trail (optionally filtered by proposal) | proposalId? | | dao_artefacts | View auto-generated artefacts (ADR, risk report, PRD, etc.) | proposalId | | dao_rate | Rate a proposal outcome post-execution (1–5 stars) | proposalId, score, comment | | dao_dashboard | View outcome tracking dashboard and health score | (none) | | dao_dry_run | Preview execution without applying changes | proposalId | | dao_rollback | Revert a proposal to its pre-execution snapshot | proposalId | | dao_roundtable | Ask every agent to suggest a proposal idea | (none) | | dao_update_proposal | Update structured fields on an open proposal | proposalId, problemStatement?, acceptanceCriteria?, successMetrics?, rollbackConditions? |

Commands

| Command | Description | |---------|-------------| | /dao | Show the DAO dashboard (/dao or /dao status) | | /dao help | Show command help and the recommended next tools | | /dao setup | Initialize DAO directly from the slash command |

Event Hooks

| Event | When | What it does | |-------|------|--------------| | session_start | Pi session begins | Initializes .dao/ storage, loads or creates state | | before_agent_start | Before each LLM turn | Injects DAO status into the system prompt so the agent is context-aware |

Proposal Types

Proposals are categorized and routed through type-specific councils and quorum rules:

| Type | Label | Default Quorum | |------|-------|----------------| | product-feature | ✨ Product Feature | 60% | | security-change | 🔒 Security Change | 75% | | technical-change | ⚙️ Technical Change | 60% | | release-change | 📦 Release Change | 50% | | governance-change | 📜 Governance Change | 70% |

Architecture

The adapter bridges Pi to the Swarm DAO core's 4-layer governance model:

┌─────────────────────────────────────────────────────────┐
│  Pi Coding Agent                                        │
│  ┌─────────────────────────────────────────────────┐    │
│  │  swarm-dao-pi-adapter (this package)            │    │
│  │  • Registers tools, commands, event hooks       │    │
│  │  • Implements HostAdapter for Pi's agent runner │    │
│  └──────────────────────┬──────────────────────────┘    │
└─────────────────────────┼───────────────────────────────┘
                          │
┌─────────────────────────┼───────────────────────────────┐
│  @guyghost/swarm-dao-core                               │
│                                                         │
│  L1 Governance ── L2 Intelligence ── L3 Delivery        │
│  Proposals          Deliberation       Execution         │
│  Voting             Scoring            Plans             │
│  Lifecycle          Synthesis          Dry-run           │
│                      Round Table       Rollback          │
│                                                         │
│  L4 Control ─────────────────────────────────────────── │
│  Quality Gates · Audit Trail · Checklists               │
└─────────────────────────────────────────────────────────┘
                          │
┌─────────────────────────┼───────────────────────────────┐
│  Persistence (.dao/)                                    │
│  state.json · audit.json · scores.json · artefacts/     │
└─────────────────────────────────────────────────────────┘

Host Adapter

The adapter implements the HostAdapter interface from @guyghost/swarm-dao-core:

| Method | Pi Implementation | |--------|-------------------| | spawnAgent | Produces structured agent output (analysis, vote, score inputs) for deliberation and roundtable flows | | spawnAgents | Delegates to spawnAgent sequentially | | log | Writes to console.log with structured format | | getWorkingDirectory | Returns process.cwd() | | readFile | Uses node:fs/promises | | writeFile | Uses node:fs/promises | | exec | Uses node:child_process | | hasCapability | Reports read_file, write_file, exec, log |

Note on spawnAgent: The adapter now returns structured fallback outputs when host-level subprocess spawning is unavailable, so deliberation can still reach quorum and complete end-to-end.

Configuration

The DAO uses sensible defaults. To customize, modify .dao/state.json after initialization:

| Setting | Default | Description | |---------|---------|-------------| | quorumPercent | 60 | Minimum participation % | | approvalThreshold | 55 | Minimum approval % | | riskThreshold | 7 | Risk score threshold (1–10) | | maxConcurrent | 4 | Max agents running in parallel |

Development

# Install dependencies
bun install

# Build
cd packages/pi-adapter && bun run build

# Test
bun test

# Type-check only
bun run typecheck

License

MIT — see LICENSE.