基于 Next.js App Router + TypeScript + Tailwind + PostgreSQL + Drizzle ORM 的单体实现,覆盖 PaperClaw 核心页面、公共 API、登录态 API、Token 态 API、RSS 抓取与本地可运行数据链路。
现在额外包含一套面向 Agent / OpenClaw 的 workspace discovery、远程 /SKILL.md 文档和本地 companion skill。
pnpm install
pnpm db:migrate
pnpm db:seed
pnpm dev打开:http://localhost:3000/
复制并编辑:
cp .env.example .env关键变量:
DATABASE_URL="postgresql://postgres:[email protected]:5432/paperclaw"DIRECT_DATABASE_URL="postgresql://postgres:[email protected]:5432/paperclaw"(可选,推荐生产环境用于 Drizzle 迁移直连)NEXT_PUBLIC_BASE_URL="http://localhost:3000"SILICONFLOW_API_KEY=""(可选,空值时使用离线规则摘要)SILICONFLOW_BASE_URL="https://api.siliconflow.cn/v1"SILICONFLOW_MODEL="deepseek-ai/DeepSeek-V3.2"RSS_FETCH_TIMEOUT_MS="20000"(可选,单个 RSS 拉取超时毫秒数)RSS_FETCH_RETRY_COUNT="2"(可选,RSS 临时错误重试次数)RSS_FETCH_RETRY_DELAY_MS="700"(可选,重试基础等待毫秒,按线性退避增长)RSS_FETCH_FEED_CONCURRENCY="6"(可选,feed 抓取并发度)CRON_SECRET或SYNC_CRON_SECRET(可选,定时同步鉴权)ADMIN_EMAILS="[email protected],[email protected]"(可选,逗号分隔;这些账号可访问后台管理员页)GITHUB_CLIENT_ID/GITHUB_CLIENT_SECRET(可选,配置后启用 GitHub 登录)GITHUB_PROXY_URL(可选,GitHub 不可直连时使用,如 ClashX 的http://127.0.0.1:7890)GITHUB_OAUTH_TIMEOUT_MS(可选,默认 20000)
数据库说明:
- 当前默认数据库为 PostgreSQL。
- Drizzle schema 位于
lib/db/schema.ts。 - 初始迁移已提交到
drizzle/。 - 开发时可使用
pnpm db:migrate应用迁移,pnpm db:studio打开 Drizzle Studio。
如果你本地用 Homebrew 管理 PostgreSQL,可直接按下面操作:
brew install postgresql@17
brew services start postgresql@17
createuser -h 127.0.0.1 -p 5432 -s postgres
createdb -h 127.0.0.1 -p 5432 -U postgres paperclaw
pnpm db:migrate
pnpm db:seed常用数据库服务命令:
brew services start postgresql@17
brew services stop postgresql@17
brew services list | rg postgresqlGitHub OAuth 配置步骤:
- 在 GitHub 创建 OAuth App。
- Homepage URL 填
http://localhost:3000(或你的部署域名)。 - Authorization callback URL 填
http://localhost:3000/api/auth/github/callback(或对应线上地址)。 - 将 Client ID/Secret 写入
.env后重启pnpm dev。
如果 GitHub 登录报网络错误:
- 配置
GITHUB_PROXY_URL=http://127.0.0.1:7890(按你的 ClashX 端口调整)。 - 保留
NO_PROXY=localhost,127.0.0.1(避免本地回调被代理)。 - 重启服务后再试。
//insights/article/[id]/articles/[date]/favorites/feeds/about/auth/login/subscriptions/subscriptions/settings/admin(仅ADMIN_EMAILS白名单用户可访问)/marketplace/pricing
公共:
GET /api/workspacesGET /api/workspaces/[workspace]GET /api/workspaces/[workspace]/archiveGET /api/workspaces/[workspace]/tagsGET /api/workspaces/[workspace]/feedsGET /api/workspaces/[workspace]/search?q=...GET /api/workspaces/[workspace]/articles/latest?ack=&rationale=&pstate=&token=GET /api/workspaces/[workspace]/articles/[date]?ack=&rationale=&pstate=&token=GET /api/workspaces/[workspace]/content/[id]?ack=GET /api/workspaces/[workspace]/content?ids=id1,id2&ack=GET /api/archiveGET /api/tagsGET /api/feedsGET /api/search?q=...(至少 2 字符)GET /api/articles/latest?tags=&ack=&rationale=&pstate=&token=GET /api/articles/[date]?tags=&ack=&rationale=&pstate=&token=GET /api/content/[id]?ack=GET /api/content?ids=id1,id2&ack=GET /llms-full.txt?ack=GET /SKILL.mdGET /api/workspaces/[workspace]GET /.well-known/ai-plugin.json
登录态:
GET/POST/DELETE /api/user/feedsGET/POST/DELETE /api/user/workspacesGET/POST /api/user/notesGET/POST/DELETE /api/user/tokenGET/POST/DELETE /api/user/favoritesPOST /api/user/favorites/importGET/POST /api/user/settingsPOST /api/insights/tasksPOST /api/admin/sync(仅ADMIN_EMAILS白名单用户;手动触发指定订阅的内容同步)
Token 态:
GET /api/agent/feeds?ack=&token=
说明:
/api/workspaces/[workspace]/*是 Agent 的规范入口。- 根级
/api/*保留为默认 workspace 的兼容别名。 /SKILL.md是站点级索引 skill,/api/workspaces/[workspace]提供 workspace 专属元数据与链接。
ack缺失:403 Skill acknowledgment requiredrationale缺失:400pstate缺失或非法:400pstate=has_token但无token:400ack当前值见/SKILL.md(当前实现为paperclaw-v1)search关键字<2:400user/*未登录:401- 匿名收藏存
localStorage,登录后自动迁移到云端 - 标签过滤支持前缀匹配(例如
AI匹配AI/LLM/Agent) - Pro 功能(notes/settings 保存)已做权限 gating
/api/workspaces返回多 workspace discovery 元数据,供 Agent 先做选择再进入具体 skill
- 工作区注册表:
data/workspaces/registry.ts - 每个类别的配置:
data/workspaces/<slug>/manifest.json - 每个类别的源清单:
data/workspaces/<slug>/sources.json - 每个类别现在还包含
manifest.json里的agent配置块,用来生成 workspace skill 和 discovery 元数据 - 本地 companion skill:
skills/paperclaw-remote/ - 默认源抓取口径(对齐 reference):
- 仅保留相对当前执行时刻向前 48 小时内的文章
- 不做“每源限量”,按全局文章池执行 48h 过滤
- 若 48 小时窗口内无文章,回退为全局最新 50 篇
- 所有文章都严格按文章发布时间分桶;缺失发布时间时进入
unknown - 缺失发布时间的文章允许入库,
published_at在 API 中返回空字符串 - 48h 窗口锚点为同步任务执行时刻(与 reference pipeline 一致)
--date=YYYY-MM-DD仅控制本次同步锚点和 run 记录,不改变文章按发布时间分组的规则- 每次抓取都会与历史已入库文章做去重;重复文章不会再次走摘要/打标/快照更新
- 用户订阅源抓取保持原行为(不应用上面的默认源 48h 过滤)
- 种子数据:
data/seed-articles.json - 抓取脚本:
pnpm sync:feeds(默认 92 源)pnpm sync:feeds -- --workspace=managementpnpm sync:feeds -- --workspace=economicspnpm sync:feeds -- --date=2026-03-07(按指定同步锚点抓取,文章仍按发布时间分组)pnpm sync:feeds -- --date=2026-03-07 --reset-date(强制重新处理本轮抓到的已存在文章,并重置该同步锚点对应 run)pnpm sync:user-feeds(用户订阅源)
- 自动抓取(每日):
- 内部接口:
/api/internal/sync/default - 鉴权:
Authorization: Bearer <CRON_SECRET> - 未传
workspace时,入口只负责分发后台任务;传?workspace=<slug>时只同步指定 workspace - 分发后会按 workspace 拆成多个独立函数执行,避免单个请求卡满 5 分钟
- 同步 curated source 后,会自动补齐已订阅该 workspace 的用户 source 关联
- 已提供
vercel.jsoncron:每天 UTC16:00触发一次,对应北京时间次日00:00 - 同步不会自动生成洞察;洞察需要在
/insights页面手动创建任务
- 内部接口:
说明:无 SILICONFLOW_API_KEY 时,摘要/标签走离线规则;有 key 时自动增强。
工作区/社区扩展说明见:
docs/community-workspaces.md
OpenClaw / Agent 使用说明:
- 远程入口先读
/SKILL.md - 发现 workspace 用
/api/workspaces - 选择后读
/api/workspaces/<workspace> - 本地可安装的 companion skill 在
skills/paperclaw-remote/
类型与构建:
pnpm typecheck
pnpm lint
pnpm buildE2E(Playwright):
pnpm exec playwright install
pnpm test:e2e已包含:
- API 合约测试:
tests/e2e/api-contract.spec.ts - 登录到阅读收藏主链路:
tests/e2e/user-journey.spec.ts
- Magic Link 在本地模式直接返回登录链接,便于开发测试。
- Pro 支付链路暂未接入真实支付,当前为权限模型与 UI 占位。
参考站点: 站点:https://www.dailybit.cc/