Update pi-agent skill

This commit is contained in:
Timothy Kassis committed 2026-06-10 14:43:26 -07:00
1 parent 3b73388d4d
commit d995f2ac25
6 files changed
+421 -3

No files matched your search

+7 -3
View File
@@ -1,10 +1,10 @@
---
name: pi-agent
description: Build with and use Pi, the minimal terminal coding harness. Use for installing Pi, configuring providers/models/settings, creating Pi skills/extensions/packages/themes/prompt templates, embedding Pi through the SDK, integrating over RPC or JSON event streams, parsing sessions, or developing custom Pi providers and TUI components.
description: Build with and use Pi, the minimal terminal coding harness. Use for installing Pi, configuring providers/models/settings, creating Pi skills/extensions/packages/themes/prompt templates, embedding Pi through the SDK, integrating over RPC or JSON event streams, parsing sessions, developing custom Pi providers and TUI components, or using ecosystem packages such as pi-subagents (delegation/orchestration), pi-mcp-adapter (MCP servers), pi-interview (interactive forms), and pi-web-access (web search, fetching, video understanding).
license: MIT
compatibility: Requires Node.js/npm for Pi CLI and SDK usage. Pi package name is @earendil-works/pi-coding-agent.
metadata:
version: "1.0"
version: "1.1"
skill-author: K-Dense Inc.
---
@@ -29,6 +29,10 @@ Pick the reference before answering or coding:
| Consume JSONL event output | `references/json.md` |
| Build terminal UI components | `references/tui.md` |
| Package extensions/skills/prompts/themes | `references/packages.md` |
| Delegate to subagents, chains, parallel runs, orchestration | `references/pi-subagents.md` |
| Connect MCP servers, MCP tool discovery/config | `references/pi-mcp-adapter.md` |
| Interactive interview forms, structured user input | `references/pi-interview.md` |
| Web search, URL/PDF/repo fetching, video understanding | `references/pi-web-access.md` |
| Author Pi skills | `references/skills.md` |
| Prompt templates or themes | `references/prompt-templates.md`, `references/themes.md` |
| Sessions, branching, compaction, parsing JSONL | `references/sessions.md`, `references/compaction.md`, `references/session-format.md` |
@@ -68,4 +72,4 @@ pi --tools read,grep,find,ls -p "Review this repository"
## Source Coverage
These references summarize the Pi documentation at `https://pi.dev/docs/latest` and each docs page found under it as of this skill version. When exact API behavior matters, prefer the cited reference page and inspect installed TypeScript definitions under `node_modules/@earendil-works/pi-coding-agent/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.
These references summarize the Pi documentation at `https://pi.dev/docs/latest` and each docs page found under it as of this skill version, plus the package pages for `pi-subagents`, `pi-mcp-adapter`, `pi-interview`, and `pi-web-access` at `https://pi.dev/packages/`. When exact API behavior matters, prefer the cited reference page and inspect installed TypeScript definitions under `node_modules/@earendil-works/pi-coding-agent/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.
+8
View File
@@ -56,6 +56,14 @@ Runtime deps belong in `dependencies`. Pi bundles core packages for extensions/s
Object settings can include/exclude resources with globs, `!pattern`, exact `+path`, exact `-path`, or `[]` to load none for a resource type.
## Notable Ecosystem Packages
- `pi install npm:pi-subagents` — delegate to child agents, chains, parallel runs: `references/pi-subagents.md`
- `pi install npm:pi-mcp-adapter` — token-efficient MCP server access: `references/pi-mcp-adapter.md`
- `pi install npm:pi-interview` — interactive interview forms for structured user input: `references/pi-interview.md`
- `pi install npm:pi-web-access` — web search, URL/PDF/repo fetching, video understanding: `references/pi-web-access.md`
- `pi install npm:pi-intercom` — child-to-parent coordination companion for pi-subagents
## Security
Packages run with full system access. Review third-party package code before installing.
@@ -0,0 +1,85 @@
# pi-interview Package
Source: https://pi.dev/packages/pi-interview
Interactive interview form extension: the agent collects structured user responses through forms with single/multi-select, text input, image upload, and info panels, plus rich media (code, diffs, Markdown, images, Chart.js charts, Mermaid diagrams, tables, HTML). Requires pi-agent v0.35.0+.
```bash
pi install npm:pi-interview
pi install npm:glimpseui # optional: native macOS windows (browser fallback otherwise)
```
## Invocation
Agents call the tool directly:
```javascript
await interview({
questions: '/path/to/questions.json',
timeout: 600, // optional, seconds
verbose: false // optional, debug logging
});
```
## Question Schema
```json
{
"title": "Project Setup",
"description": "Review my suggestions and adjust as needed.",
"questions": [
{ "id": "context", "type": "info", "question": "Architecture context", "context": "This project needs SSR and edge deployment support." },
{ "id": "framework", "type": "single", "question": "Which framework?",
"options": ["React", "Vue", "Svelte"],
"recommended": "React", "conviction": "strong", "weight": "critical" }
]
}
```
Question types: `single` (radio), `multi` (checkbox), `text`, `image` (upload), `info` (non-interactive panel).
| Field | Purpose |
|---|---|
| `id`, `type`, `question` | Identifier, type, question text |
| `options` | Choices for single/multi; strings or `{ label, content }` objects |
| `recommended` | Pre-selected option(s) with badge |
| `conviction` | `"strong"` or `"slight"` — controls pre-selection |
| `weight` | `"critical"` or `"minor"` — visual prominence |
| `context` | Help text |
| `content` | Code/diff/Markdown block: `{ source, lang, file, lines, highlights, showSource }`; `lang: "diff"` renders diffs, `lang: "md"` renders Markdown preview |
| `media` | Object or array: types `image`, `table`, `chart`, `mermaid`, `html`; each supports `position`: `"above"`/`"below"`/`"side"` and `caption`; tables take `{ headers, rows, highlights }` |
## Response Format
```typescript
interface Response { id: string; value: string | string[]; attachments?: string[]; }
```
## Settings
`~/.pi/agent/settings.json`:
```json
{
"interview": {
"timeout": 600,
"port": 19847,
"snapshotDir": "~/.pi/interview-snapshots/",
"autoSaveOnSubmit": true,
"generateModel": "anthropic/claude-haiku-4-5",
"theme": { "mode": "auto", "name": "default", "lightPath": "/path/to/light.css", "darkPath": "/path/to/dark.css", "toggleHotkey": "mod+shift+l" }
}
}
```
Timeout precedence: function parameter > settings > default 600s. Built-in themes: `default` (monospace) and `tufte` (serif); modes `dark` (default), `light`, `auto`. Custom themes are CSS files overriding variables like `--bg-body`, `--bg-card`, `--accent`, `--error`.
## Recovery and Snapshots
Abandoned/timed-out interviews save to `~/.pi/interview-recovery/{date}_{time}_{project}_{branch}_{sessionId}.json` (auto-deleted after 7 days). Submissions can auto-save snapshots (`index.html` + `images/`) to `~/.pi/interview-snapshots/`. Resume either by passing the recovery JSON or snapshot `index.html` path as `questions`.
## Keyboard and Limits
`↑`/`↓` navigate options, `⌘+←`/`⌘+→` navigate questions (Ctrl on non-macOS), `Tab` cycles, `Enter`/`Space` selects, `⌘+Enter` submits, `Esc` twice quits, `⌘+Shift+L` toggles theme. Auto-saves via localStorage; detects multi-agent queues.
Image limits: max 12 per submission, 5MB each, 4096×4096 px, PNG/JPG/GIF/WebP.
@@ -0,0 +1,84 @@
# pi-mcp-adapter Package
Source: https://pi.dev/packages/pi-mcp-adapter
MCP adapter extension for Pi. Instead of loading hundreds of MCP tool definitions upfront (10,000+ tokens per server), it exposes one `mcp` proxy tool (~200 tokens) that discovers and calls tools on demand. Servers connect lazily and disconnect when idle.
```bash
pi install npm:pi-mcp-adapter
```
Restart Pi after installation.
## Configuration Files
Precedence (highest to lowest):
1. `~/.config/mcp/mcp.json` — user-global shared config
2. `<Pi agent dir>/mcp.json` — Pi global override
3. `.mcp.json` — project-local shared config
4. `.pi/mcp.json` — Pi project override
```json
{
"mcpServers": {
"chrome-devtools": { "command": "npx", "args": ["-y", "chrome-devtools-mcp@latest"] }
}
}
```
Import existing configs with `"imports": ["cursor", "claude-code", "claude-desktop"]` (also `vscode`, `windsurf`, `codex`).
## Server Options
| Field | Description |
|---|---|
| `command`, `args`, `env`, `cwd` | stdio transport; `env`/`cwd` support `${VAR}`, `$env:VAR`, `~` |
| `url`, `headers` | HTTP endpoint (StreamableHTTP with SSE fallback); headers support interpolation |
| `auth` | `"bearer"` or `"oauth"` |
| `oauth` | `{ grantType, clientId, clientSecret, scope, redirectUri }` |
| `lifecycle` | `"lazy"` (default: connect on first call, idle disconnect), `"eager"` (connect at startup), `"keep-alive"` (startup + health checks + auto-reconnect) |
| `idleTimeout` | Minutes before idle disconnect (default 10) |
| `exposeResources` | Expose MCP resources as tools (default true) |
| `directTools` | `true`, `string[]`, or `false` — register tools directly instead of via proxy |
| `excludeTools` | Tool names to hide |
| `debug` | Show server stderr (default false) |
Global `settings` block: `toolPrefix`, `idleTimeout`, `directTools`, `disableProxyTool`, `autoAuth`, `sampling`, `samplingAutoApprove`, `elicitation`, `elicitationAutoOpenUrls`.
Direct tools cost 150–300 tokens each; use for 5–20 targeted tools, the proxy for everything else:
```json
{ "mcpServers": { "github": { "directTools": ["search_repositories", "get_file_contents"] } } }
```
## Proxy Tool API
```javascript
mcp({ }) // list servers
mcp({ server: "name" }) // server details
mcp({ search: "screenshot navigate" }) // search tools
mcp({ describe: "tool_name" }) // tool description
mcp({ tool: "chrome_devtools_take_screenshot", args: '{"format": "png"}' }) // call; args is a JSON string
mcp({ connect: "server-name" })
mcp({ action: "ui-messages" }) // retrieve MCP UI messages
```
## CLI Commands
```
/mcp # interactive panel and first-run setup
/mcp setup # guided imports and config
/mcp tools # list all available tools
/mcp reconnect [server]
/mcp logout <server> # clear OAuth credentials
/mcp-auth [server] # OAuth setup picker
```
## Behavior Notes
Tool metadata is cached to disk so search/describe work offline. npx-based servers resolve to direct binaries to skip npm overhead. MCP UI–capable tools open in a native macOS window via Glimpse (if installed) or a browser fallback; UI message types `prompt`, `intent`, `notify`, `message` are retrievable via `mcp({ action: "ui-messages" })`.
Limitations: no cross-session server sharing; MCP sampling is text-only (context, tools, audio, images rejected).
Subagents (`pi-subagents`) only receive direct MCP tools when listed in their `tools:` frontmatter with an `mcp:` prefix — see `references/pi-subagents.md`.
+134
View File
@@ -0,0 +1,134 @@
# pi-subagents Package
Source: https://pi.dev/packages/pi-subagents
Extension for delegating tasks to focused child agents with sequential chains, parallel execution, dynamic fanout, worktree isolation, and acceptance gates.
```bash
pi install npm:pi-subagents
```
## Built-in Agents
| Agent | Purpose |
|---|---|
| `scout` | Fast local codebase recon: files, entry points, data flow, risks |
| `researcher` | Web/docs research with sources and a concise brief |
| `planner` | Concrete implementation plan from existing context |
| `worker` | Implementation: file editing and validation |
| `reviewer` | Code review and small fixes against task/plan |
| `context-builder` | Setup pass gathering code context and handoff material |
| `oracle` | Second opinion challenging assumptions; no edits |
| `delegate` | Lightweight general delegate close to parent behavior |
Packaged `planner`, `worker`, `oracle` default to `context: "fork"` (branch from parent session state); others default to `fresh`.
## Commands
```bash
/run <agent> [task] # single agent; --bg detached, --fork branch session
/run reviewer[model=anthropic/claude-sonnet-4] summarize this code
/chain scout "scan the codebase" -> planner "create an implementation plan"
/parallel scanner "find security issues" -> reviewer "check code style"
/run-chain <chainName> -- <task> # saved workflow
/subagents-doctor # setup diagnostics
```
Per-step config uses `[key=value,...]` on the agent name: `output=file.md`, `outputMode=file-only|inline`, `reads=a.md+b.md`, `model=...`, `skills=a+b`, `thinking=high`, `progress`.
Natural language also works: "Use reviewer to review this diff", "Run parallel reviewers: one for correctness, one for tests".
Packaged prompt shortcuts: `/parallel-review`, `/review-loop`, `/parallel-research`, `/parallel-context-build`, `/parallel-handoff-plan`, `/gather-context-and-clarify`, `/parallel-cleanup` (add `autofix` to apply synthesized fixes).
## Programmatic API (subagent tool)
```javascript
{ agent: "worker", task: "refactor auth" }
{ tasks: [{ agent: "scout", task: "audit frontend" }, { agent: "reviewer", task: "audit backend" }] } // parallel; count: N duplicates a task
{ chain: [{ agent: "scout", task: "Gather context" }, { agent: "planner" }, { agent: "worker" }, { agent: "reviewer" }] }
{ chain: [...], timeoutMs: 30000 }
{ agent: "worker", task: "...", maxRuntimeMs: 600000 }
{ action: "list" | "get" | "create" | "update" | "delete" | "status" | "interrupt" | "resume" | "doctor" }
{ action: "resume", id: "<run-id>", message: "follow-up" }
```
Key parameters: `output` (file or `false`), `outputMode` (`inline`/`file-only`), `skill` (string/array/`false`), `model`, `concurrency` (default 4), `worktree`, `context` (`fresh`/`fork`), `chainDir`, `clarify` (default true for chains), `async`, `cwd`, `maxOutput` (default 200KB/5000 lines), `share` (Gist upload, off by default), `acceptance`.
Dynamic fanout: a chain step with `expand: { from: { output: "name", path: "/items" }, item: "target", maxItems: N }` plus `parallel: { agent, task: "Review {target.path}" }` and `collect: { as: "reviews" }` fans out over a prior step's structured output (`as` + `outputSchema`).
## Agent Definition Files
Markdown with YAML frontmatter. Precedence: project `.pi/agents/**/*.md` > user `~/.pi/agent/agents/**/*.md` > builtin.
```yaml
---
name: scout
description: Fast codebase recon
model: claude-haiku-4-5
fallbackModels: openai/gpt-5-mini, anthropic/claude-sonnet-4
thinking: high
tools: read, grep, find, ls, bash # allowlist; mcp: prefix for direct MCP tools
extensions: mcp:chrome-devtools # omitted = all; empty = none
skills: safe-bash
systemPromptMode: replace # or append
inheritProjectContext: false
inheritSkills: false
defaultContext: fork # or fresh
output: context.md
defaultReads: context.md
defaultProgress: true
completionGuard: false # false for non-implementation validators
interactive: true
maxSubagentDepth: 1
maxExecutionTimeMs: 600000
maxTokens: 50000
---
Your system prompt goes here.
```
Subagents only receive direct MCP tools when listed in `tools:` frontmatter (requires `pi-mcp-adapter`); a global `directTools: true` is insufficient.
## Chain Files
Reusable workflows: project `.pi/chains/**/*.chain.md|.chain.json` > user `~/.pi/agent/chains/`. Markdown chains use `## agent` headings with per-step keys (`phase`, `label`, `as`, `output`, `outputMode`, `reads`, `model`, `skills`, `progress`, `outputSchema`) and a task body. Template variables: `{task}`, `{previous}`, `{chain_dir}`, `{outputs.name}`.
## Configuration
Builtin agent overrides in `~/.pi/agent/settings.json` or `.pi/settings.json`:
```json
{ "subagents": { "agentOverrides": { "reviewer": { "model": "anthropic/claude-sonnet-4", "thinking": "high" } }, "disableBuiltins": false } }
```
Override fields: `model`, `fallbackModels`, `thinking`, `systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `defaultContext`, `disabled`, `skills`, `tools`, `systemPrompt`.
Extension config at `~/.pi/agent/extensions/subagent/config.json`: `asyncByDefault`, `forceTopLevelAsync`, `parallel: { maxTasks, concurrency }`, `defaultSessionDir`, `maxSubagentDepth`, `intercomBridge: { mode: "always"|"fork-only"|"off", instructionFile }`, `worktreeSetupHook` (+ `worktreeSetupHookTimeoutMs`; hook gets stdin JSON with repo/worktree paths and must print `{ "syntheticPaths": [...] }`).
Nesting depth defaults to 2 levels; tighten/relax via `PI_SUBAGENT_MAX_DEPTH` env var, config `maxSubagentDepth`, or per-agent frontmatter (per-agent can only tighten). Children never get the `subagent` tool unless their resolved tools explicitly include it.
## Worktree Isolation
`worktree: true` on parallel tasks or chain steps runs each agent in an isolated git worktree. Requires a git repo with a clean working tree; `node_modules/` is symlinked in; task-level `cwd` overrides must match the shared cwd.
## Acceptance Gates
Attach explicit contracts to any run/step:
```javascript
{ agent: "worker", task: "Implement the fix", acceptance: {
criteria: ["Patch the bug without widening scope"],
evidence: ["changed-files", "tests-added", "commands-run", "residual-risks", "no-staged-files"],
verify: [{ id: "focused", command: "npm test", timeoutMs: 120000 }],
maxFinalizationTurns: 3
} }
```
Provenance levels reported: `attested`, `checked`, `verified`, `reviewed`, `rejected`.
## Async, Clarify, Observability
`--bg` / `async: true` detaches runs; status files under `<tmpdir>/pi-subagents-<scope>/async-subagent-runs/<id>/` (`status.json`, `events.jsonl`, logs). Chains open a clarify TUI by default to preview/edit steps (`e` edit, `m` model, `t` thinking, `s` skills, `b` background, `Enter` run, `Esc` cancel). Debug artifacts land in `{sessionDir}/subagent-artifacts/` with input/output/jsonl/meta per run; chain artifacts in `<tmpdir>/pi-subagents-<scope>/chain-runs/{runId}/`. Directories older than 24h are cleaned on startup. Events: `subagent:async-started`, `subagent:async-complete`, `subagent:control-intercom`, `subagent:result-intercom`.
Optional companion `pi install npm:pi-intercom` lets children call `contact_supervisor` (reasons: `need_decision`, `progress_update`) and groups completion delivery back to the parent.
Recommended implementation pattern: clarify → planner → worker → fresh reviewers → worker.
+103
View File
@@ -0,0 +1,103 @@
# pi-web-access Package
Source: https://pi.dev/packages/pi-web-access
Extension adding web search, URL fetching, GitHub repo cloning, PDF extraction, YouTube video understanding, and local video analysis to Pi.
```bash
pi install npm:pi-web-access
```
Works immediately without API keys via Exa MCP. Optional: `brew install ffmpeg yt-dlp` for video frame extraction.
## Tools
### web_search
Searches via Exa, Perplexity, or Gemini with synthesized answers and citations.
```javascript
web_search({ query: "TypeScript best practices 2025" })
web_search({ queries: ["query 1", "query 2"] })
web_search({ query: "latest news", numResults: 10, recencyFilter: "week" })
web_search({ query: "...", domainFilter: ["github.com"], provider: "exa" })
```
Parameters: `query`/`queries`, `numResults`, `recencyFilter` (day/week/month/year), `domainFilter`, `provider` (auto/exa/perplexity/gemini), `includeContent`, `workflow`.
### code_search
Code examples and API references; no API key required.
```javascript
code_search({ query: "React useEffect cleanup pattern" })
code_search({ query: "Express middleware error handling", maxTokens: 10000 })
```
### fetch_content
Readable content from URLs, GitHub repos, YouTube videos, PDFs, and local video files.
```javascript
fetch_content({ url: "https://example.com/article" })
fetch_content({ urls: ["url1", "url2", "url3"] })
fetch_content({ url: "https://github.com/owner/repo" })
fetch_content({ url: "https://youtube.com/watch?v=abc", prompt: "What libraries are shown?" })
fetch_content({ url: "/path/to/recording.mp4", prompt: "What error appears on screen?" })
fetch_content({ url: "https://youtube.com/watch?v=abc", timestamp: "23:41-25:00", frames: 4 })
```
Parameters: `url`/`urls`, `prompt`, `timestamp`, `frames` (max 12), `forceClone`.
### get_search_content
Stored content from previous searches (for content beyond the 30,000-character inline limit): `get_search_content({ responseId: "abc123", urlIndex: 0 })` or `{ responseId, url }`.
## Capabilities
- **GitHub repos**: cloned locally for real file contents — root URLs return tree + README, `/tree/` paths list directories, `/blob/` paths show files; repos over 350MB get lightweight API-based views.
- **YouTube**: visual descriptions, timestamped transcripts, chapter markers via Gemini.
- **Local video**: MP4/MOV/WebM/AVI up to 50MB via Gemini; frame extraction at timestamps with ffmpeg.
- **PDFs**: text extraction saved to `~/Downloads/` as markdown (no OCR).
- **Blocked pages**: automatic retry via Jina Reader, then Gemini URL Context API, for JS-heavy and anti-bot sites.
## CLI Commands
```
/websearch [queries] # open curator; pre-fill comma-separated queries
/curator # toggle curator workflow
/curator on|off|summary-review # configure curator mode
/search # browse stored results interactively
/google-account # display active Google account
```
`Ctrl+Shift+W` toggles an activity monitor with live request/response data.
## Configuration
All settings in `~/.pi/web-search.json` are optional. Env vars `EXA_API_KEY`, `GEMINI_API_KEY`, `PERPLEXITY_API_KEY` take precedence over the file.
```json
{
"exaApiKey": "exa-...",
"perplexityApiKey": "pplx-...",
"geminiApiKey": "AIza...",
"provider": "exa",
"chromeProfile": "Profile 2",
"allowBrowserCookies": false,
"searchModel": "gemini-2.5-flash",
"summaryModel": "anthropic/claude-haiku-4-5",
"workflow": "summary-review",
"curatorTimeoutSeconds": 20,
"githubClone": { "enabled": true, "maxRepoSizeMB": 350, "cloneTimeoutSeconds": 30, "clonePath": "/tmp/pi-github-repos" },
"youtube": { "enabled": true, "preferredModel": "gemini-3-flash-preview" },
"video": { "enabled": true, "preferredModel": "gemini-3-flash-preview", "maxSizeMB": 50 },
"shortcuts": { "curate": "ctrl+shift+s", "activity": "ctrl+shift+w" }
}
```
Bundled skill `librarian` combines GitHub cloning, web search, and git operations for evidence-backed library investigation with permalink citations.
## Limitations
Chromium cookie extraction requires opt-in (`allowBrowserCookies: true`); age-restricted/private YouTube videos may fail; Gemini handles videos up to ~1 hour; non-code GitHub URLs fall through to standard web extraction.