baoyu-danger-x-to-markdown
将X(推特)推文及文章转换为带YAML前置元数据的Markdown格式。采用逆向工程API,需获得用户授权方可使用。当用户提及"X转markdown"、"推文转markdown"、"保存推文"或提供x.com/twitter.com链接请求转换时启用此功能。
X to Markdown
Converts X content to markdown:
Script Directory
Scripts located in scripts/ subdirectory.
Path Resolution:
SKILL_DIR = this SKILL.md's directory${SKILL_DIR}/scripts/main.tsConsent 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.jsonLinux
cat ~/.local/share/baoyu-skills/x-to-markdown/consent.jsonStep 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:
DISCLAIMERThis 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)
Use Bash to check EXTEND.md existence (priority order):
# Check project-level first
test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "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 │ Use defaults │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md Supports: Default output directory | Output format preferences
Usage
npx -y bun ${SKILL_DIR}/scripts/main.ts <url>
npx -y bun ${SKILL_DIR}/scripts/main.ts <url> -o output.md
npx -y bun ${SKILL_DIR}/scripts/main.ts <url> --jsonOptions
| Option | Description |
|---|---|
<url> | Tweet or article URL |
-o <path> | Output path |
--json | JSON output |
--login | Refresh cookies only |
Supported URLs
https://x.com//status/ https://twitter.com//status/ https://x.com/i/article/Output
---
url: https://x.com/user/status/123
author: "Name (@user)"
tweet_count: 3
Content...
File structure: x-to-markdown/{username}/{tweet-id}.md
Authentication
X_AUTH_TOKEN, X_CT0Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.