mcpField
X
xpai-doubao-web

xpai-doubao-web

github.com/hunduncn创意与媒体1275 次安装38 周前更新
代码仓库

关于 xpai-doubao-web

通过复用 Doubao Web 浏览器登录 Cookie 生成图像或文本的命令行工具,面向需要在 CLI 中使用 Doubao Web 的用户。支持提示词文件、参考图、预设和会话;首次自动化前需取得明确同意。

主要功能

  1. 01生成图像或文本
  2. 02读取提示词文件和参考图
  3. 03预设提示词前后缀
  4. 04保存并列出会话
  5. 05JSON 输出与登录刷新

适用场景

  1. 01根据提示词生成图像
  2. 02使用参考图进行视觉输入
  3. 03通过会话进行多轮对话

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/hunduncn/xpai-doubao-web --skill xpai-doubao-web

安装后在 Claude Code 中输入/xpai-doubao-web确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

README.md
agents/
openai.yaml
references/
presets.example.json
scripts/
main.ts
scripts/doubao-webapi/
config.ts
presets.ts
types.ts
client.ts

详细介绍

XPAI Doubao Web

概述

使用此技能,通过复用浏览器登录 Cookie,从 Doubao Web 生成图像或文本。它提供了 CLI 封装,支持提示词文件、可选参考图像、预设、会话和 JSON 输出。

脚本目录

此技能的所有脚本都位于 scripts/ 子目录中。

脚本参考:

  • scripts/main.ts:CLI 入口(图像/文本)
  • scripts/doubao-webapi/*:TypeScript 客户端和辅助工具

同意检查(首次使用前必需)

此技能依赖逆向工程得到的网页行为,并会访问/存储你的 Doubao Web Cookie。 运行自动化操作前,必须获得用户的明确同意。

同意文件位置:

  • macOS:~/Library/Application Support/xpai-skills/doubao-web/consent.json
  • Linux:~/.local/share/xpai-skills/doubao-web/consent.json
  • Windows:%APPDATA%\\xpai-skills\\doubao-web\\consent.json

同意文件格式: {"version":1,"accepted":true,"acceptedAt":"<ISO>","disclaimerVersion":"1.0"}

偏好设置(EXTEND.md)

按以下顺序检查可选的 EXTEND.md 覆盖项:

# Project-level first
test -f .xpai-skills/xpai-doubao-web/EXTEND.md && echo "project"

# Then user-level
test -f "$HOME/.xpai-skills/xpai-doubao-web/EXTEND.md" && echo "user"

支持的设置(如果你为其添加解析功能):默认模型、代理设置、自定义数据目录。

用法

# Text-to-image
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts "Your prompt"

# Text-only
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --mode text --prompt "Summarize this article"

# Specify model
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --prompt "Your prompt" --model doubao-default

# Generate an image file
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --prompt "A cute cat" --image out.png

# Prompt from files
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --promptfiles system.md content.md --image out.png

# Vision input (reference images)
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --prompt "Create variation" --reference a.png --image out.png

# Preset (aspect ratio via prompt prefix/suffix)
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --preset xiaohongshu_cover --prompt "Minimalist poster" --image out.png

# List presets
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts --list-presets

# Multi-turn sessions
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts "Remember: 42" --sessionId session-abc
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts "What number?" --sessionId session-abc

# JSON output
npx -y bun /Users/aqxp/Aicodingmac/test2/xpai-doubao-web/scripts/main.ts "Hello" --json

选项

  • --prompt、-p:提示词文本
  • --promptfiles:从文件读取提示词(串联)
  • --model、-m:模型字符串(直接传递)
  • --mode:image(默认)或 text
  • --preset:预设名称(应用提示词前缀/后缀;默认 xiaohongshu_cover)
  • --image [path]:生成图像(默认:generated.png)
  • --reference、--ref:用于视觉输入的参考图像
  • --sessionId:多轮对话的会话 ID
  • --list-sessions:列出已保存的会话
  • --list-presets:列出预设名称和配置路径
  • --json:以 JSON 格式输出
  • --login:刷新 Cookie,然后退出
  • --cookie-path:自定义 Cookie 文件路径
  • --profile-dir:Chrome 配置文件目录

身份验证

登录使用浏览器 Cookie。CLI 支持:

  • 使用 --login 触发基于浏览器的刷新(通过 Playwright 实现)。
  • 使用 --cookie-path 或 DOUBAO_WEB_COOKIE_PATH 指定导出的 Cookie 文件。

流程说明:

  • --login 会打开一个可见的浏览器窗口并保存 Cookie。
  • 默认情况下,图像/文本生成以无头模式运行(不显示窗口)。设置 DOUBAO_WEB_HEADLESS=0 可显示浏览器。
  • 如果 Cookie 文件已存在,生成过程会直接进行,不会打开浏览器。
  • 若要强制重新登录,请删除 Cookie 文件或再次运行 --login。

对于 --login 和图像生成,请安装 Playwright 及其浏览器:

npm i -D playwright
npx playwright install

支持的浏览器(Playwright):Chromium/Chrome/Edge。 通过 DOUBAO_WEB_CHROME_PATH 覆盖浏览器路径。如果传入 --profile-dir,它将用作 Playwright 用户数据目录。

预设

预设配置路径优先级:

  1. DOUBAO_WEB_PRESETS_PATH
  2. .xpai-skills/xpai-doubao-web/presets.json(项目)
  3. $HOME/.xpai-skills/xpai-doubao-web/presets.json(用户)

格式:

{
  "default": "xiaohongshu_cover",
  "presets": {
    "xiaohongshu_cover": { "prefix": "...", "suffix": "..." }
  }
}

示例文件:references/presets.example.json

环境变量

  • DOUBAO_WEB_DATA_DIR:数据目录
  • DOUBAO_WEB_COOKIE_PATH:Cookie 文件路径
  • DOUBAO_WEB_HEADLESS:设置为 0 可在有头模式下运行浏览器(默认:无头)
  • DOUBAO_WEB_MAX_IMAGES:最多保存的图像数量(默认:1)
  • DOUBAO_WEB_LOGIN_URL:在浏览器中打开的登录 URL(默认:https://www.doubao.com/)
  • DOUBAO_WEB_COOKIE_DOMAIN:按域名筛选 Cookie(默认:doubao.com)
  • DOUBAO_WEB_PRESETS_PATH:预设配置文件路径
  • DOUBAO_WEB_INPUT_SELECTOR:提示词输入框的自定义选择器
  • DOUBAO_WEB_OUTPUT_SELECTOR:最新助手消息的自定义选择器
  • DOUBAO_WEB_CHROME_PROFILE_DIR:Chrome 配置文件目录
  • DOUBAO_WEB_CHROME_PATH:Chrome 可执行文件路径
  • HTTP_PROXY、HTTPS_PROXY:网页访问代理

会话

会话文件存储在数据目录下的 sessions/<id>.json 中。

包含:id、conversationUrl、messages、时间戳。设置 --sessionId 时,会在 profiles/<id>/ 下存储持久化的 Playwright 配置文件,以保留登录状态。

评论

支持 Markdown