Skip to main content

pi

# 安装
bun add -g @earendil-works/pi-coding-agent
# 或者使用 npm
npm install -g --ignore-scripts @earendil-works/pi-coding-agent

export PI_SKIP_VERSION_CHECK=1 # 只关版本检查
export PI_CACHE_RETENTION=long # 1h 缓存
export PI_TELEMETRY=0 # 关遥测

pi
VariableDescription
PI_CODING_AGENT_DIR~/.pi/agent
PI_PACKAGE_DIR
PI_SKIP_VERSION_CHECK关闭版本检测
PI_TELEMETRY1/true/yes to enable or 0/false/no to disable
PI_CACHE_RETENTIONlong (Anthropic: 1h, OpenAI: 24h)
VISUAL, EDITOR
  • $PWD/.pi/
    • settings.json
    • SYSTEM.md
    • APPEND_SYSTEM.md
    • skills/
    • prompts/
    • extenstions/
    • npm/
      • node_modules/
    • git/
      • github.com/org/repo/
    • themes/
  • ~/.pi/agent
    • auth.json
    • models.json
    • sessions/--PATH--/TIMESTAMP_UUID.jsonl
  • .agents/skills
    • 主要支持 skills 递归向上查找
pi install -l npm:@org/pi-package
pi install -l git:github.com/org/repo
{
"enableInstallTelemetry": false,
"skills": [
// "+/path/SKILL.md"
]
}
{
"providers": {
"name": {
"baseUrl": "",
"apiKey": "",
"api": "openai-completions",
"headers": {},
"compact": {},
"models": [
{
"id": "model-id",
"name": "",
"reasoning": true,
"contextWindow": 128000,
"maxTokens": 16384,
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
}
],
"modelOverrides": {}
}
}
}

Awesome

# ~/.pi/agent/extensions/pi-rtk-optimizer
pi install npm:pi-rtk-optimizer

Session

# session dir
ls ~/.pi/agent/sessions/-$(echo "$PWD/" | sed 's#/#-#g')-
cd ~/.pi/agent/sessions/-$(echo "$PWD/" | sed 's#/#-#g')-

jq -r 'select(.type=="message" and .message.role=="user") | if (.message.content|type)=="string" then .message.content else [.message.content[]? | select(.type=="text") | .text] | join("\n---\n") end' *.jsonl

Inside

type KnownApi =
| 'openai-completions'
| 'mistral-conversations'
| 'openai-responses'
| 'azure-openai-responses'
| 'openai-codex-responses'
| 'anthropic-messages'
| 'bedrock-converse-stream'
| 'google-generative-ai'
| 'google-vertex';
  • openrouter-images
  • OpenAI-compatible proxy / Ollama / vLLM / LM Studio:openai-completions
  • Anthropic-compatible proxy:anthropic-messages
  • Google AI Studio:google-generative-ai
  • OpenAI Responses-compatible:openai-responses
openai-responsesopenai-codex-responses
目标OpenAI 官方 Responses APIChatGPT/Codex 后端
默认 endpointmodel.baseUrl 通常 /v1 下 Responseshttps://chatgpt.com/backend-api/codex/responses
认证OpenAI API keyCodex/ChatGPT auth token
传输OpenAI SDK streamingWebSocket 优先,SSE fallback
system prompt转成 Responses input单独放 instructions
tools标准 Responses toolsCodex 兼容 tools,strict: null
retry/timeoutSDK request options自定义 retry、SSE header timeout、WebSocket fallback
典型 provideropenai, github-copilot, cloudflare-ai-gateway 等openai-codex

Awesome

  • tintinweb/pi-subagents
    • Agent
      • schedule
    • get_subagent_result
    • steer_subagent
    • 给正在运行的子 agent 发 steering message。
{
subagent_type: "Explore" | "Plan" | "general-purpose" | "<custom>",
prompt: "...",
description: "...",
model?: "sonnet" | "provider/model",
thinking?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh",
max_turns?: number,
run_in_background?: boolean,
resume?: string,
isolated?: boolean,
inherit_context?: boolean,
isolation?: "worktree",
schedule?: string
}

Prompt

---
# 不写则取正文第一条非空行,最多 60 字符
description: Review staged git changes
argument-hint: "[focus]"
---
Review staged changes.

Focus: $ARGUMENTS
  • Review $1 with $ARGUMENTS
    • /review 789 XYZ

<project_context>

Project-specific instructions and guidelines:

<project_instructions path="/path/to/AGENTS.md">
...文件内容...
</project_instructions>

</project_context>

<available_skills>
<skill>
<name>pi-dev-guide</name>
<description>Use when modifying...</description>
<location>/path/to/SKILL.md</location>
</skill>
</available_skills>

<skill name="foo" location="/path/to/SKILL.md">
References are relative to /path/to/skill-dir.

...SKILL.md 正文,去掉 frontmatter...
</skill>

args

Version

v0.74

  • repo 变更为 badlogic/pi-mono -> earendil-works/pi
  • npm @mariozechner/pi-coding-agent -> @earendil-works/pi-coding-agent
pi update
pi update --self

FAQ

# 修复会话 cwd
cd /new/project/path
pi --fork /path/to/old/session.jsonl