@phren/cli

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

Knowledge layer for AI agents - CLI, MCP server, and data layer

原始使用文档
文档目录10 节
  1. Install
  2. Environment variables
  3. Tools
  4. Integration model
  5. Governance and security highlights
  6. search_knowledge
  7. get_project_summary
  8. list_projects
  9. How it works
  10. Development

phren MCP server

MCP server that indexes your personal phren and exposes it to AI agents via full-text search.

On startup it walks your phren directory, reads all .md files, and builds an in-memory SQLite FTS5 index.

Periodic remote checks are off by default. Enable them with phren config pull-interval 60 to check shared Git stores every minute while running, coordinated across MCP clients using the same store. Changed refs are fetched and applied only as clean fast-forwards; dirty or diverged stores are deferred. Pulled changes refresh the index and existing managed skill/instruction mirrors. Configure this machine with phren config pull-interval 600 (ten minutes) or phren config pull-interval off. Periodic checks are disabled for project-local stores and the manual preset; existing lifecycle hooks are configured separately.

Public surface: 78 MCP implementation tools across 17 catalog modules (search, tasks, findings, notes, memory, data, graph, sessions, ops/review, skills, hooks, config, extraction).

Notable shipped capabilities:

  • finding lifecycle tools: supersede_finding, retract_finding, resolve_contradiction, get_contradictions
  • finding provenance: add_finding.source (human|agent|hook|extract|consolidation|unknown)
  • lightweight daily notes: CRUD in <project>/notes/YYYY-MM-DD.md, explicit search, and promotion to findings without automatic prompt injection
  • cross-session continuity: task checkpoints + session_history
  • finding impact scoring from injected-context outcomes
  • skill registry behavior: scope precedence, alias-collision handling, visibility gating, generated skill-manifest.json
  • lifecycle penalties: superseded 0.25×, retracted 0.1×, contradicted 0.4× confidence in retrieval
  • inactive findings stripped from FTS index (superseded/retracted findings cannot appear in search)
  • auto-tagging: findings without type tags are inferred from content at write time
  • session context diff: session_start reports new findings since last session
  • decay resistance: confirmed findings decay 3× slower when repeatedly useful

Install

npx @phren/cli init

This sets up phren without needing sudo or a global install. On Windows, use npm install -g @phren/cli if npx isn't available.

Or add manually to Claude Code:

claude mcp add phren -- phren ~/.phren

Environment variables

VariableDefaultDescription
PHREN_PATH~/.phrenPath to your phren instance
PHREN_PROFILE(none)Active profile name. When unset, phren uses machines.yaml when available and otherwise falls back to an unscoped view
PHREN_PULL_INTERVAL_SECONDS0 (off)Overrides the machine-local pull interval. Whole seconds from 30–86400, or 0/off to disable periodic MCP checks.
PHREN_ACTOROS user / envActor identity used in governance/audit RBAC checks

Tools

See docs/api-reference.md for the full API reference.

Integration model

  • Claude: full native lifecycle hooks (SessionStart, UserPromptSubmit, Stop, PostToolUse) + MCP
  • Copilot CLI / Cursor / Codex: MCP + generated hook config + session wrapper binaries

Governance and security highlights

  • RBAC uses .config/access-control.json and .runtime/access-control.local.json
  • Web UI binds loopback-only, uses per-run auth token, enforces CSRF for mutations, and sets CSP headers
  • Telemetry is opt-in only (phren config telemetry on) and stored locally in .runtime/telemetry.json

search_knowledge

Full-text search across all indexed markdown files with synonym expansion.

query: string              - FTS5 query (supports AND, OR, NOT, "phrase matching")
limit?: number             - Max results, 1-20, default 5
type?: string              - Filter: "claude", "findings", "reference", "summary", "task", "skill"
project?: string           - Filter to a specific project
tag?: string               - Filter findings by type tag: decision, pitfall, pattern, tradeoff, architecture, bug
since?: string             - Filter findings by date: "7d", "30d", "YYYY-MM", "YYYY-MM-DD"
status?: string            - Filter by lifecycle status: active, superseded, contradicted, stale, invalid_citation, retracted
include_history?: boolean  - Include superseded/retracted findings (default false)
synthesize?: boolean       - Generate a synthesis paragraph from top results using an LLM

get_project_summary

Returns a project's summary.md content, path to its AGENTS.md, and a list of indexed files.

name: string      - Project name (e.g. "my-app", "backend")

list_projects

Lists all projects in the active profile with a brief description and which docs exist.

No parameters.

How it works

  1. Reads PHREN_PATH (or defaults to ~/.phren)
  2. Resolves the active profile from PHREN_PROFILE, or from machines.yaml when the env var is unset
  3. If no active profile can be resolved yet, falls back to an unscoped view of top-level project directories
  4. Walks each project directory, reads .md files, classifies them by filename
  5. Builds an in-memory SQLite FTS5 index with Porter stemming
  6. Serves tools over stdio using the MCP protocol

File types are derived from filenames and directories: AGENTS.md -> "claude", summary.md -> "summary", FINDINGS.md -> "findings", tasks.md -> "task", files under notes/ -> "notes", files under reference/ -> "reference", files under skills/ -> "skill".

Development

cd ~/phren
npm install
npm run build    # Compile TypeScript
npm run dev      # Run with tsx (hot reload)
npm test         # Run all tests

版本与发布记录

@phren/cli 共发布 189 个版本,首次发布于 2026/03/14;过去 12 个月发布了 189 个版本。最新版本附带 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/cli 的常见问题

@phren/cli 是什么?

AI代理的知识层- CLI, MCP服务器和数据层

如何安装 @phren/cli?

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

@phren/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@phren/cli 支持 ESM 还是 CommonJS?

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

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

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

@phren/cli 可以商用吗?

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

@phren/cli 还在维护吗?

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