pi README

项目的 README,来自 github.com/earendil-works/pi。合并为一个 markdown 文件:README.md。

pi logo

Discord npm

New issues and PRs from new contributors are auto-closed by default. Maintainers review auto-closed issues daily. See CONTRIBUTING.md.

Pi

Pi is a minimal, extensible agent harness that you can make your own.

Adapt Pi to your workflows, not the other way around. Customize Pi with extensions, skills, prompt templates, and themes. Bundle them as Pi packages and share via npm or git.

Pi ships with powerful defaults but skips features like sub-agents and plan mode. Ask Pi to build what you want, or install a package that does it your way.

Use Pi interactively, automate it in print or JSON mode, control it over RPC, or build apps with the Pi TypeScript SDK. See OpenClaw for a real-world integration.

Getting started

Install the command-line interface:

curl -fsSL https://pi.dev/install.sh | sh

On Windows:

powershell -c "irm https://pi.dev/install.ps1 | iex"

The installer pins all dependencies and updates Pi with pi update. Alternatively, install directly with npm, which does not pin transitive dependencies:

npm install -g --ignore-scripts @earendil-works/pi-coding-agent

Pi requires Node.js 22.19 or newer. The macOS, Linux, and Windows installers can install it if needed. Pi does not require dependency lifecycle scripts for a normal npm installation.

Start Pi in the directory where you want it to work:

cd /path/to/project
pi

For a built-in AI provider, run /login inside Pi to connect a subscription or API key. Then give Pi a task.

See the documentation for full setup and usage instructions, or visit pi.dev for demos.

Run with Nix

nix run github:earendil-works/pi/stable

stable points at the latest release. Install it with nix profile add github:earendil-works/pi/stable and update with nix profile upgrade pi. Use a release tag such as github:earendil-works/pi/v1.0.0 to pin a version, or github:earendil-works/pi for unreleased changes on main. Nix builds Pi from source.

Supports ARM64 and x86-64 on Linux and macOS. Use nix build . or nix run . to build or run your checkout.

Nix builds are offline, so the bundled model data comes from a pi.dev model catalog revision pinned in nix/model-catalog.json. At runtime, Pi still overlays newer catalog data from pi.dev as usual. The Nix workflow replaces the pin on main when it no longer matches the checkout, for example after a provider is added or gains a new model type. To refresh it by hand:

npm run update:model-catalog-pin

Packages

This monorepo contains the Pi CLI and its supporting libraries.

Package Description
@earendil-works/chord Object runtime for apps across processes: contracts, documents, a store, links, plugins with hot reload, HTTP, workers, web and terminal clients
@earendil-works/pi-telemetry Vendor-neutral telemetry contracts, reference adapter, conformance tests, and typed schemas
@earendil-works/pi-ai Unified multi-provider LLM API (OpenAI, Anthropic, Google, etc.)
@earendil-works/pi-durable Durable conversation, task, and document runtime
@earendil-works/pi-agent-core Agent runtime with tool calling and state management
@earendil-works/pi-coding-agent Interactive coding agent CLI
@earendil-works/pi-tui Terminal UI library with differential rendering

For Slack/chat automation and workflows see earendil-works/pi-chat.

Permissions & Containerization

Pi does not include a built-in permission system for restricting filesystem, process, network, or credential access. By default, it runs with the permissions of the user and process that launched it.

If you need stronger boundaries, containerize or sandbox Pi. See packages/coding-agent/docs/containerization.md for three patterns:

Contributing

See CONTRIBUTING.md for contribution guidelines and AGENTS.md for project-specific rules (for both humans and agents). Longer term plans for Pi can also be found in RFCs.

Development

npm install --ignore-scripts  # Install all dependencies without running lifecycle scripts
npm run build         # Refresh model data, then build all packages
npm run build:offline # Rebuild using existing model data without network access
npm run check         # Lint, format, and type check
./test.sh            # Run tests (skips LLM-dependent tests without API keys)
./pi-test.sh         # Run pi from sources (can be run from any directory)

Using local packages outside the monorepo

Build every public package into one coherent local artifact set:

npm run pack:packages -- --out .artifacts/pi-packages

This refreshes model data before building pi-ai. To avoid network access when model data is already hydrated, pass --offline-model-data.

Then configure an external project to consume one package and resolve all of its Pi dependencies from the same artifact set. npm is the default:

node scripts/use-local-packages.mjs \
  --manifest .artifacts/pi-packages/manifest.json \
  --consumer ../my-project \
  --package @earendil-works/pi-durable \
  --package @earendil-works/pi-agent-core
cd ../my-project
npm install --ignore-scripts

