这个项目能做什么

Poe Code 是一个工具,可将你常用的编码代理(Claude Code、Codex、OpenCode、Goose 等)通过 Poe API 路由,因此你只需一个 Poe 订阅,而无需管理多个提供商或账户。一次性配置后,它可与这些代理的常规 CLI 或桌面应用配合使用,也支持生成一次性提示,用于脚本和 CI/CD。 ## 快速开始 将 Poe Code 设为某个代理的默认提供商(会更新配置文件): ```bash npx poe-code@latest configure npx poe-code@latest configure codex # 或 claude、opencode、goose ``` 使用 `unconfigure` 移除覆盖配置: ```bash npx poe-code@latest unconfigure claude ``` ## 身份验证 使用你的 Poe API 密钥。首次运行时,会提示你通过浏览器登录(OAuth)。你也可以直接提供密钥: ```bash npx poe-code@latest login npx poe-code@latest login --api-key <your-key> export POE_API_KEY=<your-key> ``` 凭据存储在 `~/.poe-code/` 中。使用 `poe-code auth status` 检查状态,使用 `logout` 移除。 ## 实用工具 - **生成一次性提示**:`npx poe-code@latest spawn codex "Say hello" --mode read`(模式:yolo、auto、edit、read;在无 TTY 的 CI 中为必填)。 - **针对 GitHub 仓库生成**:`--cwd github://owner/repo`,或带 ref/subdir,如 `github://owner/repo#main:packages/auth`。 - **通过 stdin 传入提示**:`echo "Say hello" | npx poe-code@latest spawn codex --mode read`。 - **审查 GitHub PR**:`code-review install`、`code-review run <url>`、`code-review commit <url> --dry-run`。 - **测试已配置的服务**:`npx poe-code@latest test codex`。 - **安装代理 CLI**:`install claude-code`、`install codex`、`install opencode`、`install goose`。 - **可选标志**:`--dry-run`(显示变更但不写入磁盘)、`--yes`(接受默认值)。 ## 用量与计费 检查计算点数余额和用量历史: ```bash poe-code usage poe-code usage list poe-code usage list --limit 100 poe-code usage list --filter claude ``` ## 模型 列出可用的 Poe API 模型,可按端点、提供商或搜索过滤: ```bash poe-code models poe-code models --endpoint /v1/responses poe-code models --endpoint /v1/chat/completions poe-code models --search claude ``` ## SDK 在你自己的代码中以编程方式使用 Poe Code: ```typescript import { spawn, getPoeApiKey, getPoeAuthIdentity } from "poe-code"; const apiKey = await getPoeApiKey(); const identity = await getPoeAuthIdentity(); const result = await spawn("claude-code", { prompt: "Fix the bug in auth.ts", cwd: "/path/to/project", model: "claude-sonnet-4-6" }); console.log(result.stdout); ``` - `spawn(service, options)` – 运行单个提示;选项包括 `prompt`、`cwd`(本地路径或 `github://` 定位符)、`model`、`mode`、`args`。返回 `{ stdout, stderr, exitCode }`。 - `spawn.pretty(service, options)` – 相同,但渲染带颜色的 ACP 事件流。 - `getPoeApiKey()` – 读取 `POE_API_KEY` 环境变量或凭据文件。 - `getPoeAuthIdentity()` – 获取 Poe 账户身份。 对于插件优先的组合方式,使用 `poe-code/agent` 子路径,配合 `agent()`、`openaiResponsesPlugin()`、`systemPromptPlugin()`。 ## 研究预览 功能可能会有破坏性变更: - **SafeJS** – 具有显式宿主能力、执行预算、可恢复检查点的 JavaScript 解释器。发布为 `@poe-platform/safe-js`。尚未建立完整一致性。 - **Pipeline** – 运行具有可配置步骤、实时进度、排队后续任务的任务计划。 - **Ralph** – 围绕 markdown 文档迭代的代理式构建循环。 - **Experiment loop** – Karpathy 风格的优化循环(代理修改代码,评估打分,通过 git 保留/丢弃)。 - **Poe Agent** – 可组合的代理运行时。 ## 更新 ```sh npx poe-code@latest update npx poe-code@latest update --package-manager pnpm ``` 有关版本检查、试运行和托管工作树,请参阅完整参考。