PiG README

项目的 README,来自 github.com/MichaelKinsy/PiG。合并为一个 markdown 文件:README.md。

PiG project banner: There are many agent harnesses, but this one is yours. Meet Pi-in-Go.

PiG

CI CodeQL OpenSSF Scorecard OpenSSF Best Practices REUSE status Go Reference Minimum Go version License: MIT Latest release Pi pin 1.6.0 Pi port progress Follow PiG on X Join r/PiGCodingAgent

PiG is Pi, the minimal and extensible coding agent for the terminal, rebuilt in Go as one native binary. The binary needs no Node.js. Pi's TypeScript extensions run on your Node.js 22.13 or newer through PiG's compatible runtime modules, and extension API parity lists the differences. You can also write extensions in Go, Rust, Python, or Common Lisp, and bundle extensions, skills, and prompts into a Piglet: one named agent you can share or build into its own executable.

PiG is a pre-stable 0.x release. Core paths are ported and checked against Pi 1.6.0 with paired parity scenarios; edge cases are still hardening. See the port status and file map for current scope and evidence.

If PiG behaves differently from Pi, that is either a bug or a documented divergence. Windows support is a preview.

Install

On macOS, Linux, or Android with Termux (arm64):

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

On Windows, in PowerShell:

irm https://pi-in-go.dev/install.ps1 | iex

With npm, on any supported platform:

npm install -g @pi-in-go/pig

With Go:

go install github.com/MichaelKinsy/PiG/cmd/pig@latest

With Nix:

nix run github:MichaelKinsy/PiG

You can also download an archive from GitHub Releases or build from source. pi-in-go.dev/install covers every method, including updates and uninstalling.

Quick start

Start PiG in the directory where you want it to work, run /login to connect a subscription or set your provider's API key (for example OPENAI_API_KEY), then ask it something:

cd /path/to/project
pig

Interactive /login masks secret input by default. Turn off Mask secret input in /settings to restore Pi's plain-text typing and submitted input (D80). See login privacy.

The documentation covers everything else, starting with the quickstart. You can also ask PiG to explain itself.

Serve many sessions

pig --mode rpc --listen <path> serves one RPC session per connection on the Unix socket at <path>, with Pi's RPC protocol unchanged on each connection (D232). It is new in PiG 0.8.0 and not in PiG 0.7.0, and Pi has no equivalent.

See serving many sessions for the protocol details.

Upstream Pi

Pi is the reference implementation. PiG follows Pi's behavior and design unless a Go constraint or an approved product-neutral requirement makes a difference necessary.

Use the upstream project for Pi itself:

PiG is not an official Pi release. The Pi maintainers do not endorse PiG.

Origins

Michael Kinsy created PiG working at Hewlett Packard Enterprise.

PiG is maintained as an independent open-source project. Project decisions, issues, and contributions belong in this repository. See docs/project/GOVERNANCE.md and docs/project/MAINTAINERS.md.

Compatibility philosophy

PiG adds a Go implementation to the Pi ecosystem and follows the Pi reference implementation.

The pinned Pi release is 1.6.0 at commit faac585884ae2c013a6b1400f3e9e77f10b34bac. The pin names the behavior oracle. It does not claim that every upstream change is already ported: test/parity/generated/coverage.md reports verified behavior, and the upgrade ledgers under test/parity/upstream-sync/ list each upstream change and its disposition.

PiG's current package scope covers Pi's agent, AI, coding-agent, and TUI packages. It does not implement Pi's experimental remote Session packages or its standalone telemetry and evaluation packages. See docs/parity/PORT_MAP.md for the exact boundary.

Project facts

pig version prints the PiG release and the pinned Pi release as separate fields. The interactive startup line prints PiG's version as <PiG release>+<Pi release>, for example 0.8.0+1.6.0: the Pi release is semver build metadata, so the version sorts as the PiG release. pig --version and pig -v print the pinned Pi package version alone, exactly as pi --version does, so a launcher that checks Pi's version reads it. That change is new in PiG 0.8.0: PiG 0.7.0 prints its own version with the Pi release as build metadata for pig --version. Neither command reads user configuration.

Repository map

Path Responsibility
agent/ Pi-compatible Agent loop, messages, and harness Session state.
ai/ Pi-compatible providers, model catalog, authentication, and streaming types.
coding/ Public coding-agent SDK, extension contracts, Package support, and Piglet support.
tui/ Public terminal components, rendering, input, and terminal lifecycle.
cmd/pig/ Stock PiG command-line application and RPC process surface.
internal/ Private implementation used by Stock PiG. External modules cannot import it.
extensions/ Go, Rust, Python, Common Lisp, and declaration-only TypeScript extension SDKs.
piglets/ Explicit agent compositions such as PiG Standard and Pig Porter.
test/parity/ Pinned Pi correspondence, scenarios, inventories, and generated evidence.
test/ Integration, extension-conformance, clean-repository, and upstream-contract tests.
docs/ Maintainer references and the static public documentation site.
examples/ Small extension and embedding examples.
automation/ Build, generation, CI, release, layout, and maintainer tooling.

