关于 tuzi-danger-gemini-web
该技能通过 Gemini Web API 提供文本和图像生成,面向需要在命令行中使用 Gemini 的用户。它支持参考图像和多轮对话,并可保存会话。
主要功能
- 01生成文本和图像
- 02使用参考图像作为输入
- 03支持多轮会话
- 04选择 Gemini 模型
- 05支持 JSON 输出
适用场景
- 01通过提示词生成文本
- 02根据参考图生成图像
- 03延续已保存的多轮会话
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ tuziapi/ tuzi-skills --skill tuzi-danger-gemini-web安装后在 Claude Code 中输入/tuzi-danger-gemini-web确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
scripts/main.tsscripts/gemini-webapi/client.tsconstants.tsexceptions.tsindex.tsscripts/gemini-webapi/components/gem-mixin.tsindex.tsscripts/gemini-webapi/types/candidate.tsgem.tsgrpc.tsimage.tsindex.tsmodeloutput.tsscripts/gemini-webapi/utils/cookie-file.tsdecorators.tsget-access-token.tshttp.tsindex.tsload-browser-cookies.tslogger.tsparsing.tspaths.tsrotate-1psidts.tsupload-file.ts详细介绍
Gemini Web 客户端
通过 Gemini Web API 生成文本/图像。支持参考图像和多轮对话。
脚本目录
重要:所有脚本都位于此技能的 scripts/ 子目录中。
Agent 执行说明:
- 将此 SKILL.md 文件所在目录路径确定为
SKILL_DIR - 脚本路径 =
${SKILL_DIR}/scripts/<script-name>.ts - 将本文档中的所有
${SKILL_DIR}替换为实际路径
脚本参考:
| 脚本 | 用途 |
|---|---|
scripts/main.ts | 文本/图像生成的 CLI 入口 |
scripts/gemini-webapi/* | gemini_webapi 的 TypeScript 移植版(GeminiClient、类型、工具函数) |
同意检查(必需)
首次使用前,请确认用户同意使用逆向工程 API。
同意文件位置:
- macOS:
~/Library/Application Support/tuzi-skills/gemini-web/consent.json - Linux:
~/.local/share/tuzi-skills/gemini-web/consent.json - Windows:
%APPDATA%\tuzi-skills\gemini-web\consent.json
流程:
- 检查同意文件是否存在,且包含
accepted: true和disclaimerVersion: "1.0" - 如果同意有效 → 打印包含
acceptedAt日期的警告,然后继续 - 如果没有同意 → 显示免责声明,并通过
AskUserQuestion询问用户:- “是,我接受” → 创建包含 ISO 时间戳的同意文件,然后继续
- “不,我拒绝” → 输出拒绝消息,然后停止
- 同意文件格式:
{"version":1,"accepted":true,"acceptedAt":"<ISO>","disclaimerVersion":"1.0"}
偏好设置(EXTEND.md)
使用 Bash 按优先级顺序检查 EXTEND.md 是否存在:
# Check project-level first
test -f .tuzi-skills/tuzi-danger-gemini-web/EXTEND.md && echo "project"
# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)
test -f "$HOME/.tuzi-skills/tuzi-danger-gemini-web/EXTEND.md" && echo "user"
┌──────────────────────────────────────────────────────────┬───────────────────┐ │ 路径 │ 位置 │ ├──────────────────────────────────────────────────────────┼───────────────────┤ │ .tuzi-skills/tuzi-danger-gemini-web/EXTEND.md │ 项目目录 │ ├──────────────────────────────────────────────────────────┼───────────────────┤ │ $HOME/.tuzi-skills/tuzi-danger-gemini-web/EXTEND.md │ 用户主目录 │ └──────────────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐ │ 结果 │ 操作 │ ├───────────────────────────────────────────────────────────────────────────────────────┤ │ 找到 │ 读取、解析并应用设置 │ ├───────────────────────────────────────────────────────────────────────────────────────┤ │ 未找到 │ 使用默认值 │ └───────────┴───────────────────────────────────────────────────────────────────────────┘
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-dir | Chrome 配置文件目录 |
模型
| 模型 | 说明 |
|---|---|
gemini-3-pro | 默认,最新的 3.0 Pro |
gemini-3-flash | 快速、轻量的 3.0 Flash |
gemini-3-flash-thinking | 带有思考功能的 3.0 Flash |
gemini-3.1-pro-preview | 3.1 Pro 预览版(空 header,自动路由) |
身份验证
首次运行时会打开浏览器进行 Google 身份验证。Cookie 会自动缓存。
支持的浏览器(自动检测):Chrome、Chrome Canary/Beta、Chromium、Edge。
强制刷新:--login 标志。覆盖浏览器:GEMINI_WEB_CHROME_PATH 环境变量。
环境变量
| 变量 | 描述 |
|---|---|
GEMINI_WEB_DATA_DIR | 数据目录 |
GEMINI_WEB_COOKIE_PATH | Cookie 文件路径 |
GEMINI_WEB_CHROME_PROFILE_DIR | Chrome 配置目录 |
GEMINI_WEB_CHROME_PATH | Chrome 可执行文件路径 |
HTTP_PROXY, HTTPS_PROXY | 用于访问 Google 的代理(在命令中内联设置) |
会话
会话文件存储在数据目录下的 sessions/<id>.json 中。
包含:id、metadata(Gemini 聊天状态)、messages 数组、时间戳。
扩展支持
通过 EXTEND.md 使用自定义配置。路径和支持的选项请参阅 偏好设置 部分。