$npx -y skills add ECNU-ICALK/AutoSkill --skill baoyu-danger-x-to-markdownConverts X (Twitter) tweets and articles to markdown with YAML front matter. Uses reverse-engineered API requiring user consent. Use when user mentions "X to markdown", "tweet to markdown", "save tweet", or provides x.com/twitter.com URLs for conversion.
| 1 | # X to Markdown |
| 2 | |
| 3 | Converts X content to markdown: |
| 4 | - Tweets/threads → Markdown with YAML front matter |
| 5 | - X Articles → Full content extraction |
| 6 | |
| 7 | ## Script Directory |
| 8 | |
| 9 | Scripts located in `scripts/` subdirectory. |
| 10 | |
| 11 | **Path Resolution**: |
| 12 | 1. `SKILL_DIR` = this SKILL.md's directory |
| 13 | 2. Script path = `${SKILL_DIR}/scripts/main.ts` |
| 14 | |
| 15 | ## Consent Requirement |
| 16 | |
| 17 | **Before any conversion**, check and obtain consent. |
| 18 | |
| 19 | ### Consent Flow |
| 20 | |
| 21 | **Step 1**: Check consent file |
| 22 | |
| 23 | ```bash |
| 24 | # macOS |
| 25 | cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json |
| 26 | |
| 27 | # Linux |
| 28 | cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json |
| 29 | ``` |
| 30 | |
| 31 | **Step 2**: If `accepted: true` and `disclaimerVersion: "1.0"` → print warning and proceed: |
| 32 | ``` |
| 33 | Warning: Using reverse-engineered X API. Accepted on: <acceptedAt> |
| 34 | ``` |
| 35 | |
| 36 | **Step 3**: If missing or version mismatch → display disclaimer: |
| 37 | ``` |
| 38 | DISCLAIMER |
| 39 | |
| 40 | This tool uses a reverse-engineered X API, NOT official. |
| 41 | |
| 42 | Risks: |
| 43 | - May break if X changes API |
| 44 | - No guarantees or support |
| 45 | - Possible account restrictions |
| 46 | - Use at your own risk |
| 47 | |
| 48 | Accept terms and continue? |
| 49 | ``` |
| 50 | |
| 51 | Use `AskUserQuestion` with options: "Yes, I accept" | "No, I decline" |
| 52 | |
| 53 | **Step 4**: On accept → create consent file: |
| 54 | ```json |
| 55 | { |
| 56 | "version": 1, |
| 57 | "accepted": true, |
| 58 | "acceptedAt": "<ISO timestamp>", |
| 59 | "disclaimerVersion": "1.0" |
| 60 | } |
| 61 | ``` |
| 62 | |
| 63 | **Step 5**: On decline → output "User declined. Exiting." and stop. |
| 64 | |
| 65 | ## Preferences (EXTEND.md) |
| 66 | |
| 67 | Use Bash to check EXTEND.md existence (priority order): |
| 68 | |
| 69 | ```bash |
| 70 | # Check project-level first |
| 71 | test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project" |
| 72 | |
| 73 | # Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) |
| 74 | test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user" |
| 75 | ``` |
| 76 | |
| 77 | ┌────────────────────────────────────────────────────────────┬───────────────────┐ |
| 78 | │ Path │ Location │ |
| 79 | ├────────────────────────────────────────────────────────────┼───────────────────┤ |
| 80 | │ .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ Project directory │ |
| 81 | ├────────────────────────────────────────────────────────────┼───────────────────┤ |
| 82 | │ $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ User home │ |
| 83 | └────────────────────────────────────────────────────────────┴───────────────────┘ |
| 84 | |
| 85 | ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ |
| 86 | │ Result │ Action │ |
| 87 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 88 | │ Found │ Read, parse, apply settings │ |
| 89 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 90 | │ Not found │ **MUST** run first-time setup (see below) — do NOT silently create defaults │ |
| 91 | └───────────┴───────────────────────────────────────────────────────────────────────────┘ |
| 92 | |
| 93 | **EXTEND.md Supports**: Download media by default | Default output directory |
| 94 | |
| 95 | ### First-Time Setup (BLOCKING) |
| 96 | |
| 97 | **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. |
| 98 | |
| 99 | Use `AskUserQuestion` with ALL questions in ONE call: |
| 100 | |
| 101 | **Question 1** — header: "Media", question: "How to handle images and videos in tweets?" |
| 102 | - "Ask each time (Recommended)" — After saving markdown, ask whether to download media |
| 103 | - "Always download" — Always download media to local imgs/ and videos/ directories |
| 104 | - "Never download" — Keep original remote URLs in markdown |
| 105 | |
| 106 | **Question 2** — header: "Output", question: "Default output directory?" |
| 107 | - "x-to-markdown (Recommended)" — Save to ./x-to-markdown/{username}/{tweet-id}.md |
| 108 | - (User may choose "Other" to type a custom path) |
| 109 | |
| 110 | **Question 3** — header: "Save", question: "Where to save preferences?" |
| 111 | - "User (Recommended)" — ~/.baoyu-skills/ (all projects) |
| 112 | - "Project" — .baoyu-skills/ (this project only) |
| 113 | |
| 114 | After user answers, create EXTEND.md at the chosen location, confirm "Preferences saved to [path]", then continue. |
| 115 | |
| 116 | Full reference: [references/config/first-time-setup.md](references/config/first-time-setup.md) |
| 117 | |
| 118 | ### Supported Keys |
| 119 | |
| 120 | | Key | Default | Values | Description | |
| 121 | |-----|---------|--------|-------------| |
| 122 | | `download_media` | `ask` | `ask` / `1` / `0` | `ask` = prompt each time, `1` = always download, `0` = never | |
| 123 | | `default_output_dir` | empty | path or empty | Default output directory (empty = `./x-to-markdown/`) | |
| 124 | |
| 125 | **Value p |