baoyu-danger-x-to-markdown by jimliu/baoyu-skills
npx skills add https://github.com/jimliu/baoyu-skills --skill baoyu-danger-x-to-markdown将 X 内容转换为 Markdown:
脚本位于 scripts/ 子目录中。
路径解析:
{baseDir} = 此 SKILL.md 文件所在的目录{baseDir}/scripts/main.ts${BUN_X} 运行时:如果已安装 bun → bun;如果 npx 可用 → npx -y bun;否则建议安装 bun广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
在任何转换之前,检查并获取同意。
步骤 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:如果文件缺失或版本不匹配 → 显示免责声明:
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?
使用 AskUserQuestion 并提供选项:"Yes, I accept" | "No, I decline"
步骤 4:接受后 → 创建同意文件:
{
"version": 1,
"accepted": true,
"acceptedAt": "<ISO timestamp>",
"disclaimerVersion": "1.0"
}
步骤 5:拒绝后 → 输出 "User declined. Exiting." 并停止。
检查 EXTEND.md 是否存在(优先级顺序):
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user"
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "user" }
┌────────────────────────────────────────────────────────────┬───────────────────┐ │ 路径 │ 位置 │ ├────────────────────────────────────────────────────────────┼───────────────────┤ │ .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ 项目目录 │ ├────────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ 用户主目录 │ └────────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ 结果 │ 操作 │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ 找到 │ 读取、解析、应用设置 │ ├───────────┼───────────────────────────────────────────────────────────────────────────┤ │ 未找到 │ 必须 运行首次设置(见下文)— 不要静默创建默认值 │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md 支持:默认下载媒体 | 默认输出目录
关键:当未找到 EXTEND.md 时,在创建 EXTEND.md 之前,必须使用 AskUserQuestion 询问用户的偏好设置。切勿在不询问的情况下使用默认值创建 EXTEND.md。这是一个阻塞式操作 — 在设置完成之前,不要进行任何转换。
使用 AskUserQuestion 在一次调用中询问所有问题:
问题 1 — 标题:"Media",问题:"如何处理推文中的图片和视频?"
问题 2 — 标题:"Output",问题:"默认输出目录?"
问题 3 — 标题:"Save",问题:"在哪里保存偏好设置?"
用户回答后,在所选位置创建 EXTEND.md,确认"偏好设置已保存到 [路径]",然后继续。
| 键 | 默认值 | 值 | 描述 |
|---|---|---|---|
download_media | ask | ask / 1 / 0 | ask = 每次提示,1 = 总是下载,0 = 从不下载 |
default_output_dir | 空 | 路径或空 | 默认输出目录(空 = ./x-to-markdown/) |
值优先级:
--download-media, -o)${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 | 仅刷新 cookies |
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 时:
imgs/ 目录videos/ 目录基于 EXTEND.md 中的 download_media 设置:
| 设置 | 行为 |
|---|---|
1 (总是) | 使用 --download-media 标志运行脚本 |
0 (从不) | 不使用 --download-media 标志运行脚本 |
ask (默认) | 遵循下面的"每次询问"流程 |
--download-media 运行脚本 → Markdown 已保存https://)AskUserQuestion:
--download-media 运行脚本(用本地化链接覆盖 Markdown 文件)X_AUTH_TOKEN, X_CT0通过 EXTEND.md 进行自定义配置。有关路径和支持的选项,请参阅偏好设置部分。
每周安装数
12.0K
仓库
GitHub 星标数
11.8K
首次出现
Jan 19, 2026
安全审计
安装于
opencode11.0K
gemini-cli10.7K
codex10.5K
github-copilot9.8K
cursor9.7K
amp9.5K
Converts X content to markdown:
Scripts located in scripts/ subdirectory.
Path Resolution :
{baseDir} = this SKILL.md's directory{baseDir}/scripts/main.ts${BUN_X} runtime: if bun installed → bun; if npx available → npx -y bun; else suggest installing bunBefore any conversion , check and obtain consent.
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.
Check EXTEND.md existence (priority order):
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user"
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "user" }
┌────────────────────────────────────────────────────────────┬───────────────────┐ │ Path │ Location │ ├────────────────────────────────────────────────────────────┼───────────────────┤ │ .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ Project directory │ ├────────────────────────────────────────────────────────────┼───────────────────┤ │ $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
CRITICAL : When EXTEND.md is not found, you MUST useAskUserQuestion 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?"
Question 2 — header: "Output", question: "Default output directory?"
Question 3 — header: "Save", question: "Where to save preferences?"
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
| Key | Default | Values | Description |
|---|---|---|---|
download_media | ask | ask / 1 / 0 | ask = prompt each time, 1 = always download, 0 = never |
default_output_dir |
Value priority :
--download-media, -o)${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
| 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 |
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...
File structure : x-to-markdown/{username}/{tweet-id}/{content-slug}.md
When --download-media is enabled:
imgs/ next to the markdown filevideos/ next to the markdown fileBased 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 |
--download-media → markdown savedhttps:// in image/video links)AskUserQuestion:
--download-media (overwrites markdown with localized links)X_AUTH_TOKEN, X_CT0Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
Weekly Installs
12.0K
Repository
GitHub Stars
11.8K
First Seen
Jan 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode11.0K
gemini-cli10.7K
codex10.5K
github-copilot9.8K
cursor9.7K
amp9.5K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
| empty |
| path or empty |
Default output directory (empty = ./x-to-markdown/) |
| Refresh cookies only |