Agent Skill
2/7/2026

pi-extensions

创建 pi 编码 Agent 扩展的完整指南。当用户需要创建 pi 扩展(Extensions)时使用,支持工具(Tools)、命令(Commands)、事件处理器(Event Handlers)和自定义 UI 组件的开发。通过读取 assets/templates/ 中的模板文件,根据用户需求生成扩展代码。

D
dwsy
12GitHub Stars
1Views
npx skills add Dwsy/agent

SKILL.md

Namepi-extensions
Description创建 pi 编码 Agent 扩展的完整指南。当用户需要创建 pi 扩展(Extensions)时使用,支持工具(Tools)、命令(Commands)、事件处理器(Event Handlers)和自定义 UI 组件的开发。通过读取 assets/templates/ 中的模板文件,根据用户需求生成扩展代码。

Pi Agent

Enterprise-grade AI coding agent system with modular architecture.

English | 中文


Overview

Pi Agent is an autonomous AI orchestrator for software development — a monorepo containing the agent core, a multi-channel gateway, 40+ skills, 30+ extensions, and 20+ specialized subagents.

  • 5-Phase Workflow: Context retrieval → Analysis → Prototyping → Implementation → Audit
  • Multi-Model Orchestration: Claude, Gemini, and specialized tool routing
  • Multi-Channel Gateway: Telegram, Discord, WebChat via single-port HTTP+WS server
  • Plugin Architecture: Skills (prompt injection), Extensions (runtime hooks), Agents (task delegation)
  • Enterprise Protocols: Code sovereignty, sandbox security, SSOT documentation

Prerequisites

Quick Start

# Clone with submodules
git clone --recurse-submodules <repo-url> ~/.pi/agent

# Use workflow commands in any project
/scout authentication flow      # Fast code reconnaissance
/analyze database schema        # Deep analysis
/brainstorm caching strategy    # Design exploration

# Start the multi-channel gateway
cd ~/.pi/agent/pi-gateway && bun install && bun run start

Project Structure

~/.pi/agent/
├── pi-gateway/            # Multi-channel AI gateway (Telegram/Discord/WebChat)
├── extensions/            # Runtime extensions (30 modules)
│   ├── pi-interactive-shell/  # Interactive CLI overlay (vim, psql, ssh)
│   ├── pi-subagents/          # Multi-agent chains & parallel execution
│   ├── plan-mode/             # Read-only planning with command interception
│   ├── role-persona/          # Per-role memory & personality isolation
│   ├── games/                 # Mini-games (Snake, Tetris, 2048, Minesweeper)
│   ├── answer.ts              # Interactive Q&A TUI (Ctrl+.)
│   ├── workflow-commands.ts   # /scout, /analyze, /brainstorm, /research
│   ├── safety-gates.ts        # Destructive operation interception
│   └── ...
├── skills/                # Prompt-injectable capabilities (40 modules)
│   ├── ace-tool/              # Semantic code search (AugmentCode MCP)
│   ├── web-browser/           # Chromium automation (CDP)
│   ├── tmux/                  # Remote terminal session control
│   ├── workhub/               # Issue/PR documentation management
│   ├── office-combo/          # Excel, PPT, PDF, Word support
│   └── ...
├── agents/                # Subagent definitions (20+ markdown specs)
├── prompts/               # Workflow templates (init, handoff, implement, etc.)
├── roles/                 # Role-based persona configurations
├── commands/              # Slash command definitions (/scout, /analyze, etc.)
├── messenger/             # Inter-agent session registry & event feed
├── landing-page/          # Marketing site (Vite + Lit + Tailwind)
├── docs/                  # System protocols, guides, knowledge base
├── APPEND_SYSTEM.md       # Agent system prompt
├── settings.json          # Agent runtime settings
├── models.json            # Model provider configurations
└── auth.json              # Authentication credentials

Pi Gateway

Single-port HTTP+WebSocket gateway that routes messages from Telegram, Discord, and WebChat into isolated pi agent RPC processes.

cd pi-gateway
bun install
bun run start                    # Start gateway (default port 18800)
bun run dev                      # Start with hot-reload
bun run src/cli.ts doctor        # Health check
bun run src/cli.ts config show   # Show current config

Key capabilities:

  • 3 built-in channels: Telegram (polling/webhook, multi-account, media), Discord (slash commands), WebChat (browser UI)
  • RPC process pool: Min/max scaling, capability-based matching, idle eviction
  • Session routing: agent:{agentId}:{channel}:{scope}:{id} key format with role mapping
  • Plugin system: 14 lifecycle hooks, register channels/tools/HTTP routes/WS methods/commands/services
  • Cron & Heartbeat: Scheduled jobs (cron/every/at), periodic agent wake-up
  • Media pipeline: Receive/send images with HMAC-SHA256 signed URLs
  • OpenAI-compatible API: /v1/chat/completions endpoint
  • Config: pi-gateway.jsonc with JSON5 support, deep merge, hot-reload

→ Architecture docs

Extensions

Runtime hooks that enhance the agent's UI, commands, and behavior. → Details

