使用 AI 生成的摘要,将你的 X(Twitter)书签归档到分类的 Markdown 文件中。
本技能使用 bird CLI 获取你的 X 书签,根据 URL 模式进行分类,利用 OpenAI 生成 AI 摘要,并将它们保存为组织有序的 Markdown 文件。
OPENAI_API_KEY 环境变量以启用 AI 摘要生成。# 确保 bird CLI 已安装并完成身份验证
bird --version
# 设置 OpenAI API 密钥(可选,用于 AI 摘要)
export OPENAI_API_KEY="sk-..."
run - 完整流程获取并处理新书签:
node skills/x-bookmark-archiver/scripts/run.cjs
run --force - 仅处理现有书签跳过获取步骤,仅处理待处理的书签:
node skills/x-bookmark-archiver/scripts/run.cjs --force
fetch - 仅下载书签node skills/x-bookmark-archiver/scripts/fetch.cjs
process - 仅归档待处理书签node skills/x-bookmark-archiver/scripts/process.cjs
书签根据 URL 模式自动分类:
| 分类 | 域名 |
|---|---|
| 工具 | github.com, gitlab.com, github.io, huggingface.co, replicate.com, vercel.com, npmjs.com, pypi.org |
| 文章 | medium.com, substack.com, dev.to, hashnode.dev, x.com/i/article, blog.*, towardsdatascience.com |
| 视频 | youtube.com, youtu.be, vimeo.com, twitch.tv |
| 研究 | arxiv.org, paperswithcode.com, semanticscholar.org, researchgate.net, dl.acm.org, ieee.org |
| 新闻 | techcrunch.com, theverge.com, hn.algolia.com, news.ycombinator.com, wired.com, arstechnica.com |
| 书签 | 未匹配 URL 的默认分类 |
Markdown 文件创建在 OpenClaw 工作空间 的以下路径:
旧版安装(旧名称):
~/clawd/X-knowledge/
新版安装:
~/.openclaw/workspace/X-knowledge/
使用配置文件时(OPENCLAW_PROFILE=prod):
~/.openclaw/workspace-prod/X-knowledge/
使用环境变量覆盖:
export OPENCLAW_WORKSPACE=/custom/path
node skills/x-bookmark-archiver/scripts/run.cjs
# 创建路径:/custom/path/X-knowledge/
~/.openclaw/workspace/X-knowledge/
├── tools/
│ ├── awesome-ai-project.md
│ └── useful-cli-tool.md
├── articles/
│ ├── how-to-build-x.md
│ └── ml-best-practices.md
├── videos/
│ └── conference-talk.md
├── research/
│ └── attention-is-all-you-need.md
├── news/
│ └── latest-tech-announcement.md
└── bookmarks/
└── misc-link.md
每个归档的书签都会生成一个包含 Frontmatter 的 Markdown 文件:
---
title: "Awesome AI Project"
type: tool
date_archived: 2026-01-31
source_tweet: https://x.com/i/web/status/1234567890
link: https://github.com/user/repo
**标签:** ["ai", "machine-learning", "github"]
---
该项目实现了一种新颖的...(AI 生成的摘要)
状态文件用于跟踪处理进度:
/root/clawd/.state/
├── x-bookmark-pending.json # 等待处理的书签
└── x-bookmark-processed.json # 已归档书签的 ID
| 变量 | 是否必需 | 描述 |
|---|---|---|
OPENAI_API_KEY |
否 | 用于 AI 生成摘要的 API 密钥 |
X-knowledge/{category}/。编辑 scripts/lib/categorize.cjs:
const CATEGORIES = {
tools: ['github.com', '...'],
your_category: ['example.com', '...'],
// ...
};
编辑 scripts/process.cjs:
const KNOWLEDGE_DIR = 'your-directory-name';
修改 scripts/process.cjs 中的 generateMetadata() 函数以使用你偏好的 API。
运行测试套件:
# 运行所有测试
cd skills/x-bookmark-archiver/tests
node test-all.cjs
# 运行单独的测试套件
node lib/categorize.test.cjs
node lib/state.test.cjs
node integration.test.cjs
categorize.js(21 个测试)- URL 模式匹配。state.js(9 个测试)- JSON 读写操作。在没有 bird CLI 的情况下,可以使用模拟数据进行测试:
# 创建模拟待处理数据
cat > /tmp/test-pending.json << 'EOF'
[
{
"id": "test123",
"url": "https://github.com/test/repo",
"text": "Test bookmark"
}
]
EOF
# 复制到状态目录并处理
mkdir -p /root/clawd/.state
cp /tmp/test-pending.json /root/clawd/.state/x-bookmark-pending.json
node skills/x-bookmark-archiver/scripts/process.cjs
| 问题 | 解决方案 |
|---|---|
bird: command not found |
从 GitHub releases 安装 bird CLI |
| 没有获取到书签 | 确保已使用 bird 登录 X |
| AI 摘要未生成 | 检查 OPENAI_API_KEY 是否已设置 |
| t.co 链接未展开 | 可能是网络/超时问题;将使用原始 URL |
skills/x-bookmark-archiver/
├── SKILL.md
├── scripts/
│ ├── fetch.cjs # 从 X 下载书签 (CommonJS)
│ ├── process.cjs # 生成 Markdown 文件 (CommonJS)
│ ├── run.cjs # 编排 fetch → process 流程 (CommonJS)
│ └── lib/
│ ├── categorize.cjs # URL → 分类映射 (CommonJS)
│ └── state.cjs # JSON 状态管理 (CommonJS)
└── tests/
├── test-all.cjs
├── lib/
│ ├── categorize.test.cjs
│ └── state.test.cjs
├── integration.test.cjs
└── fixtures/
└── sample-bookmarks.json
MIT