personal-ai
v0.2.4
Published
Personal AI Identity Provider — local-first AI agent identity system. One command to scan, compile your profile, and deploy to any agent.
Maintainers
Readme
pai — Personal AI Identity Provider
本地优先的 AI Agent 身份画像系统。一条命令扫描本机,编译你的 profile,部署到任何 Agent。
pai init → Scan → Profile → Deploy to AgentsProfile ≠ Skill: Profile 描述你是谁(身份、环境、偏好、项目),Skill 是 Agent 使用 pai 的说明书。
快速开始
# 安装 (需要 Node.js >= 22)
npm install -g personal-ai
# 一条命令完成: 初始化 + 扫描本机 + 编译 profile (~12s, 零 LLM)
pai init
# 部署到 Cursor (Agent 自动认识你)
pai distribute
# 查看你的 profile
pai profile三步搞定,不需要 LLM,不需要 API Key。Agent 立刻认识你。
从源码安装 (开发者)
git clone https://github.com/piai/personal-ai-skills-new.git
cd personal-ai-skills-new
pnpm install && pnpm build && npm link核心概念
Profile (核心产物)
~/.pai/profile.md — 从本机扫描数据直接编译,零 LLM 依赖。
包含 7 个维度:
- Identity: 用户名、Apple ID、Git 身份、语言、时区
- Environment & Tools: 运行时、包管理器、Shell、IDE 扩展
- Work Style & Habits: 命令习惯、编码规则、AI agent 配置
- Active Projects & Recent Focus: 活跃仓库、近期 commit、工作目录
- Digital Footprint: 书签、浏览域名、安装的应用
- Registry & Cloud Accounts: npm/Docker/AWS/GCP/Vercel 等账户
- Context: 日历、文件组织结构
14 个数据收集器
| # | Collector | 数据来源 | |---|---|---| | 1 | identity-profile | 用户名、Apple ID、Git 配置、语言、时区 | | 2 | calendar-context | Calendar.app 订阅 | | 3 | file-organization | Documents/Desktop/Downloads 结构 | | 4 | dev-environment | 运行时版本、包管理器、全局包 | | 5 | dev-preferences | Shell aliases、Git config、Cursor 扩展 | | 6 | shell-habits | 最常用命令 Top 30 | | 7 | coding-rules | CLAUDE.md、Claude commands、项目规则 | | 8 | active-projects | 活跃 Git 仓库、SSH hosts | | 9 | productivity-setup | 已装 App、Dock 应用、浏览器 | | 10 | browser-bookmarks | 书签文件夹结构 | | 11 | browser-domains | 近 30 天高频域名 Top 30 | | 12 | github-profile | GitHub 用户信息、仓库、stars | | 13 | recent-focus | 近期 commit 分析、工作目录、工具使用 | | 14 | social-profiles | npm/Docker/AWS/GCP/Vercel 账户 |
Skill (Agent 说明书)
pai distribute 部署到 Agent 的文件包含两部分:
- 你的 Profile (谁、环境、偏好)
- Agent Skill 指令 (如何调用
pai context/search/add)
CLI 命令
# Profile (核心)
pai init # 初始化 + 扫描 + 编译 profile (一条龙)
pai init --skip-scan # 仅初始化,跳过扫描 (CI/测试用)
pai profile # 查看当前 profile
pai profile --rebuild # 重新扫描 + 编译
pai profile --export # 输出可复制粘贴的 profile
pai profile --json # JSON 元数据
pai distribute # 部署 profile + skill 到 Cursor
# 日常记录 (零 LLM)
pai log <text> # 追加到今日 journal (memory/YYYY-MM-DD.md)
pai log --clip # 从剪贴板读入
pai log --show # 查看今日 journal
pai log --date <date> <text> # 回填指定日期
# 数据管理
pai reset [--force] # 清空所有数据并重新初始化
pai add <text> # 手动添加文本到 raw/local/
pai add --url <url> # 抓取 URL 到 raw/web/
pai add <file> # 添加文件内容
pai auth google # Google 授权 (gmail/calendar 首次或重授权)
pai import --source mac # 手动触发 Mac 扫描 (写入 raw)
pai import --source gmail [--days N] [--query "..."] # Gmail 导入
pai import --source calendar [--days N] # 日历导入
# PINData 提取 (需要 OPENAI_API_KEY)
pai distill [--dry-run] [--file] # 提取 PINData: raw + journal → vault
pai distill --today # 只处理今日 journal
pai digest [--date <date>] # 生成 AI 日摘要
pai gaps [--days <n>] # 检查缺失日志 (默认 7 天)
pai generate [--profile <name>] # LLM 生成 SKILL.md
pai index # 更新 QMD 索引
# 搜索 & 检索
pai ask <question> # 智能问答,端到端答案 (agent 首选,需 LLM)
pai ask <question> --json # JSON: answer, sources, steps
pai search <query> # 混合搜索 vault
pai search <query> --fast # 快速关键词搜索
pai search <query> --json # JSON 格式
pai context --task <desc> # 身份 + 任务相关记忆 (agent 用)
# 状态
pai status [--json] # 数据状态概览技术栈
- 语言: TypeScript (ESM, strict mode)
- 运行时: Node.js ≥ 22
- CLI 框架: Commander.js
- 配置验证: Zod + JSON5
- LLM 调用: openai SDK (可选,深度知识功能需要)
- 本地搜索: QMD (可选,搜索功能需要)
- 终端输出: chalk + ora
- 构建: tsdown
- 测试: Vitest
- Lint: Oxlint
- 包管理: pnpm
前置依赖
# QMD (本地搜索引擎,搜索功能需要,profile 不需要)
npm install -g https://github.com/tobi/qmd
# GitHub CLI (可选,GitHub profile 收集)
brew install gh && gh auth login项目结构
src/
├── cli/ # CLI 命令注册 (Commander.js)
│ ├── build-program.ts
│ ├── command-registry.ts
│ └── register.*.ts # init/profile/log/distill/digest/gaps/add/search/...
├── profile/ # Profile 编译器 (scan → profile.md, 零 LLM)
├── memory/ # 时间维度 — 日志 + 摘要 (journal.ts)
├── vault/ # 主题维度 — PINData 结构化知识 (writer.ts)
├── config/ # 配置管理 (Zod + JSON5 + 路径管理)
├── auth/ # Google OAuth (encryption + google-oauth)
├── connectors/ # 数据收集器
│ ├── mac/ # 14 个 Mac collectors
│ ├── google/ # gmail.ts, calendar.ts
│ └── sanitize.ts
├── raw/ # Raw 层 (来源维度)
├── scraper/ # 网页抓取 (Playwright + defuddle)
├── distill/ # PINData 提取 Pipeline (extract.ts)
├── generate/ # SKILL.md 生成
├── search/ # QMD 搜索封装
├── llm/ # OpenAI client
├── prompts/ # Prompt 模板 (extract.ts, generate.ts)
├── ask/ # Ask agent (Vercel AI SDK + tools)
├── utils/ # 工具函数
├── types.ts # 全局类型
├── index.ts # Public API
└── entry.ts # CLI 入口数据目录
~/.pai/
├── profile.md # 核心产物 — 编译后的用户画像 (零 LLM)
├── memory/ # 时间维度 — 日志 + 摘要
│ ├── 2026-02-08.md # 每日 journal (pai log 追加)
│ └── weekly/ # 周摘要 (未来)
├── raw/ # 来源维度 — 原始数据 (扫描/添加)
│ ├── local/
│ ├── web/
│ └── connector/ # mac/, gmail/, calendar/
├── vault/ # 主题维度 — PINData 结构化知识
│ ├── context/ # identity.md, projects.md, services.md
│ ├── preferences/ # tools.md, workflow.md
│ ├── work/ # activity.md, finance.md
│ ├── life/ # interests.md
│ └── coding/ # lessons.md
├── credentials/ # Google OAuth: client_secret.json, google-oauth.json.enc
├── skills/profiles/ # LLM 生成的 SKILL.md (可选)
└── config/
├── pai.json5
├── profiles.json5
└── preferences.mdAgent 集成
两层记忆架构
Layer 1 (常驻): pai distribute → ~/.cursor/rules/pai-context.mdc
→ Profile (谁) + Skill (怎么用 pai), 每次对话自动注入
Layer 2 (情境): pai ask "问题" → 直接答案 (agentic,需 LLM)
或 pai context --task "当前任务" → 身份 + 相关记忆快速部署
pai init && pai distribute # 两步搞定
# Agent 在工作时调用
pai ask "What's the user's deployment preference?" # 推荐:直接拿答案
pai context --task "configure PostgreSQL connection pooling"
pai search "database performance" --json
pai log "learned: always set pool_size=20 for production" # 快速记住开发
pnpm install # 安装依赖
pnpm dev # 开发模式 (tsx)
pnpm build # 构建 (tsdown)
pnpm lint # Lint (oxlint)
pnpm typecheck # 类型检查
pnpm test # 测试 (vitest)
pnpm check # 完整门禁License
MIT
