跳至内容

开发

创建于 2025-07-16·更新于 2026-07-16

更多指南请参阅 AGENTS.md

设置 Setup

git clone https://github.com/earendil-works/pi-mono
cd pi-mono
npm install
npm run build

从源码运行:

/path/to/pi-mono/pi-test.sh

该脚本可从任意目录运行。Pi 保持调用者的当前工作目录。

复刻 / 品牌重塑 Forking / Rebranding

通过 package.json 配置:

{
  "piConfig": {
    "name": "pi",
    "configDir": ".pi"
  }
}

修改 nameconfigDirbin 字段以适配你的复刻。会影响 CLI 横幅、配置路径和环境变量名称。

路径解析 Path Resolution

三种执行模式:npm install、独立二进制文件、从源码通过 tsx 运行。

始终使用 src/config.ts 获取包资源:

import { getPackageDir, getThemeDir } from "./config.js";

切勿直接使用 __dirname 获取包资源。

调试命令 Debug Command

/debug(隐藏命令)写入 ~/.pi/agent/pi-debug.log

  • 渲染的 TUI 行(含 ANSI 转义码)
  • 发送给 LLM 的最后几条消息

测试 Testing

./test.sh                         # 运行非 LLM 测试(无需 API 密钥)
npm test                          # 运行所有测试
npm test -- test/specific.test.ts # 运行指定测试

项目结构 Project Structure

packages/
  ai/           # LLM 提供商抽象层
  agent/        # Agent 循环与消息类型
  tui/          # 终端 UI 组件
  coding-agent/ # CLI 与交互模式