diff --git a/skills/baoyu-danger-x-to-markdown/SKILL.md b/skills/baoyu-danger-x-to-markdown/SKILL.md index d8c60eb..8feace3 100644 --- a/skills/baoyu-danger-x-to-markdown/SKILL.md +++ b/skills/baoyu-danger-x-to-markdown/SKILL.md @@ -1,6 +1,14 @@ --- name: baoyu-danger-x-to-markdown description: Converts 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. +version: 1.56.1 +metadata: + openclaw: + homepage: https://github.com/JimLiu/baoyu-skills#baoyu-danger-x-to-markdown + requires: + anyBins: + - bun + - npx --- # X to Markdown @@ -14,8 +22,8 @@ Converts X content to markdown: Scripts located in `scripts/` subdirectory. **Path Resolution**: -1. `SKILL_DIR` = this SKILL.md's directory -2. Script path = `${SKILL_DIR}/scripts/main.ts` +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 @@ -140,10 +148,10 @@ Full reference: [references/config/first-time-setup.md](references/config/first- ## Usage ```bash -${BUN_X} ${SKILL_DIR}/scripts/main.ts -${BUN_X} ${SKILL_DIR}/scripts/main.ts -o output.md -${BUN_X} ${SKILL_DIR}/scripts/main.ts --download-media -${BUN_X} ${SKILL_DIR}/scripts/main.ts --json +${BUN_X} {baseDir}/scripts/main.ts +${BUN_X} {baseDir}/scripts/main.ts -o output.md +${BUN_X} {baseDir}/scripts/main.ts --download-media +${BUN_X} {baseDir}/scripts/main.ts --json ``` ## Options diff --git a/skills/baoyu-danger-x-to-markdown/scripts/main.ts b/skills/baoyu-danger-x-to-markdown/scripts/main.ts index 74b7d34..43cafe8 100644 --- a/skills/baoyu-danger-x-to-markdown/scripts/main.ts +++ b/skills/baoyu-danger-x-to-markdown/scripts/main.ts @@ -30,8 +30,22 @@ type ConsentRecord = { const DISCLAIMER_VERSION = "1.0"; +function formatScriptCommand(fallback: string): string { + const raw = process.argv[1]; + const displayPath = raw + ? (() => { + const relative = path.relative(process.cwd(), raw); + return relative && !relative.startsWith("..") ? relative : raw; + })() + : fallback; + const quotedPath = displayPath.includes(" ") + ? `"${displayPath.replace(/"/g, '\\"')}"` + : displayPath; + return `npx -y bun ${quotedPath}`; +} + function printUsage(exitCode: number): never { - const cmd = "npx -y bun skills/baoyu-danger-x-to-markdown/scripts/main.ts"; + const cmd = formatScriptCommand("scripts/main.ts"); console.log(`X (Twitter) to Markdown Usage: diff --git a/skills/baoyu-danger-x-to-markdown/scripts/tweet-to-markdown.ts b/skills/baoyu-danger-x-to-markdown/scripts/tweet-to-markdown.ts index 57d0853..998940b 100644 --- a/skills/baoyu-danger-x-to-markdown/scripts/tweet-to-markdown.ts +++ b/skills/baoyu-danger-x-to-markdown/scripts/tweet-to-markdown.ts @@ -36,6 +36,20 @@ function normalizeInputUrl(input: string): string { } } +function formatScriptCommand(fallback: string): string { + const raw = process.argv[1]; + const displayPath = raw + ? (() => { + const relative = path.relative(process.cwd(), raw); + return relative && !relative.startsWith("..") ? relative : raw; + })() + : fallback; + const quotedPath = displayPath.includes(" ") + ? `"${displayPath.replace(/"/g, '\\"')}"` + : displayPath; + return `npx -y bun ${quotedPath}`; +} + function parseTweetId(input: string): string | null { const trimmed = input.trim(); if (!trimmed) return null; @@ -179,7 +193,7 @@ async function main() { const { url } = parseArgs(); if (!url) { console.error("Usage:"); - console.error(" npx -y bun skills/baoyu-danger-x-to-markdown/scripts/tweet-to-markdown.ts "); + console.error(` ${formatScriptCommand("scripts/tweet-to-markdown.ts")} `); process.exit(1); }