baoyu-danger-x-to-markdown
- 作者仓库星标 0
- 作者更新于 2026年7月4日 09:22
- 作者仓库 baoyu-skills
X 转 Markdown
将 X 内容转换为 Markdown:
- 推文/帖子 → 带有 YAML front matter 的 Markdown
- X 文章 → 完整内容提取
用户输入工具
当此技能提示用户时,请遵循以下工具选择规则(优先级顺序):
- 优先使用当前 Agent 运行时公开的内置用户输入工具 — 例如,
AskUserQuestion、request_user_input、clarify、ask_user或任何等效工具。 - 回退方案:如果不存在此类工具,则输出带编号的纯文本消息,并要求用户回复所选问题的编号/答案。
- 批量处理:如果工具支持每次调用多个问题,则将所有适用问题合并到一次调用中;如果只支持单个问题,则按优先级顺序逐一提问。
下面具体的 AskUserQuestion 引用是示例 — 在其他运行时中请替换为本地等效工具。
脚本目录
脚本位于 scripts/ 子目录中。
路径解析:
{baseDir}= 此 SKILL.md 的目录- 脚本路径 =
{baseDir}/scripts/main.ts - 解析
${BUN_X}运行时:如果安装了bun→bun;如果npx可用 →npx -y bun;否则建议安装 bun
同意要求
在任何转换之前,请检查并获取用户同意。
同意流程
步骤 1:检查同意文件
# macOS
cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json
# Linux
cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json
步骤 2:如果 accepted: true 且 disclaimerVersion: "1.0" → 打印警告并继续:
Warning: Using reverse-engineered X API. Accepted on: <acceptedAt>
步骤 3:如果缺失或版本不匹配 → 显示免责声明:
免责声明
此工具使用逆向工程的 X API,而非官方 API。
风险:
- 如果 X 更改 API,可能会失效
- 不提供任何保证或支持
- 可能导致账户受限
- 使用风险自负
接受条款并继续吗?
使用 AskUserQuestion 并提供选项:"是,我接受" | "否,我拒绝"
步骤 4:如果接受 → 创建同意文件:
{
"version": 1,
"accepted": true,
"acceptedAt": "<ISO timestamp>",
"disclaimerVersion": "1.0"
}
步骤 5:如果拒绝 → 输出 "用户拒绝。退出。" 并停止。
首选项 (EXTEND.md)
按优先级顺序检查 EXTEND.md — 找到的第一个生效:
| 优先级 | 路径 | 范围 |
|---|---|---|
| 1 | .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md |
项目 |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md |
用户主目录 |
| 结果 | 操作 |
|---|---|
| 找到 | 读取、解析、应用设置 |
| 未找到 | 必须运行首次设置(见下文)— 不要静默创建默认值 |
EXTEND.md 支持:默认下载媒体、默认输出目录。
首次设置(阻塞)
关键:当未找到 EXTEND.md 时,您必须使用 AskUserQuestion 询问用户他们的偏好,然后才能创建 EXTEND.md。绝不能在未询问的情况下创建带有默认值的 EXTEND.md。这是一个阻塞操作 — 在设置完成之前,不要进行任何转换。
使用 AskUserQuestion 在一次调用中提出所有问题:
问题 1 — 标题:"媒体",问题:"如何处理推文中的图片和视频?"
- "每次询问(推荐)" — 保存 Markdown 后,询问是否下载媒体
- "始终下载" — 始终将媒体下载到本地 imgs/ 和 videos/ 目录
- "从不下载" — 在 Markdown 中保留原始远程 URL
问题 2 — 标题:"输出",问题:"默认输出目录?"
- "x-to-markdown(推荐)" — 保存到 ./x-to-markdown/{username}/{tweet-id}.md
- (用户可以选择 "其他" 输入自定义路径)
问题 3 — 标题:"保存",问题:"将偏好设置保存到何处?"
- "用户(推荐)" — ~/.baoyu-skills/ (所有项目)
- "项目" — .baoyu-skills/ (仅此项目)
用户回答后,在所选位置创建 EXTEND.md,确认 "偏好设置已保存到 [路径]",然后继续。
完整参考:references/config/first-time-setup.md
支持的键
| 键 | 默认值 | 值 | 描述 |
|---|---|---|---|
download_media |
ask |
ask / 1 / 0 |
ask = 每次提示,1 = 始终下载,0 = 从不下载 |
default_output_dir |
空 | 路径或空 | 默认输出目录(空 = ./x-to-markdown/) |
值优先级:
- CLI 参数 (
--download-media,-o) - EXTEND.md
- 技能默认值
用法
${BUN_X} {baseDir}/scripts/main.ts <url>
${BUN_X} {baseDir}/scripts/main.ts <url> -o output.md
${BUN_X} {baseDir}/scripts/main.ts <url> --download-media
${BUN_X} {baseDir}/scripts/main.ts <url> --json
选项
| 选项 | 描述 |
|---|---|
<url> |
推文或文章 URL |
-o <path> |
输出路径 |
--json |
JSON 输出 |
--download-media |
将图片/视频资产下载到本地 imgs/ 和 videos/ 目录,并重写 Markdown 链接为本地相对路径 |
--login |
仅刷新 cookie |
支持的 URL
https://x.com/<user>/status/<id>https://twitter.com/<user>/status/<id>https://x.com/i/article/<id>
输出
---
url: "https://x.com/user/status/123"
author: "Name (@user)"
tweetCount: 3
coverImage: "https://pbs.twimg.com/media/example.jpg"
---
Content...
文件结构:x-to-markdown/{username}/{tweet-id}/{content-slug}.md
当启用 --download-media 时:
- 图片保存到 Markdown 文件旁边的
imgs/目录 - 视频保存到 Markdown 文件旁边的
videos/目录 - Markdown 媒体链接被重写为本地相对路径
媒体下载工作流
基于 EXTEND.md 中的 download_media 设置:
| 设置 | 行为 |
|---|---|
1 (始终) |
使用 --download-media 标志运行脚本 |
0 (从不) |
不带 --download-media 标志运行脚本 |
ask (默认) |
遵循下面的每次询问流程 |
每次询问流程
- 不带
--download-media运行脚本 → Markdown 已保存 - 检查已保存的 Markdown 中是否存在远程媒体 URL(图片/视频链接中的
https://) - 如果未找到远程媒体 → 完成,无需提示
- 如果找到远程媒体 → 使用
AskUserQuestion:- 标题:"媒体",问题:"下载 N 张图片/视频到本地文件吗?"
- "是" — 下载到本地目录
- "否" — 保留远程 URL
- 如果用户确认 → 再次运行脚本,带上
--download-media(用本地化链接覆盖 Markdown)
认证
- 环境变量(首选):
X_AUTH_TOKEN、X_CT0 - Chrome 登录(回退):自动打开 Chrome,在本地缓存 cookie
扩展支持
通过 EXTEND.md 进行自定义配置。请参阅首选项部分了解路径和支持的选项。
X to Markdown
Converts X content to markdown:
- Tweets/threads → Markdown with YAML front matter
- X Articles → Full content extraction
User Input Tools
When this skill prompts the user, follow this tool-selection rule (priority order):
- Prefer built-in user-input tools exposed by the current agent runtime — e.g.,
AskUserQuestion,request_user_input,clarify,ask_user, or any equivalent. - Fallback: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question.
- Batching: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.
Concrete AskUserQuestion references below are examples — substitute the local equivalent in other runtimes.
Script Directory
Scripts located in scripts/ subdirectory.
Path Resolution:
{baseDir}= this SKILL.md's directory- Script path =
{baseDir}/scripts/main.ts - Resolve
${BUN_X}runtime: ifbuninstalled →bun; ifnpxavailable →npx -y bun; else suggest installing bun
Consent Requirement
Before any conversion, check and obtain consent.
Consent Flow
Step 1: Check consent file
# macOS
cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json
# Linux
cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json
Step 2: If accepted: true and disclaimerVersion: "1.0" → print warning and proceed:
Warning: Using reverse-engineered X API. Accepted on: <acceptedAt>
Step 3: If missing or version mismatch → display disclaimer:
DISCLAIMER
This tool uses a reverse-engineered X API, NOT official.
Risks:
- May break if X changes API
- No guarantees or support
- Possible account restrictions
- Use at your own risk
Accept terms and continue?
Use AskUserQuestion with options: "Yes, I accept" | "No, I decline"
Step 4: On accept → create consent file:
{
"version": 1,
"accepted": true,
"acceptedAt": "<ISO timestamp>",
"disclaimerVersion": "1.0"
}
Step 5: On decline → output "User declined. Exiting." and stop.
Preferences (EXTEND.md)
Check EXTEND.md in priority order — the first one found wins:
| Priority | Path | Scope |
|---|---|---|
| 1 | .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md |
Project |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md |
User home |
| Result | Action |
|---|---|
| Found | Read, parse, apply settings |
| Not found | MUST run first-time setup (see below) — do NOT silently create defaults |
EXTEND.md supports: Download media by default, default output directory.
First-Time Setup (BLOCKING)
CRITICAL: When EXTEND.md is not found, you MUST use AskUserQuestion to ask the user for their preferences before creating EXTEND.md. NEVER create EXTEND.md with defaults without asking. This is a BLOCKING operation — do NOT proceed with any conversion until setup is complete.
Use AskUserQuestion with ALL questions in ONE call:
Question 1 — header: "Media", question: "How to handle images and videos in tweets?"
- "Ask each time (Recommended)" — After saving markdown, ask whether to download media
- "Always download" — Always download media to local imgs/ and videos/ directories
- "Never download" — Keep original remote URLs in markdown
Question 2 — header: "Output", question: "Default output directory?"
- "x-to-markdown (Recommended)" — Save to ./x-to-markdown/{username}/{tweet-id}.md
- (User may choose "Other" to type a custom path)
Question 3 — header: "Save", question: "Where to save preferences?"
- "User (Recommended)" — ~/.baoyu-skills/ (all projects)
- "Project" — .baoyu-skills/ (this project only)
After user answers, create EXTEND.md at the chosen location, confirm "Preferences saved to [path]", then continue.
Full reference: references/config/first-time-setup.md
Supported Keys
| Key | Default | Values | Description |
|---|---|---|---|
download_media |
ask |
ask / 1 / 0 |
ask = prompt each time, 1 = always download, 0 = never |
default_output_dir |
empty | path or empty | Default output directory (empty = ./x-to-markdown/) |
Value priority:
- CLI arguments (
--download-media,-o) - EXTEND.md
- Skill defaults
Usage
${BUN_X} {baseDir}/scripts/main.ts <url>
${BUN_X} {baseDir}/scripts/main.ts <url> -o output.md
${BUN_X} {baseDir}/scripts/main.ts <url> --download-media
${BUN_X} {baseDir}/scripts/main.ts <url> --json
Options
| Option | Description |
|---|---|
<url> |
Tweet or article URL |
-o <path> |
Output path |
--json |
JSON output |
--download-media |
Download image/video assets to local imgs/ and videos/, and rewrite markdown links to local relative paths |
--login |
Refresh cookies only |
Supported URLs
https://x.com/<user>/status/<id>https://twitter.com/<user>/status/<id>https://x.com/i/article/<id>
Output
---
url: "https://x.com/user/status/123"
author: "Name (@user)"
tweetCount: 3
coverImage: "https://pbs.twimg.com/media/example.jpg"
---
Content...
File structure: x-to-markdown/{username}/{tweet-id}/{content-slug}.md
When --download-media is enabled:
- Images are saved to
imgs/next to the markdown file - Videos are saved to
videos/next to the markdown file - Markdown media links are rewritten to local relative paths
Media Download Workflow
Based on download_media setting in EXTEND.md:
| Setting | Behavior |
|---|---|
1 (always) |
Run script with --download-media flag |
0 (never) |
Run script without --download-media flag |
ask (default) |
Follow the ask-each-time flow below |
Ask-Each-Time Flow
- Run script without
--download-media→ markdown saved - Check saved markdown for remote media URLs (
https://in image/video links) - If no remote media found → done, no prompt needed
- If remote media found → use
AskUserQuestion:- header: "Media", question: "Download N images/videos to local files?"
- "Yes" — Download to local directories
- "No" — Keep remote URLs
- If user confirms → run script again with
--download-media(overwrites markdown with localized links)
Authentication
- Environment variables (preferred):
X_AUTH_TOKEN,X_CT0 - Chrome login (fallback): Auto-opens Chrome, caches cookies locally
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
- 流狐分类
- 文档
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 92 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @JimLiu · v1.117.3 · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 即装即用
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- macOS · Linux
- 底层运行要求
- Bun
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 When this skill prompts the user, follow this tool-selection rule (priority order): Prefer built-in user-input tools exposed by the current agent runtime — e.g., AskUserQuestion, requestuserinput, clarify, askuser, or any equivalent.
Scripts located in scripts/ subdirectory. Path Resolution: {baseDir} = this SKILL.md's directory
Before any conversion, check and obtain consent.
Step 1: Check consent file Step 2: If accepted: true and disclaimerVersion: "1.0" → print warning and proceed: Step 3: If missing or version mismatch → display disclaimer:
Check EXTEND.md in priority order — the first one found wins: Priority · Path · Scope 1 · .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md · Project
CRITICAL: When EXTEND.md is not found, you MUST use AskUserQuestion to ask the user for their preferences before creating EXTEND.md. NEVER create EXTEND.md with defaults without asking. This is a BLOCKING operation — do NOT proceed with any conversion until…
# X to Markdown
Converts X content to markdown:
- Tweets/threads → Markdown with YAML front matter
- X Articles → Full content extraction
## User Input Tools
When this skill prompts the user, follow this tool-selection rule (priority order):
1. **Prefer built-in user-input tools** exposed by the current agent runtime — e.g., `AskUserQuestion`, `request_user_input`, `clarify`, `ask_user`, or any equivalent.
2. **Fallback**: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question.
3. **Batching**: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.
Concrete `AskUserQuestion` references below are examples — substitute the local equivalent in other runtimes.
## Script Directory
Scripts located in `scripts/` subdirectory.
**Path Resolution**:
1. `{baseDir}` = this SKILL.md's directory
2. Script path = `{baseDir}/scripts/main.ts`
3. Resolve `${BUN_X}` runtime: if `bun` installed → `bun`; if `npx` available → `npx -y bun`; else suggest installing bun
## Consent Requirement
**Before any conversion**, check and obtain consent.
### Consent Flow
**Step 1**: Check consent file
```bash
# macOS
cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json
# Linux
cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json
```
**Step 2**: If `accepted: true` and `disclaimerVersion: "1.0"` → print warning and proceed:
```
Warning: Using reverse-engineered X API. Accepted on: <acceptedAt>
```
**Step 3**: If missing or version mismatch → display disclaimer:
```
DISCLAIMER
This tool uses a reverse-engineered X API, NOT official.
Risks:
- May break if X changes API
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> User Input Tools → Script Directory → Consent Requirement → Consent Flow → Preferences (EXTEND.md) → First-Time Setup (BLOCKING)
要点 -> Prefer built-in user-input tools · Fallback · Batching · Path Resolution · Before any conversion · Step 1 · Step 2 · Step 3
文件/命令 -> AskUserQuestion · requestuserinput · clarify · askuser · scripts/ · {baseDir} · {baseDir}/scripts/main.ts · ${BUNX}
内容 SHA-256 -> 3ca6376ec635
baoyu-danger-x-to-markdown 把 X(Twitter)上的推文 / 长推文(X Articles)转成带 YAML frontmatter 的 Markdown,本地归档用。
设计思路
作者把它定位成「写作素材抓取器」——X 上看到一段值得保存的推文串、一篇 X Articles 长文,复制链接给这个技能,几秒钟后得到一份 Markdown,可以直接贴进 Obsidian、博客 RSS、读书笔记。它不像 RSS 那样定时拉,是「需要时按需抓」。
Consent Requirement
和
baoyu-danger-gemini-web同样设了 Consent Requirement——它用 X 内部 API(reverse-engineered),需要用户明确同意。X 已多次更新反爬,所以技能名字里也带danger提醒你这是非官方路径。输出格式
Output 章节里说得很具体:每条推文 / 文章都生成一个
.md文件,顶部是 YAML frontmatter(含作者、原始 URL、抓取时间、媒体列表),下面是清洗后的正文 Markdown。媒体(图、视频)按 Media Download Workflow 下载到本地附件夹。支持范围
Supported URLs 章节列出:单条推文、推文串(thread)、X Articles 长文、空间(Spaces)暂不支持。
Authentication
基于浏览器 session,需要登录的 X 账号——这样能抓到只对登录用户开放的推文。
适合谁
风险与限制
配套
和
baoyu-format-markdown、baoyu-post-to-wechat配套:抓 → 格式化 → 发布。