@phren/agent

中文文档
0.3.69发布于 2026/11/02MITES Module构建来源已验证

phren's coding agent: starts every session knowing your project's memory, tasks and decisions

原始使用文档
文档目录4 节
  1. Keyboard help and remote MCP
  2. Developing this package
  3. Phren Hook / iPhone chat
  4. Splash

@phren/agent

phren's coding agent. It reads, edits and runs your code with tool calls, and starts every session already knowing the project's truths, open tasks, recent findings and last session, from the same phren store your other agents use.

npm install -g @phren/cli @phren/agent
phren init                 # once, creates the memory store
phren agent -i             # or: phren-agent -i

It runs on a ChatGPT/Codex subscription (phren agent auth login), OpenAI, OpenRouter, Anthropic, DeepSeek (DEEPSEEK_API_KEY), any OpenAI-compatible endpoint (--provider openai-compat --base-url … --model …) or local Ollama models. For scripts, -p --output-format json|stream-json gives machine-readable output. PARITY.md compares it with Claude Code, Codex and OpenCode, and scripts/bench/run.mjs runs it headless against small real-task fixture repos. The full guide, including MCP servers, permissions, headless runs and the phone app, is docs/agent.md. This package is released together with @phren/cli and pins its exact version.

Keyboard help and remote MCP

Press ? with an empty draft or F1 to open keyboard help; Escape closes it without losing the draft. The help hint remains visible in every permission mode. Assistant text wraps beneath its first text column in both live and completed turns.

MCP configuration accepts stdio, http (Streamable HTTP), and legacy sse. Remote transports use the MCP SDK, including responses delivered on a separate SSE stream after HTTP 202. To enable browser OAuth, set oauth: true on a server:

{"mcpServers":{"example":{"type":"http","url":"https://example.com/mcp","oauth":true}}}

On first connection, open the authorization URL printed in the terminal. The loopback callback verifies state; the SDK handles discovery, PKCE and token refresh. OAuth requires HTTPS except for local loopback servers. For a registered client, oauth can instead be an object with clientId, optional clientSecret, scope, and callbackPort (default 14557). Credentials are stored per server in mode-0600 files under ~/.phren/agent/mcp-auth; PHREN_MCP_AUTH_DIR overrides that directory. PKCE verifiers remain in memory. Authorization waits at most five minutes and closing a connection closes its callback listener.

Developing this package

packages/agent is a pnpm workspace member, built by the root pnpm build and tested in CI by its own agent-test job:

  • pnpm build (root) includes this package.
  • pnpm test (root) does not run this package's tests: its suite runs separately (its own vitest.config.ts, no workspace-root globalSetup) and is kept off the CI OS×node matrix.

To build, test, or lint this package on demand:

pnpm exec turbo run test --filter=@phren/agent   # builds @phren/cli dist first
pnpm --filter @phren/agent build
pnpm --filter @phren/agent lint

Note: the test suite imports @phren/cli subpath exports that resolve to packages/cli/dist/, so a bare pnpm --filter @phren/agent test on a clean checkout fails until the CLI is built — prefer the turbo invocation.

Phren Hook / iPhone chat

When phren-agent runs inside a Herdr pane (HERDR_ENV=1), it reports SessionStart, UserPromptSubmit and Stop to the installed Phren Hook bundle (~/.local/share/phren/bridge/current/bridge-hook.mjs hook phren, see src/herdr-hooks.ts) so the iPhone can bind the pane to this session's .runtime/sessions/session-<id>.events.jsonl. Everything on Phren's side is in place; the pane shows up as a chat once Herdr reports phren as an agent kind (Herdr adds agents in its own releases — see the draft request in the project notes). Without Herdr the hook calls are silent no-ops. Under tmux the Hook recognizes the agent from its process, whether it was started as phren-agent or phren agent (which spawns this package's binary with argv0 phren-agent).

Splash

Interactive sessions (phren-agent -i, --multi, --team) open with the phren splash — mascot plus the wordmark text effect — using the CLI's @phren/cli/shell/intro export, with the provider and model in the tagline. Set PHREN_INTRO=off to skip it.

版本与发布记录

@phren/agent 共发布 81 个版本,首次发布于 2026/03/29;过去 12 个月发布了 81 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.69latest2026/11/021 天前
0.3.682026/11/021 天前
0.3.672026/11/012 天前
0.3.662026/10/312 天前
0.3.652026/10/312 天前
0.3.642026/10/313 天前

关于 @phren/agent 的常见问题

@phren/agent 是什么?

Phren的编码代理:在每个会话开始时都知道项目的内存、任务和决策

如何安装 @phren/agent?

在项目目录运行 npm install @phren/agent,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 phren-agent,可以用 npx phren-agent 直接运行。

@phren/agent 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/phren__agent 是否存在。

@phren/agent 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@phren/agent 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@phren/agent 可以商用吗?

@phren/agent 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@phren/agent 还在维护吗?

最新版本 0.3.69 发布于 2026/11/02(1 天前);至今共发布 81 个版本,其中过去 12 个月发布了 81 个;首次发布于 2026/03/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。