mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-25 11:29:47 +08:00
refactor(baoyu-danger-x-to-markdown): add openclaw metadata, baseDir rename, and dynamic script path
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
---
|
---
|
||||||
name: baoyu-danger-x-to-markdown
|
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.
|
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
|
# X to Markdown
|
||||||
@@ -14,8 +22,8 @@ Converts X content to markdown:
|
|||||||
Scripts located in `scripts/` subdirectory.
|
Scripts located in `scripts/` subdirectory.
|
||||||
|
|
||||||
**Path Resolution**:
|
**Path Resolution**:
|
||||||
1. `SKILL_DIR` = this SKILL.md's directory
|
1. `{baseDir}` = this SKILL.md's directory
|
||||||
2. Script path = `${SKILL_DIR}/scripts/main.ts`
|
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
|
3. Resolve `${BUN_X}` runtime: if `bun` installed → `bun`; if `npx` available → `npx -y bun`; else suggest installing bun
|
||||||
|
|
||||||
## Consent Requirement
|
## Consent Requirement
|
||||||
@@ -140,10 +148,10 @@ Full reference: [references/config/first-time-setup.md](references/config/first-
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
${BUN_X} ${SKILL_DIR}/scripts/main.ts <url>
|
${BUN_X} {baseDir}/scripts/main.ts <url>
|
||||||
${BUN_X} ${SKILL_DIR}/scripts/main.ts <url> -o output.md
|
${BUN_X} {baseDir}/scripts/main.ts <url> -o output.md
|
||||||
${BUN_X} ${SKILL_DIR}/scripts/main.ts <url> --download-media
|
${BUN_X} {baseDir}/scripts/main.ts <url> --download-media
|
||||||
${BUN_X} ${SKILL_DIR}/scripts/main.ts <url> --json
|
${BUN_X} {baseDir}/scripts/main.ts <url> --json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|||||||
@@ -30,8 +30,22 @@ type ConsentRecord = {
|
|||||||
|
|
||||||
const DISCLAIMER_VERSION = "1.0";
|
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 {
|
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
|
console.log(`X (Twitter) to Markdown
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|||||||
@@ -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 {
|
function parseTweetId(input: string): string | null {
|
||||||
const trimmed = input.trim();
|
const trimmed = input.trim();
|
||||||
if (!trimmed) return null;
|
if (!trimmed) return null;
|
||||||
@@ -179,7 +193,7 @@ async function main() {
|
|||||||
const { url } = parseArgs();
|
const { url } = parseArgs();
|
||||||
if (!url) {
|
if (!url) {
|
||||||
console.error("Usage:");
|
console.error("Usage:");
|
||||||
console.error(" npx -y bun skills/baoyu-danger-x-to-markdown/scripts/tweet-to-markdown.ts <tweet url>");
|
console.error(` ${formatScriptCommand("scripts/tweet-to-markdown.ts")} <tweet url>`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user