PiG aligns public package boundaries with Pi's agent, ai, coding-agent, and tui packages. Go files within a package follow cohesive implementation responsibilities instead of mirroring TypeScript file mechanics. docs/parity/PORT_MAP.md records every source correspondence.

Stock PiG and compositions

Stock PiG is the product-neutral binary built from this repository. It does not activate PiG Standard Resources, product authentication, product APIs, or deployment-specific behavior.

A Piglet explicitly selects Resources, tools, discovery, defaults, and environment requirements for one agent. A Package distributes Resources. A Package never owns or activates a Piglet. A Piglet Binary is a direct executable build output for one pinned Piglet composition.

PiG Standard is the explicit Piglet at piglets/standard/pig-standard.yaml. It currently selects four extensions: PiG login and the sprite catalogue, PiG Runner, Angry Pigs, and the Bun runtime installer. Run it from source with:

pig --piglet piglets/standard/pig-standard.yaml

Stock PiG never selects this composition implicitly. A Package can distribute its Resources, but a Package cannot own or activate the Piglet.

See CONTEXT.md and docs/README.md for the project terms and documentation map.

Security boundary

PiG runs with the permissions of the user who starts it. PiG does not provide a security sandbox for model output, tools, extensions, skills, hooks, or shell commands.

Use a container, virtual machine, or another operating-system boundary when you need isolation. Load extensions and project instructions only from sources you trust. See .github/SECURITY.md.

Install with npm

Install the command with npm (Node.js 18 or newer):

npm install -g @pi-in-go/pig
pig version

Or run it once without installing:

npx @pi-in-go/pig version

pig itself is the native binary: npm installs the matching platform package (@pi-in-go/pig-<os>-<cpu>, for macOS, Linux and Windows on x64 and arm64, and Android on arm64 for Termux) as an optional dependency, and Node.js runs only a small launcher. Do not install with --omit=optional or --no-optional, which leaves the binary out. Update with npm update -g @pi-in-go/pig or pig update (which runs npm install -g --ignore-scripts --min-release-age=0 @pi-in-go/pig@<version> when the global install is writable), and uninstall with npm uninstall -g @pi-in-go/pig.

Install with Go

Install the command without a source checkout with Go 1.27 or newer (an older Go, 1.21 or newer, downloads the toolchain go.mod names unless GOTOOLCHAIN=local):

go install github.com/MichaelKinsy/PiG/cmd/pig@latest

Go writes the pig executable to GOBIN, or to the bin directory of the first GOPATH entry when GOBIN is unset: $(go env GOPATH)/bin, which is ~/go/bin by default (%USERPROFILE%\go\bin on Windows). Add that directory to PATH. With an older Go 1.21 or later and the default GOTOOLCHAIN=auto, Go downloads a new enough toolchain automatically. Release binaries are built with Go 1.27.4.

Use an exact release such as @v0.8.0 when reproducibility matters. Update a Go installation by running go install again. Each release tags the root module (v0.8.0) and the Go extension SDK module (extensions/sdk/v0.8.0) on the same commit; go install needs both.

Install with Nix

The flake builds PiG from source in the Nix sandbox, with every input pinned by flake.lock:

nix run github:MichaelKinsy/PiG -- version
nix profile add github:MichaelKinsy/PiG

Nix before 2.30 and Lix spell the second command nix profile install.

On NixOS or with Home Manager, add the flake as an input and install inputs.pig.packages.${system}.default, or apply inputs.pig.overlays.default and install pkgs.pig.

The package wraps pig as Pi's flake does: fd, ripgrep, and the clipboard commands come first on PATH, and Node.js comes last so that npm is available for package installs. Extensions build and run as in any other installation, with the toolchains on your PATH and the SDKs PiG stages under ~/.pig. pig update does not replace a Nix installation; update the flake input instead. The flake is verified on x86_64-linux; the other systems evaluate but are not yet verified natively.

Build from source

PiG currently supports source builds on Linux, macOS, and Windows. Do not treat a platform as release-supported until its native release verification passes.

Requirements:

Build the binary:

go build -o bin/pig ./cmd/pig
./bin/pig version

Prepare the exact Pi comparator and source mirror:

make upstream-mirror

Run the main local gate:

make check

The upstream-mirror target installs the Pi comparator of the pin: the lockfile-pinned package for a release tag, or a build of the pinned commit. It retrieves the exact Pi source and verifies its commit against .upstream/pin.

