mcpField
B
baoyu-danger-gemini-web

baoyu-danger-gemini-web

github.com/xy121718创意与媒体103173 次安装35 周前更新
代码仓库

关于 baoyu-danger-gemini-web

baoyu-danger-gemini-web 是通过 Gemini Web API 生成文本和图像的命令行技能,支持参考图、多轮会话及浏览器 Google 身份验证。

主要功能

  1. 01生成文本和图像
  2. 02输入参考图
  3. 03多轮会话及会话列表
  4. 04选择 Gemini 模型
  5. 05通过浏览器验证并保存 Cookie

适用场景

  1. 01通过 Gemini Web 生成文本
  2. 02根据提示词和参考图生成图像
  3. 03使用已保存会话继续对话
  4. 04刷新 Google 身份验证 Cookie

安装

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

$npx skills add https://github.com/xy121718/baoyu-skills --skill baoyu-danger-gemini-web

安装后在 Claude Code 中输入/baoyu-danger-gemini-web确认已加载。

包含的文件

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

scripts/
main.ts
scripts/gemini-webapi/
client.ts
constants.ts
exceptions.ts
index.ts
scripts/gemini-webapi/components/
gem-mixin.ts
index.ts
scripts/gemini-webapi/types/
candidate.ts
gem.ts
grpc.ts
image.ts
index.ts
modeloutput.ts
scripts/gemini-webapi/utils/
cookie-file.ts
decorators.ts
get-access-token.ts
http.ts
index.ts
load-browser-cookies.ts
logger.ts
parsing.ts
paths.ts
rotate-1psidts.ts
upload-file.ts

详细介绍

Gemini Web 客户端

通过 Gemini Web API 生成文本/图像。支持参考图像和多轮对话。

脚本目录

重要:所有脚本都位于此 skill 的 scripts/ 子目录中。

Agent 执行说明:

  1. 将此 SKILL.md 文件所在目录路径确定为 SKILL_DIR
  2. 脚本路径 = ${SKILL_DIR}/scripts/<script-name>.ts
  3. 将本文档中的所有 ${SKILL_DIR} 替换为实际路径

脚本参考:

脚本用途
scripts/main.ts用于生成文本/图像的 CLI 入口
scripts/gemini-webapi/*gemini_webapi 的 TypeScript 移植版(GeminiClient、类型、工具函数)

同意确认(必需)

首次使用前,请确认用户是否同意使用逆向工程 API。

同意文件位置:

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

流程:

  1. 检查同意文件是否存在,且包含 accepted: true 和 disclaimerVersion: "1.0"
  2. 如果存在有效同意 → 打印包含 acceptedAt 日期的警告,然后继续
  3. 如果没有同意 → 显示免责声明,通过 AskUserQuestion 询问用户:
    • “Yes, I accept” → 创建包含 ISO 时间戳的同意文件,然后继续
    • “No, I decline” → 输出拒绝消息,然后停止
  4. 同意文件格式:{"version":1,"accepted":true,"acceptedAt":"<ISO>","disclaimerVersion":"1.0"}

偏好设置(EXTEND.md)

使用 Bash 按优先级顺序检查 EXTEND.md 是否存在:

# Check project-level first
test -f .baoyu-skills/baoyu-danger-gemini-web/EXTEND.md && echo "project"

# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md" && echo "user"

┌──────────────────────────────────────────────────────────┬───────────────────┐ │ Path │ Location │ ├──────────────────────────────────────────────────────────┼───────────────────┤ │ .baoyu-skills/baoyu-danger-gemini-web/EXTEND.md │ Project directory │ ├──────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md │ User home │ └──────────────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ Result │ Action │ ├──────────────────────────────────────────────────────────────────────────────────────┤ │ Found │ Read, parse, apply settings │ ├──────────────────────────────────────────────────────────────────────────────────────┤ │ Not found │ Use defaults │ └───────────┴───────────────────────────────────────────────────────────────────────────┘

EXTEND.md 支持:默认模型 | 代理设置 | 自定义数据目录

用法

# Text generation
npx -y bun ${SKILL_DIR}/scripts/main.ts "Your prompt"
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Your prompt" --model gemini-3-flash

# Image generation
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cute cat" --image cat.png
npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png

# Vision input (reference images)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Describe this" --reference image.png
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Create variation" --reference a.png --image out.png

# Multi-turn conversation
npx -y bun ${SKILL_DIR}/scripts/main.ts "Remember: 42" --sessionId session-abc
npx -y bun ${SKILL_DIR}/scripts/main.ts "What number?" --sessionId session-abc

# JSON output
npx -y bun ${SKILL_DIR}/scripts/main.ts "Hello" --json

选项

选项描述
--prompt、-p提示词文本
--promptfiles从文件读取提示词(拼接)
--model、-m模型:gemini-3-pro(默认)、gemini-3-flash、gemini-3-flash-thinking、gemini-3.1-pro-preview
--image [path]生成图像(默认:generated.png)
--reference、--ref用作视觉输入的参考图像
--sessionId多轮对话的会话 ID
--list-sessions列出已保存的会话
--json以 JSON 格式输出
--login刷新 Cookie,然后退出
--cookie-path自定义 Cookie 文件路径
--profile-dirChrome 配置文件目录

模型

模型描述
gemini-3-pro默认,最新的 3.0 Pro
gemini-3-flash快速、轻量的 3.0 Flash
gemini-3-flash-thinking支持思考的 3.0 Flash
gemini-3.1-pro-preview3.1 Pro 预览版(空标头,自动路由)

身份验证

首次运行时会打开浏览器进行 Google 身份验证。Cookie 会自动缓存。

支持的浏览器(自动检测):Chrome、Chrome Canary/Beta、Chromium、Edge。

强制刷新:--login 标志。覆盖浏览器:GEMINI_WEB_CHROME_PATH 环境变量。

环境变量

变量描述
GEMINI_WEB_DATA_DIR数据目录
GEMINI_WEB_COOKIE_PATHCookie 文件路径
GEMINI_WEB_CHROME_PROFILE_DIRChrome 配置目录
GEMINI_WEB_CHROME_PATHChrome 可执行文件路径
HTTP_PROXY, HTTPS_PROXY用于访问 Google 的代理(在命令中内联设置)

会话

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

包含:id、metadata(Gemini 聊天状态)、messages 数组、时间戳。

扩展支持

通过 EXTEND.md 使用自定义配置。路径和支持的选项请参阅 偏好设置 部分。

评论

支持 Markdown