For a pnpm project, point --consumer at the workspace root:

node scripts/use-local-packages.mjs \
  --manifest .artifacts/pi-packages/manifest.json \
  --consumer ../my-project \
  --package @earendil-works/pi-agent-core \
  --package-manager pnpm
cd ../my-project
pnpm install --ignore-scripts

Repeat --package for each direct dependency. The command updates the consumer's package.json with content-addressed local file: references. It writes transitive overrides to package.json for npm or pnpm-workspace.yaml for pnpm. Keep the artifact directory available while installing or updating the consumer. Re-run both commands after changing Pi source.

Building standalone binaries from release source

GitHub releases include a versioned source archive covered by the release's SHA256SUMS file. Extract it and run the same build script used for the official standalone binaries:

VERSION="<release-version>"
tar -xzf "pi-${VERSION}-source.tar.gz"
cd "pi-${VERSION}"
./scripts/build-binaries.sh --offline-model-data --platform linux-x64 --out "$PWD/out"

The archive includes release model data and native prebuilds. --offline-model-data uses that model data without refreshing provider catalogs. The script installs dependencies and builds the executable with its runtime assets; pass --skip-install if dependencies are already provided.

Supply-chain hardening

We treat npm dependency changes as reviewed code changes.

Share your OSS coding agent sessions

If you use Pi or other coding agents for open source work, please share your sessions.

Public OSS session data helps improve coding agents with real-world tasks, tool use, failures, and fixes instead of toy benchmarks.

For the full explanation, see this post on X.

To publish sessions, use badlogic/pi-share-hf. Read its README.md for setup instructions. All you need is a Hugging Face account, the Hugging Face CLI, and pi-share-hf.

You can also watch this video, where I show how I publish my pi-mono sessions.

I regularly publish my own pi-mono work sessions here:

License

MIT

pi.dev domain graciously donated by

Exy mascot
exe.dev

pi (earendil-works/pi)

正在搜索数据库…

125.1K ·GitHub
这是什么?Pi 是一个智能体框架(agent harness),即一套用于构建和运行 AI 智能体的软件包工具集,包括一个可自我扩展的交互式编程智能体命令行工具、统一支持多家模型提供商的大语言模型 API、智能体运行时,以及终端用户界面库。
这是一个命令行工具,还是一组软件包?这是一个单体仓库(monorepo),里面包含多个独立的 npm 软件包:pi-coding-agent(命令行工具)、pi-agent-core(带工具调用和状态管理的智能体运行时)、pi-ai(统一的大语言模型 API)、pi-tui(终端用户界面库),另外还有用于应用组合的 chord 和用于遥测的 pi-telemetry。
我该怎么让编程智能体命令行工具运行起来?你可以安装 npm 上的 pi-coding-agent 软件包,也可以从 GitHub 发布版本下载源码压缩包(并用其中的 SHA256SUMS 文件校验),然后运行其中自带的构建脚本。如果依赖已经安装好,可以加上 --skip-install 参数跳过安装依赖。
它支持哪些大语言模型提供商?我需要 API 密钥吗?pi-ai 通过统一的 API 对接 OpenAI、Anthropic、Google 等多家提供商,因此你使用哪家提供商,就需要对应的 API 密钥。运行 Pi 还需要 Node.js 22.19 或更高版本。
Pi 会限制智能体能访问我电脑上的哪些内容吗?不会。Pi 没有内置的权限系统:默认情况下,Pi 会以启动它的用户和进程的全部权限运行,可以随意访问文件系统、进程、网络和凭据。如果想获得更强的隔离,需要自行用容器或沙箱来运行它,例如通过 Gondolin 扩展、普通 Docker 或 OpenShell。
chord 是什么?chord 是同一个单体仓库中附带的一个独立应用组合运行时,负责处理服务、复制状态、RPC 和插件。
我能在沙箱中运行 Pi 来保障安全吗?可以。文档介绍了三种方式:Gondolin 扩展(将工具转发到本地 Linux 微型虚拟机中运行,同时把身份认证保留在宿主机上)、在普通 Docker 中运行整个进程,或在 OpenShell 的策略受控沙箱中运行。
有没有 Slack 或聊天工具的集成?Slack 等聊天自动化和工作流由独立的 earendil-works/pi-chat 项目负责,不在本仓库中。
我能与他人分享我的编程智能体会话吗?可以。配套工具 pi-share-hf 可以把你的 Pi 会话日志发布到 Hugging Face,用真实的任务数据帮助改进编程智能体。
大小
136.2 MB
星标
125.1K
时长
1年
提交 · 90 天