pi-package
Pi package development best practices and patterns. Use when planning, editing, implementing, or reviewing pi package code — structuring a new package, writing extensions, registering tools, commands, events, skills, prompt templates, or themes. Also use when the user asks about package architecture, conventions, or "how should I implement" a pi package feature. Do not use for general TypeScript development unrelated to pi packages, or for running tests (use pi-test skill if it exists).
- License 许可
- MIT
- 最近更新
- 2026-05-17
- Stars
- ★ 5
- Forks
- 1
01 前言 Front Matter
- name
- pi-package
- description
- Pi package development best practices and patterns. Use when planning, editing, implementing, or reviewing pi package code — structuring a new package, writing extensions, registering tools, commands, events, skills, prompt templates, or themes. Also use when the user asks about package architecture, conventions, or "how should I implement" a pi package feature. Do not use for general TypeScript development unrelated to pi packages, or for running tests (use pi-test skill if it exists).
02 资源文件 5
- 参考文档references/EXTENSIONS.md21.2 KB
- 参考文档references/PROMPTS.md2.4 KB
- 参考文档references/SCHEMAS.md5.8 KB
- 参考文档references/SKILLS.md4.3 KB
- 参考文档references/THEMES.md4.7 KB
03 SKILL.md 正文
Pi Package Development
This skill provides patterns and best practices for building pi packages. Read the reference files below on demand based on the current task.
Official Pi Documentation
For the complete and authoritative API reference, read pi's installed docs. Locate them with:
# Find the docs directory
npm root -g # → <dir>/@earendil-works/pi-coding-agent/docs/
Key documents (relative to that directory):
| Doc | Contents |
|---|---|
extensions.md |
Full extension API: events, tools, commands, providers, rendering |
tui.md |
TUI component API for custom UI |
skills.md |
Skill authoring and the Agent Skills standard |
themes.md |
Theme format and all color tokens |
keybindings.md |
Keybinding IDs and shortcut registration |
packages.md |
Package distribution and manifest |
session-format.md |
SessionManager API and entry types |
compaction.md |
Custom compaction handlers |
custom-provider.md |
Advanced provider topics, OAuth, custom streaming |
models.md |
Model configuration |
rpc.md |
RPC mode and extension UI protocol |
When in doubt about an API, read the official doc first — it is the source of truth.
Reference Files
Read these on demand based on the task. Do NOT load all at once. Each file has a table of contents at the top for navigation.
references/EXTENSIONS.md
Complete patterns for every extension capability.
- Extension Structure & Factory
- Custom Tools (registration, rendering, state, truncation)
- Slash Commands (registration, autocomplete, argument handling)
- Event Handlers (lifecycle, session, agent, tool, input events)
- User Interaction (dialogs, notifications, status, widgets)
- Custom UI Components (TUI, overlay, custom editor)
- State Management (session persistence, reconstruction)
- Custom Rendering (tool call/result, message renderers)
- Remote Execution (SSH, tool operations)
- Providers (custom models, OAuth)
- Anti-Patterns
references/SCHEMAS.md
Typebox schema patterns for tool parameters.
- Quick Start (minimum schemas every tool needs)
- Primitive Types
- String Enums (Google-compatible)
- Object & Nested Schemas
- Arrays & Tuples
- Optional Fields & Defaults
- Description Best Practices
- Reusable Sub-schemas
- Empty Parameters
- Common Parameter Patterns (paths, file patterns, modes)
references/THEMES.md
Theme creation reference with all 51 color tokens.
- Theme Structure (vars, colors, schema)
- Color Tokens Reference (core UI, backgrounds, markdown, diffs, syntax, thinking)
- Color Values (hex, 256-color, variables, default)
- Theme Creation Workflow
- Testing Themes
references/SKILLS.md
Skill authoring patterns for the Agent Skills standard.
- Skill Structure (SKILL.md, references, scripts, assets)
- Frontmatter (name, description, allowed-tools, disable-model-invocation)
- Progressive Disclosure Pattern
- Skill Naming & Triggering
- Reference File Organization
- Skills in Packages
references/PROMPTS.md
Prompt template authoring.
- Prompt Template Format (frontmatter, content)
- Template Variables
- Prompt Placement & Discovery
Working with existing packages
When modifying an existing package:
- Read the existing code first — match the project's conventions
- Check
AGENTS.mdfor project-specific rules - Read
package.jsonto understand thepimanifest and dependencies - Look at existing extensions/skills to match patterns
File locations in this project
- Extension source:
extensions/index.ts - Skills:
skills/ - Prompt templates:
prompts/ - Themes:
themes/ - Package manifest:
package.json
04 同仓库更多 Skills
hello
暂无简介
pi-test
Test pi package TUI components using pilotty for PTY-based terminal automation. Use when the user wants to test, verify, or validate TUI components built with pi-tui in their pi package — interactive selectors, overlays, dialogs, custom editors, status indicators, or any ctx.ui.custom() output. Also use when the user says "test the TUI", "verify the UI renders", "check my component", "run pilotty", "test my extension's UI", or asks about TUI testing strategies for pi packages. Do not use for unit testing non-TUI code, linting, type checking, or testing tools that only return text without rendering a TUI.
pi-init
Initialize a pi package project after cloning from pi-package-template. Run once at the start of development to verify the development environment is set up correctly. Use when the user says "init", "setup", "initialize", "check environment", "pi-init", or asks to verify their pi package development setup. Also use when the user says they just cloned the template or wants to start developing a pi package. Do not use for general pi package development tasks (use pi-package) or for running tests.