用途:向 X(Twitter)发布内容,包括文字、图片、视频、引用推文以及长文文章。该技能借助真实 Chrome 浏览器与 CDP 绕过自动化检测,脚本仅负责把内容填入浏览器,最终由用户人工审核并发布。
主要能力与对应脚本(均位于技能的 scripts/ 子目录,路径写作 ${SKILL_DIR}/scripts/<名称>.ts): 普通推文(文字+最多4张图片):x-browser.ts;视频推文:x-video.ts;引用推文并附评论:x-quote.ts;长文 Markdown 发布:x-article.ts;另有 md-to-html.ts、copy-to-clipboard.ts、paste-from-clipboard.ts、check-paste-permissions.ts。
基本用法示例: npx -y bun ${SKILL_DIR}/scripts/x-browser.ts "Hello!" --image ./photo.png npx -y bun ${SKILL_DIR}/scripts/x-video.ts "Check this out!" --video ./clip.mp4 npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123 "Great insight!" npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --cover ./cover.jpg 支持 --profile 指定自定义 Chrome 配置目录;文章支持 --title 覆盖标题及 YAML frontmatter 中的 title、cover_image。
配置:可选通过 EXTEND.md 自定义,优先读取项目级 .baoyu-skills/baoyu-post-to-x/EXTEND.md,其次用户级 $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md;可设置默认 Chrome 配置,未找到则用默认值。
前置条件:Google Chrome 或 Chromium、bun 运行时;首次运行需手动登录 X 以保存会话。可先运行环境检查:npx -y bun ${SKILL_DIR}/scripts/check-paste-permissions.ts。
限制与注意:视频时长普通账号最多140秒、Premium 60分钟,处理约30-60秒;X Articles 需 X Premium。若出现 Chrome debug port not ready,可先结束已有 CDP 实例再重试:pkill -f "Chrome.*remote-debugging-port" 2>/dev/null; pkill -f "Chromium.*remote-debugging-port" 2>/dev/null; sleep 2。支持 macOS、Linux、Windows。其他平台兼容性或费用细节暂未提供。