Contract model

A ported row means that code exists. It does not prove behavioral compatibility. A non-deferred scenario must exercise and assert the mapped behavior.

Extensions

PiG supports Go, Rust, Python, Common Lisp, and Node extension factories through its public extension host. The SDKs are extensions/sdk (Go), extensions/sdk-rs, extensions/sdk-py, and extensions/sdk-lisp. A Node extension needs no SDK directory, because it imports Pi's package. Extensions can register tools, commands, event handlers, flags, shortcuts, providers, and user-interface contributions.

Each language needs its toolchain on your PATH: Go, Cargo for Rust, Python 3, SBCL 2.6.9 for Common Lisp, or Node.js 22.13 or newer for TypeScript and JavaScript. pig setup reports what is missing. PiG compiles Rust and Lisp extensions on your machine.

Node extensions use Pi's TypeScript extension API. PiG supplies compatible runtime modules. Node.js is the default runtime. The extensionsTypescriptRuntime setting or PIG_TS_RUNTIME selects another runtime that an extension or Piglet installed, such as the Bun runtime that PiG Standard installs on command (D19). The declaration-only package in extensions/sdk-ts adds types for PiG-only extension capabilities without replacing Pi's TypeScript runtime.

Start with:

Use pig extension init <directory> to scaffold an extension. Use pig install <path> --validate-only --json to validate it.

Supply-chain evidence

PiG treats scanner output as evidence input, not as proof by itself. Release preparation builds a validated dependency inventory and artifact-specific SPDX SBOMs. Reviewers reconcile scanner findings with Go modules, npm locks, Python metadata, Rust locks, embedded assets, generated data, and release contents.

See docs/supply-chain.md for the inventory, SBOM, vulnerability, license, signing, and provenance requirements.

Project policies

Acknowledgements

PiG would not exist without Pi and the work of its maintainers and contributors. Their design and open-source work provide the reference that PiG follows.

Thank you to everyone who contributes to Pi and PiG. Maintainers are listed in docs/project/MAINTAINERS.md, every contributor appears on GitHub's contributors page, and the changelog credits each fix to the person who reported or contributed it.

Star History

Star History Chart

PiG (MichaelKinsy/PiG)

正在搜索数据库…

883 ·GitHub
这是什么?PiG 是 Pi 的 Go 语言移植版。Pi 是最初用 TypeScript 编写的极简终端编程智能体,PiG 将其重构为启动迅速、无需 Node.js 的单一原生二进制文件。
PiG 是对 Pi 的重写,还是别的什么?它是对齐式移植而非重写:上游 Pi 的 TypeScript 行为就是契约,Go 只是实现语言,所以 PiG 仍能原样运行 Pi 现有的 TypeScript 扩展。
怎么安装 PiG?可以用 npm 安装(npm install -g @pi-in-go/pig)、用 go install、从 GitHub Releases 下载预构建压缩包,或从源码构建;pi-in-go.dev/install 涵盖包括更新和卸载在内的所有方法。
使用它需要 Node.js 或 API key 吗?原生二进制本身不需要 Node.js(npm install 只是运行一个围绕它的小启动器);要实际使用 PiG,你需要运行 /login 绑定订阅,或设置提供商的 API key,比如 OPENAI_API_KEY。
PiG 现在稳定到可以依赖了吗?还不完全——它是稳定版之前的 0.x 版本,核心路径已完成移植,并通过对齐场景对照 Pi 1.0.0 做了校验,但边缘情况仍在打磨,Windows 支持也只是预览版。
PiG 能在哪些平台上运行?macOS、Linux、Windows(预览版),以及通过 Termux 运行的 Android,npm 包提供 x64 和 arm64 构建。
PiG 会对智能体的 shell 命令或模型输出做沙箱隔离吗?不会——PiG 以启动它的用户权限运行,对模型输出、工具、扩展、技能、钩子或 shell 命令都不提供安全沙箱;如果需要隔离,请使用容器或虚拟机。
我能用 TypeScript 以外的语言编写 PiG 扩展吗?可以——除了能原样运行 Pi 现有的 TypeScript 扩展之外,PiG 还提供 Go、Rust 和 Python 的扩展 SDK。
Piglet 是什么?Piglet 是一个命名的智能体组合,把扩展、技能和提示词打包在一起,你可以分享它,或把它构建成独立的可执行文件。
这个构建跟踪的是哪个上游 Pi 版本?PiG 锁定在 Pi 0.99.1 版本,test/parity/coverage.md 下的文件和 upstream-sync 台账精确记录了哪些行为已针对该锁定版本完成验证。
大小
1.1 GB
星标
883
时长
2个月
提交 · 90 天