ExtensionDescription
pi-interactive-shell/Run interactive CLIs (vim, psql, ssh) in TUI overlay — interactive/hands-free/dispatch modes
pi-subagents/Multi-agent orchestration: chains, parallel execution, skill injection, async support
plan-mode/Read-only planning mode with 40+ dangerous command interception
role-persona/Per-role isolated memory, personality, workspace context
games/Game framework: Snake, Tetris, 2048, Minesweeper, Breakout, Pong
answer.tsInteractive Q&A TUI (Ctrl+.)
qna.tsEditor Q&A extraction (Ctrl+,)
continue.tsQuick continue dialog (Ctrl+Option+C)
handoff.tsContext handoff to new session
git-commit.tsAuto git commit with message generation
workflow-commands.ts/scout, /analyze, /brainstorm, /research commands
safety-gates.tsSafety checks before destructive operations
knowledge-builder/Knowledge base construction
token-rate.tsToken usage rate tracking

Skills

Prompt-injectable capabilities — each skill is a SKILL.md file injected into the agent's system prompt at runtime.

CategorySkillDescription
Code Searchace-toolSemantic fuzzy search via AugmentCode MCP
ast-grepAST-aware code search and rewrite
codemapCode flow visualization and mapping
DocumentationworkhubIssue/PR documentation management
deepwikiGitHub repository documentation & Q&A
context7Library documentation retrieval
knowledge-baseKnowledge management system
Web & Searchtavily-search-freeReal-time web search
exaHigh-quality web search
web-browserChromium automation (navigation, forms, network, PDF)
Dev ToolstmuxRemote terminal session control (CLI/TUI modes)
project-plannerProject planning & documentation
system-designArchitecture design (EventStorming)
coding-runnerCode execution sandbox
Generatorsoffice-comboExcel, PPT, PDF, Word support
har-to-vueConvert HAR network captures to Vue code
svg-logo-generatorGenerate SVG logos
mcp-to-skillWrap any MCP server as a pi skill
Best Practicesreact-best-practicesReact patterns and conventions
vue-best-practicesVue patterns and conventions
vercel-designVercel design system patterns

Agents

Specialized subagents defined as markdown files with YAML frontmatter. → Examples

AgentModePurpose
scoutREAD-ONLYFast code reconnaissance via semantic search + grep
plannerPLANNING5-phase task planning (discovery → design → review → plan → approval)
workerSTANDARDFull-capability implementation with TODO enforcement
reviewerREAD-ONLYCode quality & security analysis via git diff
brainstormerSTANDARDDesign exploration and ideation
visionSTANDARDMultimodal analysis (images, video, PDF, UI/UX, diagrams)
security-reviewerREAD-ONLYSecurity audit
simplifierSTANDARDCode simplification
system-designSTANDARDArchitecture design

Messenger

Inter-agent session registry and event feed for multi-agent coordination.

  • messenger/registry/ — JSON metadata per agent (PID, session, model, activity)
  • messenger/feed.jsonl — JSONL event log (messages, test results, agent activities)
  • messenger/inbox/ — Per-agent message directories

Roles

Role-based persona system mapping project paths to agent identities.

  • roles/config.json — Path-to-role mapping (e.g., ~/.pi/agent → "zero")
  • roles/default/ — Default role configuration
  • Each role can have isolated memory, personality, and workspace context (via role-persona extension)

Core Workflow

graph LR
    A[Phase 1: Context Retrieval] --> B[Phase 2: Analysis]
    B --> C[Phase 3: Prototyping]
    C --> D[Phase 4: Implementation]
    D --> E[Phase 5: Audit]
PhaseStatusToolsOutput
1. Context RetrievalMandatoryace-tool, ast-grep, rgComplete code definitions
2. Analysis & PlanningComplex tasksGeminiStep-by-step plan + pseudocode
3. PrototypingMandatoryGemini → Unified DiffDiff only, no file writes
4. ImplementationMandatoryClaudeProduction code, minimal scope
5. Audit & DeliveryMandatoryCodex/GeminiReviewed, delivered

Workflow Commands

CommandAgentPurpose
/scout <query>scoutFast code reconnaissance
/analyze <topic>workerDeep code analysis
/brainstorm <idea>brainstormerDesign exploration
/research <topic>multi-toolParallel research

Design Principles

  1. Code Sovereignty — External AI code is reference only; must refactor to production quality via Unified Diff Patch
  2. Sandbox Security — External models cannot write directly; human-in-the-loop for all modifications
  3. SSOT — One authoritative source per knowledge domain; reference over copy; filesystem as memory
  4. Token Efficiency — Information-dense docs; reference links over duplication; context holds paths, files hold content

Configuration

FilePurpose
APPEND_SYSTEM.mdAgent system prompt (instructions & protocols)
settings.jsonRuntime settings (provider, thinking level, packages, extensions)
models.jsonModel provider configurations
auth.jsonAuthentication credentials
roles/config.jsonRole-to-path mapping
pi-gateway/pi-gateway.jsoncGateway config (port, channels, plugins, cron)

See Also

License

MIT

Skills Info
Original Name:pi-extensionsAuthor:dwsy