From 7842e4d1888a11a20aa30af8baf717f447c9914f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Liu=20=E5=AE=9D=E7=8E=89?= Date: Fri, 23 Jan 2026 16:10:04 -0600 Subject: [PATCH] chore: release v1.18.2 --- .claude-plugin/marketplace.json | 2 +- .gitignore | 3 + CHANGELOG.md | 8 + CHANGELOG.zh.md | 8 + CLAUDE.md | 139 +++++++++- skills/baoyu-compress-image/SKILL.md | 197 ++++--------- skills/baoyu-danger-gemini-web/SKILL.md | 307 ++++++--------------- skills/baoyu-danger-x-to-markdown/SKILL.md | 171 +++++------- skills/baoyu-image-gen/SKILL.md | 227 +++++---------- skills/baoyu-post-to-wechat/SKILL.md | 104 +++---- skills/baoyu-post-to-x/SKILL.md | 139 +++++----- skills/baoyu-url-to-markdown/SKILL.md | 139 +++------- 12 files changed, 583 insertions(+), 861 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 0e01d6a..3bffa16 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -6,7 +6,7 @@ }, "metadata": { "description": "Skills shared by Baoyu for improving daily work efficiency", - "version": "1.18.1" + "version": "1.18.2" }, "plugins": [ { diff --git a/.gitignore b/.gitignore index f16405f..e1a4812 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,6 @@ xhs-images/ url-to-markdown/ cover-image/ slide-deck/ +infographic/ +illustrations/ +comic/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cab8c8..59ccf73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ English | [中文](./CHANGELOG.zh.md) +## 1.18.2 - 2026-01-23 + +### Refactor +- Streamline SKILL.md documentation across 7 skills (`baoyu-compress-image`, `baoyu-danger-gemini-web`, `baoyu-danger-x-to-markdown`, `baoyu-image-gen`, `baoyu-post-to-wechat`, `baoyu-post-to-x`, `baoyu-url-to-markdown`) following official best practices—reduces total documentation by ~300 lines while preserving all functionality. + +### Documentation +- `CLAUDE.md`: adds official skill authoring best practices link, skill loading rules, description writing guidelines, and progressive disclosure patterns. + ## 1.18.1 - 2026-01-23 ### Documentation diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index 7712de8..a4ceb75 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -2,6 +2,14 @@ [English](./CHANGELOG.md) | 中文 +## 1.18.2 - 2026-01-23 + +### 重构 +- 精简 7 个技能的 SKILL.md 文档(`baoyu-compress-image`、`baoyu-danger-gemini-web`、`baoyu-danger-x-to-markdown`、`baoyu-image-gen`、`baoyu-post-to-wechat`、`baoyu-post-to-x`、`baoyu-url-to-markdown`),遵循官方最佳实践——总文档量减少约 300 行,功能完整保留。 + +### 文档 +- `CLAUDE.md`:新增官方技能编写最佳实践链接、技能加载规则、描述编写指南和渐进式披露模式。 + ## 1.18.1 - 2026-01-23 ### 文档 diff --git a/CLAUDE.md b/CLAUDE.md index d56507c..6b70eae 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -78,6 +78,20 @@ npx -y bun skills/baoyu-danger-gemini-web/scripts/main.ts --promptfiles system.m `.claude-plugin/marketplace.json` defines plugin metadata and skill paths. Version follows semver. +## Skill Loading Rules + +**IMPORTANT**: When working in this project, follow these rules: + +| Rule | Description | +|------|-------------| +| **Load project skills first** | MUST load all skills from `skills/` directory in current project. Project skills take priority over system/user-level skills with same name. | +| **Default image generation** | When image generation is needed, use `skills/baoyu-image-gen/SKILL.md` by default (unless user specifies otherwise). | + +**Loading Priority** (highest → lowest): +1. Current project `skills/` directory +2. User-level skills (`$HOME/.baoyu-skills/`) +3. System-level skills + ## Release Process **IMPORTANT**: When user requests release/发布/push, ALWAYS use `/release-skills` workflow. @@ -92,6 +106,22 @@ npx -y bun skills/baoyu-danger-gemini-web/scripts/main.ts --promptfiles system.m **IMPORTANT**: All skills MUST use `baoyu-` prefix to avoid conflicts when users import this plugin. +**REQUIRED READING**: Before creating a new skill, read the official [Skill authoring best practices](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices). + +### Key Requirements from Official Best Practices + +| Requirement | Details | +|-------------|---------| +| **Concise is key** | Claude is smart—only add context it doesn't have. Challenge each token. | +| **name field** | Max 64 chars, lowercase letters/numbers/hyphens only, no "anthropic"/"claude" | +| **description field** | Max 1024 chars, non-empty, MUST be third person, include what + when to use | +| **SKILL.md body** | Keep under 500 lines; use separate files for additional content | +| **Naming convention** | Gerund form preferred (e.g., `processing-pdfs`), but `baoyu-` prefix required here | +| **References** | Keep one level deep from SKILL.md; avoid nested references | +| **No time-sensitive info** | Avoid dates/versions that become outdated | + +### Steps + 1. Create `skills/baoyu-/SKILL.md` with YAML front matter - Directory name: `baoyu-` - SKILL.md `name` field: `baoyu-` @@ -119,6 +149,21 @@ npx -y bun skills/baoyu-danger-gemini-web/scripts/main.ts --promptfiles system.m - `description`: Brief description of the category - `skills`: Array with the skill path +### Writing Effective Descriptions + +**MUST write in third person** (not "I can help you" or "You can use this"): + +```yaml +# Good +description: Generates Xiaohongshu infographic series from content. Use when user asks for "小红书图片", "XHS images", or "RedNote infographics". + +# Bad +description: I can help you create Xiaohongshu images +description: You can use this to generate XHS content +``` + +Include both **what** the skill does and **when** to use it (triggers/keywords). + ### Script Directory Template Every SKILL.md with scripts MUST include this section after Usage: @@ -142,6 +187,26 @@ Every SKILL.md with scripts MUST include this section after Usage: When referencing scripts in workflow sections, use `${SKILL_DIR}/scripts/.ts` so agents can resolve the correct path. +### Progressive Disclosure + +For skills with extensive content, use separate reference files: + +``` +skills/baoyu-example/ +├── SKILL.md # Main instructions (<500 lines) +├── references/ +│ ├── styles.md # Style definitions (loaded as needed) +│ └── examples.md # Usage examples (loaded as needed) +└── scripts/ + └── main.ts # Executable script +``` + +In SKILL.md, link to reference files (one level deep only): +```markdown +**Available styles**: See [references/styles.md](references/styles.md) +**Examples**: See [references/examples.md](references/examples.md) +``` + ## Code Style - TypeScript throughout, no comments @@ -155,9 +220,11 @@ Skills that require image generation MUST delegate to available image generation ### Image Generation Skill Selection -1. Check available image generation skills in `skills/` directory -2. Read each skill's SKILL.md to understand parameters and capabilities -3. If multiple image generation skills available, ask user to choose preferred skill +**Default**: Use `skills/baoyu-image-gen/SKILL.md` (unless user specifies otherwise). + +1. Read `skills/baoyu-image-gen/SKILL.md` for parameters and capabilities +2. If user explicitly requests a different skill, check `skills/` directory for alternatives +3. Only ask user to choose when they haven't specified and multiple viable options exist ### Generation Flow Template @@ -298,18 +365,66 @@ READMEs use 3-column tables for style previews: ## Extension Support -Every SKILL.md MUST include an Extension Support section at the end: +Every SKILL.md MUST include two parts for extension support: + +### 1. Load Preferences Section (in Step 1 or as "Preferences" section) + +For skills with workflows, add as Step 1.1. For utility skills, add as "Preferences (EXTEND.md)" section before Usage: + +```markdown +**1.1 Load Preferences (EXTEND.md)** + +Use Bash to check EXTEND.md existence (priority order): + +\`\`\`bash +# Check project-level first +test -f .baoyu-skills//EXTEND.md && echo "project" + +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills//EXTEND.md" && echo "user" +\`\`\` + +┌────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills//EXTEND.md │ Project directory │ +├────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills//EXTEND.md │ User home │ +└────────────────────────────────────────────┴───────────────────┘ + +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, display summary │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Ask user with AskUserQuestion (see references/config/first-time-setup.md) │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: [List supported configuration options for this skill] + +Schema: `references/config/preferences-schema.md` +``` + +### 2. Extension Support Section (at the end) + +Simplified section that references the preferences section: ```markdown ## Extension Support -Custom styles and configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills//EXTEND.md` (project) -2. `~/.baoyu-skills//EXTEND.md` (user) - -If found, load before Step 1. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Step 1.1** for paths and supported options. ``` -Replace `` with the actual skill name (e.g., `baoyu-cover-image`). +Or for utility skills without workflow steps: + +```markdown +## Extension Support + +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. +``` + +**Notes**: +- Replace `` with actual skill name (e.g., `baoyu-cover-image`) +- Use `$HOME` instead of `~` for cross-platform compatibility (macOS/Linux/WSL) +- Use `test -f` Bash command for explicit file existence check +- ASCII tables for clear visual formatting diff --git a/skills/baoyu-compress-image/SKILL.md b/skills/baoyu-compress-image/SKILL.md index 8346b29..28cd083 100644 --- a/skills/baoyu-compress-image/SKILL.md +++ b/skills/baoyu-compress-image/SKILL.md @@ -1,188 +1,89 @@ --- name: baoyu-compress-image -description: Cross-platform image compression skill. Converts images to WebP by default with PNG-to-PNG support. Uses system tools (sips, cwebp, ImageMagick) with Sharp fallback. +description: Compresses images to WebP (default) or PNG with automatic tool selection. Use when user asks to "compress image", "optimize image", "convert to webp", or reduce image file size. --- # Image Compressor -Cross-platform image compression with WebP default output, PNG-to-PNG support, preferring system tools with Sharp fallback. +Compresses images using best available tool (sips → cwebp → ImageMagick → Sharp). ## Script Directory -**Important**: All scripts are located in the `scripts/` subdirectory of this skill. +Scripts in `scripts/` subdirectory. Replace `${SKILL_DIR}` with this SKILL.md's directory path. -**Agent Execution Instructions**: -1. Determine this SKILL.md file's directory path as `SKILL_DIR` -2. Script path = `${SKILL_DIR}/scripts/.ts` -3. Replace all `${SKILL_DIR}` in this document with the actual path - -**Script Reference**: | Script | Purpose | |--------|---------| -| `scripts/main.ts` | CLI entry point for image compression | +| `scripts/main.ts` | Image compression CLI | -## Quick Start +## Preferences (EXTEND.md) + +Use Bash to check EXTEND.md existence (priority order): ```bash -# Compress to WebP (default) -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png +# Check project-level first +test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project" -# Keep original format (PNG → PNG) -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --format png - -# Custom quality -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -q 75 - -# Process directory -npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "user" ``` -## Commands +┌────────────────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├────────────────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills/baoyu-compress-image/EXTEND.md │ Project directory │ +├────────────────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md │ User home │ +└────────────────────────────────────────────────────────┴───────────────────┘ -### Single File Compression +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, apply settings │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Use defaults │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: Default format | Default quality | Keep original preference + +## Usage ```bash -# Basic (converts to WebP, replaces original) -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png - -# Custom output path -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -o compressed.webp - -# Keep original file -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --keep - -# Custom quality (0-100, default: 80) -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -q 75 - -# Keep original format -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png -``` - -### Directory Processing - -```bash -# Process all images in directory -npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ - -# Recursive processing -npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r - -# With custom quality -npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75 -``` - -### Output Formats - -```bash -# Plain text (default) -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png - -# JSON output -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json +npx -y bun ${SKILL_DIR}/scripts/main.ts [options] ``` ## Options | Option | Short | Description | Default | |--------|-------|-------------|---------| -| `` | | Input file or directory | Required | -| `--output ` | `-o` | Output path | Same path, new extension | -| `--format ` | `-f` | webp, png, jpeg | webp | -| `--quality ` | `-q` | Quality 0-100 | 80 | -| `--keep` | `-k` | Keep original file | false | -| `--recursive` | `-r` | Process directories recursively | false | +| `` | | File or directory | Required | +| `--output` | `-o` | Output path | Same path, new ext | +| `--format` | `-f` | webp, png, jpeg | webp | +| `--quality` | `-q` | Quality 0-100 | 80 | +| `--keep` | `-k` | Keep original | false | +| `--recursive` | `-r` | Process subdirs | false | | `--json` | | JSON output | false | -| `--help` | `-h` | Show help | | -## Compressor Selection +## Examples -Priority order (auto-detected): +```bash +# Single file → WebP (replaces original) +npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -1. **sips** (macOS built-in, WebP support since macOS 11) -2. **cwebp** (Google's official WebP tool) -3. **ImageMagick** (`convert` command) -4. **Sharp** (npm package, auto-installed by Bun) +# Keep PNG format +npx -y bun ${SKILL_DIR}/scripts/main.ts image.png -f png --keep -The skill automatically selects the best available compressor. +# Directory recursive +npx -y bun ${SKILL_DIR}/scripts/main.ts ./images/ -r -q 75 -## Output Format - -### Text Mode (default) +# JSON output +npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json +``` +**Output**: ``` image.png → image.webp (245KB → 89KB, 64% reduction) ``` -### JSON Mode - -```json -{ - "input": "image.png", - "output": "image.webp", - "inputSize": 250880, - "outputSize": 91136, - "ratio": 0.36, - "compressor": "sips" -} -``` - -### Directory JSON Mode - -```json -{ - "files": [...], - "summary": { - "totalFiles": 10, - "totalInputSize": 2508800, - "totalOutputSize": 911360, - "ratio": 0.36, - "compressor": "sips" - } -} -``` - -## Examples - -### Compress single image - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts photo.png -# photo.png → photo.webp (1.2MB → 340KB, 72% reduction) -``` - -### Compress with custom quality - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts photo.png -q 60 -# photo.png → photo.webp (1.2MB → 280KB, 77% reduction) -``` - -### Keep original format - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts screenshot.png -f png --keep -# screenshot.png → screenshot-compressed.png (500KB → 380KB, 24% reduction) -``` - -### Process entire directory - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts ./screenshots/ -r -# Processed 15 files: 12.5MB → 4.2MB (66% reduction) -``` - -### Get JSON for scripting - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts image.png --json | jq '.ratio' -``` - ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-compress-image/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-compress-image/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. diff --git a/skills/baoyu-danger-gemini-web/SKILL.md b/skills/baoyu-danger-gemini-web/SKILL.md index af3f4b8..16dc881 100644 --- a/skills/baoyu-danger-gemini-web/SKILL.md +++ b/skills/baoyu-danger-gemini-web/SKILL.md @@ -1,15 +1,11 @@ --- name: baoyu-danger-gemini-web -description: Image generation skill using Gemini Web. Generates images from text prompts via Google Gemini. Also supports text generation. Use as the image generation backend for other skills like cover-image, xhs-images, article-illustrator. +description: Generates images and text via reverse-engineered Gemini Web API. Supports text generation, image generation from prompts, reference images for vision input, and multi-turn conversations. Use when other skills need image generation backend, or when user requests "generate image with Gemini", "Gemini text generation", or needs vision-capable AI generation. --- # Gemini Web Client -Supports: -- Text generation -- Image generation (download + save) -- Reference images for vision input (attach local images) -- Multi-turn conversations via persisted `--sessionId` +Text/image generation via Gemini Web API. Supports reference images and multi-turn conversations. ## Script Directory @@ -26,146 +22,73 @@ Supports: | `scripts/main.ts` | CLI entry point for text/image generation | | `scripts/gemini-webapi/*` | TypeScript port of `gemini_webapi` (GeminiClient, types, utils) | -## ⚠️ Disclaimer (REQUIRED) +## Consent Check (REQUIRED) -**Before using this skill**, the consent check MUST be performed. +Before first use, verify user consent for reverse-engineered API usage. -### Consent Check Flow +**Consent file locations**: +- 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` -**Step 1**: Check consent file - -```bash -# macOS -cat ~/Library/Application\ Support/baoyu-skills/gemini-web/consent.json 2>/dev/null - -# Linux -cat ~/.local/share/baoyu-skills/gemini-web/consent.json 2>/dev/null - -# Windows (PowerShell) -Get-Content "$env:APPDATA\baoyu-skills\gemini-web\consent.json" 2>$null -``` - -**Step 2**: If consent exists and `accepted: true` with matching `disclaimerVersion: "1.0"`: - -Print warning and proceed: -``` -⚠️ Warning: Using reverse-engineered Gemini Web API (not official). Accepted on: -``` - -**Step 3**: If consent file doesn't exist or `disclaimerVersion` mismatch: - -Display disclaimer and ask user: - -``` -⚠️ DISCLAIMER - -This tool uses a reverse-engineered Gemini Web API, NOT an official Google API. - -Risks: -- May break without notice if Google changes their API -- No official support or guarantees -- Use at your own risk - -Do you accept these terms and wish to continue? -``` - -Use `AskUserQuestion` tool with options: -- **Yes, I accept** - Continue and save consent -- **No, I decline** - Exit immediately - -**Step 4**: On acceptance, create consent file: - -```bash -# macOS -mkdir -p ~/Library/Application\ Support/baoyu-skills/gemini-web -cat > ~/Library/Application\ Support/baoyu-skills/gemini-web/consent.json << 'EOF' -{ - "version": 1, - "accepted": true, - "acceptedAt": "", - "disclaimerVersion": "1.0" -} -EOF - -# Linux -mkdir -p ~/.local/share/baoyu-skills/gemini-web -cat > ~/.local/share/baoyu-skills/gemini-web/consent.json << 'EOF' -{ - "version": 1, - "accepted": true, - "acceptedAt": "", - "disclaimerVersion": "1.0" -} -EOF -``` - -**Step 5**: On decline, output message and stop: -``` -User declined the disclaimer. Exiting. -``` +**Flow**: +1. Check if consent file exists with `accepted: true` and `disclaimerVersion: "1.0"` +2. If valid consent exists → print warning with `acceptedAt` date, proceed +3. If no consent → show disclaimer, ask user via `AskUserQuestion`: + - "Yes, I accept" → create consent file with ISO timestamp, proceed + - "No, I decline" → output decline message, stop +4. Consent file format: `{"version":1,"accepted":true,"acceptedAt":"","disclaimerVersion":"1.0"}` --- -## Quick start +## Preferences (EXTEND.md) + +Use Bash to check EXTEND.md existence (priority order): ```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts "Hello, Gemini" -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Explain quantum computing" +# 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 Supports**: Default model | Proxy settings | Custom data directory + +## Usage + +```bash +# 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-2.5-pro + +# 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 -# Multi-turn conversation (agent generates unique sessionId) -npx -y bun ${SKILL_DIR}/scripts/main.ts "Remember this: 42" --sessionId my-unique-id-123 -npx -y bun ${SKILL_DIR}/scripts/main.ts "What number?" --sessionId my-unique-id-123 -``` +# 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 -## Commands - -### Text generation - -```bash -# Simple prompt (positional) -npx -y bun ${SKILL_DIR}/scripts/main.ts "Your prompt here" - -# Explicit prompt flag -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Your prompt here" -npx -y bun ${SKILL_DIR}/scripts/main.ts -p "Your prompt here" - -# With model selection -npx -y bun ${SKILL_DIR}/scripts/main.ts -p "Hello" -m gemini-2.5-pro - -# Pipe from stdin -echo "Summarize this" | npx -y bun ${SKILL_DIR}/scripts/main.ts -``` - -### Image generation - -```bash -# Generate image with default path (./generated.png) -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A sunset over mountains" --image - -# Generate image with custom path -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cute robot" --image robot.png - -# Shorthand -npx -y bun ${SKILL_DIR}/scripts/main.ts "A dragon" --image=dragon.png -``` - -### Vision input (reference images) - -```bash -# Text + image -> text -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Describe this image" --reference a.png - -# Text + image -> image -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Generate a variation" --reference a.png --image out.png -``` - -### Output formats - -```bash -# Plain text (default) -npx -y bun ${SKILL_DIR}/scripts/main.ts "Hello" +# 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 @@ -175,45 +98,35 @@ npx -y bun ${SKILL_DIR}/scripts/main.ts "Hello" --json | Option | Description | |--------|-------------| -| `--prompt `, `-p` | Prompt text | -| `--promptfiles ` | Read prompt from files (concatenated in order) | -| `--model `, `-m` | Model: gemini-3-pro (default), gemini-2.5-pro, gemini-2.5-flash | -| `--image [path]` | Generate image, save to path (default: generated.png) | -| `--reference `, `--ref ` | Reference images for vision input | -| `--sessionId ` | Session ID for multi-turn conversation (agent generates unique ID) | -| `--list-sessions` | List saved sessions (max 100, sorted by update time) | +| `--prompt`, `-p` | Prompt text | +| `--promptfiles` | Read prompt from files (concatenated) | +| `--model`, `-m` | Model: gemini-3-pro (default), gemini-2.5-pro, gemini-2.5-flash | +| `--image [path]` | Generate image (default: generated.png) | +| `--reference`, `--ref` | Reference images for vision input | +| `--sessionId` | Session ID for multi-turn conversation | +| `--list-sessions` | List saved sessions | | `--json` | Output as JSON | -| `--login` | Refresh cookies only, then exit | -| `--cookie-path ` | Custom cookie file path | -| `--profile-dir ` | Chrome profile directory | -| `--help`, `-h` | Show help | - -CLI note: `scripts/main.ts` supports text generation, image generation, reference images (`--reference/--ref`), and multi-turn conversations via `--sessionId`. +| `--login` | Refresh cookies, then exit | +| `--cookie-path` | Custom cookie file path | +| `--profile-dir` | Chrome profile directory | ## Models -- `gemini-3-pro` - Default, latest model -- `gemini-2.5-pro` - Previous generation pro -- `gemini-2.5-flash` - Fast, lightweight +| Model | Description | +|-------|-------------| +| `gemini-3-pro` | Default, latest | +| `gemini-2.5-pro` | Previous pro | +| `gemini-2.5-flash` | Fast, lightweight | ## Authentication -First run opens a browser to authenticate with Google. Cookies are cached for subsequent runs. +First run opens browser for Google auth. Cookies cached automatically. -**Supported browsers** (auto-detected in order): -- Google Chrome -- Google Chrome Canary / Beta -- Chromium -- Microsoft Edge +Supported browsers (auto-detected): Chrome, Chrome Canary/Beta, Chromium, Edge. -Override with `GEMINI_WEB_CHROME_PATH` environment variable if needed. +Force refresh: `--login` flag. Override browser: `GEMINI_WEB_CHROME_PATH` env var. -```bash -# Force cookie refresh -npx -y bun ${SKILL_DIR}/scripts/main.ts --login -``` - -## Environment variables +## Environment Variables | Variable | Description | |----------|-------------| @@ -221,72 +134,14 @@ npx -y bun ${SKILL_DIR}/scripts/main.ts --login | `GEMINI_WEB_COOKIE_PATH` | Cookie file path | | `GEMINI_WEB_CHROME_PROFILE_DIR` | Chrome profile directory | | `GEMINI_WEB_CHROME_PATH` | Chrome executable path | +| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy for Google access (set inline with command) | -## Proxy Configuration +## Sessions -If you need a proxy to access Google services (e.g., in China), set `HTTP_PROXY` and `HTTPS_PROXY` environment variables before running: +Session files stored in data directory under `sessions/.json`. -```bash -# Example with local proxy -HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 npx -y bun ${SKILL_DIR}/scripts/main.ts "Hello" - -# Image generation with proxy -HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png - -# Cookie refresh with proxy -HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 npx -y bun ${SKILL_DIR}/scripts/main.ts --login -``` - -**Note**: Environment variables must be set inline with the command. Shell profile settings (e.g., `.bashrc`) may not be inherited by subprocesses. - -## Examples - -### Generate text response -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts "What is the capital of France?" -``` - -### Generate image -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts "A photorealistic image of a golden retriever puppy" --image puppy.png -``` - -### Get JSON output for parsing -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts "Hello" --json | jq '.text' -``` - -### Generate image from prompt files -```bash -# Concatenate system.md + content.md as prompt -npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image output.png -``` - -### Multi-turn conversation -```bash -# Start a session with unique ID (agent generates this) -npx -y bun ${SKILL_DIR}/scripts/main.ts "You are a helpful math tutor." --sessionId task-abc123 - -# Continue the conversation (remembers context) -npx -y bun ${SKILL_DIR}/scripts/main.ts "What is 2+2?" --sessionId task-abc123 -npx -y bun ${SKILL_DIR}/scripts/main.ts "Now multiply that by 10" --sessionId task-abc123 - -# List recent sessions (max 100, sorted by update time) -npx -y bun ${SKILL_DIR}/scripts/main.ts --list-sessions -``` - -Session files are stored in `~/Library/Application Support/baoyu-skills/gemini-web/sessions/.json` and contain: -- `id`: Session ID -- `metadata`: Gemini chat metadata for continuation -- `messages`: Array of `{role, content, timestamp, error?}` -- `createdAt`, `updatedAt`: Timestamps +Contains: `id`, `metadata` (Gemini chat state), `messages` array, timestamps. ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. diff --git a/skills/baoyu-danger-x-to-markdown/SKILL.md b/skills/baoyu-danger-x-to-markdown/SKILL.md index 23a3cb5..9225f7b 100644 --- a/skills/baoyu-danger-x-to-markdown/SKILL.md +++ b/skills/baoyu-danger-x-to-markdown/SKILL.md @@ -1,119 +1,107 @@ --- name: baoyu-danger-x-to-markdown -description: Convert X (Twitter) tweet or article URL to markdown. Uses reverse-engineered X API (private). Requires user consent before use. +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. --- # X to Markdown -Converts X (Twitter) content to markdown format: -- Tweet threads → Markdown with YAML front matter -- X Articles → Full article content extraction +Converts X content to markdown: +- Tweets/threads → Markdown with YAML front matter +- X Articles → Full content extraction ## Script Directory -**Important**: All scripts are located in the `scripts/` subdirectory of this skill. +Scripts located in `scripts/` subdirectory. -**Agent Execution Instructions**: -1. Determine this SKILL.md file's directory path as `SKILL_DIR` -2. Script path = `${SKILL_DIR}/scripts/.ts` -3. Replace all `${SKILL_DIR}` in this document with the actual path +**Path Resolution**: +1. `SKILL_DIR` = this SKILL.md's directory +2. Script path = `${SKILL_DIR}/scripts/main.ts` -**Script Reference**: -| Script | Purpose | -|--------|---------| -| `scripts/main.ts` | CLI entry point for URL conversion | +## Consent Requirement -## ⚠️ Disclaimer (REQUIRED) +**Before any conversion**, check and obtain consent. -**Before using this skill**, the consent check MUST be performed. - -### Consent Check Flow +### Consent Flow **Step 1**: Check consent file ```bash # macOS -cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json 2>/dev/null +cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json # Linux -cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json 2>/dev/null - -# Windows (PowerShell) -Get-Content "$env:APPDATA\baoyu-skills\x-to-markdown\consent.json" 2>$null +cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json ``` -**Step 2**: If consent exists and `accepted: true` with matching `disclaimerVersion: "1.0"`: - -Print warning and proceed: +**Step 2**: If `accepted: true` and `disclaimerVersion: "1.0"` → print warning and proceed: ``` -⚠️ Warning: Using reverse-engineered X API (not official). Accepted on: +Warning: Using reverse-engineered X API. Accepted on: ``` -**Step 3**: If consent file doesn't exist or `disclaimerVersion` mismatch: - -Display disclaimer and ask user: - +**Step 3**: If missing or version mismatch → display disclaimer: ``` -⚠️ DISCLAIMER +DISCLAIMER -This tool uses a reverse-engineered X (Twitter) API, NOT an official API. +This tool uses a reverse-engineered X API, NOT official. Risks: -- May break without notice if X changes their API -- No official support or guarantees -- Account restrictions possible if API usage detected +- May break if X changes API +- No guarantees or support +- Possible account restrictions - Use at your own risk -Do you accept these terms and wish to continue? +Accept terms and continue? ``` -Use `AskUserQuestion` tool with options: -- **Yes, I accept** - Continue and save consent -- **No, I decline** - Exit immediately +Use `AskUserQuestion` with options: "Yes, I accept" | "No, I decline" -**Step 4**: On acceptance, create consent file: +**Step 4**: On accept → create consent file: +```json +{ + "version": 1, + "accepted": true, + "acceptedAt": "", + "disclaimerVersion": "1.0" +} +``` + +**Step 5**: On decline → output "User declined. Exiting." and stop. + +## Preferences (EXTEND.md) + +Use Bash to check EXTEND.md existence (priority order): ```bash -# macOS -mkdir -p ~/Library/Application\ Support/baoyu-skills/x-to-markdown -cat > ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json << 'EOF' -{ - "version": 1, - "accepted": true, - "acceptedAt": "", - "disclaimerVersion": "1.0" -} -EOF +# Check project-level first +test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project" -# Linux -mkdir -p ~/.local/share/baoyu-skills/x-to-markdown -cat > ~/.local/share/baoyu-skills/x-to-markdown/consent.json << 'EOF' -{ - "version": 1, - "accepted": true, - "acceptedAt": "", - "disclaimerVersion": "1.0" -} -EOF +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user" ``` -**Step 5**: On decline, output message and stop: -``` -User declined the disclaimer. Exiting. -``` +┌────────────────────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├────────────────────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ Project directory │ +├────────────────────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md │ User home │ +└────────────────────────────────────────────────────────────┴───────────────────┘ ---- +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, apply settings │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Use defaults │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: Default output directory | Output format preferences ## Usage ```bash -# Convert tweet (outputs markdown path) npx -y bun ${SKILL_DIR}/scripts/main.ts - -# Save to specific file npx -y bun ${SKILL_DIR}/scripts/main.ts -o output.md - -# JSON output npx -y bun ${SKILL_DIR}/scripts/main.ts --json ``` @@ -122,56 +110,35 @@ npx -y bun ${SKILL_DIR}/scripts/main.ts --json | Option | Description | |--------|-------------| | `` | Tweet or article URL | -| `-o ` | Output path (file or dir) | -| `--json` | Output as JSON | +| `-o ` | Output path | +| `--json` | JSON output | | `--login` | Refresh cookies only | -## File Structure - -``` -x-to-markdown/ -└── {username}/ - └── {tweet-id}.md -``` - ## Supported URLs - `https://x.com//status/` - `https://twitter.com//status/` - `https://x.com/i/article/` -## Output Format +## Output ```markdown --- -url: https://x.com/username/status/123 -author: "Display Name (@username)" +url: https://x.com/user/status/123 +author: "Name (@user)" tweet_count: 3 --- -Tweet content... - ---- - -Thread continuation... +Content... ``` +**File structure**: `x-to-markdown/{username}/{tweet-id}.md` + ## Authentication -**Option 1**: Environment variables (recommended) -- `X_AUTH_TOKEN` - auth_token cookie -- `X_CT0` - ct0 cookie - -**Option 2**: Chrome login (auto if env vars not set) -- First run opens Chrome for login -- Cookies cached locally +1. **Environment variables** (preferred): `X_AUTH_TOKEN`, `X_CT0` +2. **Chrome login** (fallback): Auto-opens Chrome, caches cookies locally ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. diff --git a/skills/baoyu-image-gen/SKILL.md b/skills/baoyu-image-gen/SKILL.md index 843039b..758f0dd 100644 --- a/skills/baoyu-image-gen/SKILL.md +++ b/skills/baoyu-image-gen/SKILL.md @@ -1,98 +1,68 @@ --- name: baoyu-image-gen -description: AI SDK-based image generation using official OpenAI and Google APIs. Supports text-to-image, reference images, aspect ratios, and quality presets. +description: Generates images using official OpenAI and Google APIs via AI SDK. Supports text-to-image, reference images, aspect ratios, and quality presets. Use when user asks to "generate image with API", "use official API for images", "create image with OpenAI/Google", or needs API-based generation instead of browser-based. --- # Image Generation (AI SDK) -Official API-based image generation via AI SDK. Supports OpenAI (DALL-E, GPT Image) and Google (Imagen, Gemini multimodal). +Official API-based image generation. Supports OpenAI and Google providers. ## Script Directory -**Important**: All scripts are located in the `scripts/` subdirectory of this skill. +**Agent Execution**: +1. `SKILL_DIR` = this SKILL.md file's directory +2. Script path = `${SKILL_DIR}/scripts/main.ts` -**Agent Execution Instructions**: -1. Determine this SKILL.md file's directory path as `SKILL_DIR` -2. Script path = `${SKILL_DIR}/scripts/.ts` -3. Replace all `${SKILL_DIR}` in this document with the actual path +## Preferences (EXTEND.md) -**Script Reference**: -| Script | Purpose | -|--------|---------| -| `scripts/main.ts` | CLI entry point for image generation | - -## Quick Start +Use Bash to check EXTEND.md existence (priority order): ```bash -# Basic generation (auto-detect provider) +# Check project-level first +test -f .baoyu-skills/baoyu-image-gen/EXTEND.md && echo "project" + +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md" && echo "user" +``` + +┌──────────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├──────────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills/baoyu-image-gen/EXTEND.md │ Project directory │ +├──────────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md │ User home │ +└──────────────────────────────────────────────────┴───────────────────┘ + +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, apply settings │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Use defaults │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: Default provider | Default quality | Default aspect ratio + +## Usage + +```bash +# Basic npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png # With aspect ratio -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A landscape" --image landscape.png --ar 16:9 +npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A landscape" --image out.png --ar 16:9 -# High quality (2k) -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality 2k - -# Specific provider -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --provider openai +# High quality +npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image out.png --quality 2k # From prompt files npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png # With reference images (Google multimodal only) npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make blue" --image out.png --ref source.png -``` -## Commands - -### Basic Image Generation - -```bash -# Generate with prompt -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A sunset over mountains" --image sunset.png - -# Shorthand -npx -y bun ${SKILL_DIR}/scripts/main.ts -p "A cute robot" --image robot.png -``` - -### Aspect Ratios - -```bash -# Common ratios: 1:1, 16:9, 9:16, 4:3, 3:4, 2.35:1 -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A portrait" --image portrait.png --ar 3:4 - -# Or specify exact size -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Banner" --image banner.png --size 1792x1024 -``` - -### Reference Images (Google Multimodal) - -```bash -# Image editing with reference -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Make it blue" --image blue.png --ref original.png - -# Multiple references -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "Combine these styles" --image out.png --ref a.png b.png -``` - -### Quality Presets - -```bash -# Normal quality (default) -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality normal - -# High quality (2k resolution) -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --quality 2k -``` - -### Output Formats - -```bash -# Plain output (prints saved path) -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png - -# JSON output -npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --json +# Specific provider +npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image out.png --provider openai ``` ## Options @@ -110,110 +80,47 @@ npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "A cat" --image cat.png --json | `--ref ` | Reference images (Google multimodal only) | | `--n ` | Number of images | | `--json` | JSON output | -| `--help`, `-h` | Show help | ## Environment Variables -| Variable | Description | Default | -|----------|-------------|---------| -| `OPENAI_API_KEY` | OpenAI API key | - | -| `GOOGLE_API_KEY` | Google API key | - | -| `OPENAI_IMAGE_MODEL` | OpenAI model | `gpt-image-1.5` | -| `GOOGLE_IMAGE_MODEL` | Google model | `gemini-3-pro-image-preview` | -| `OPENAI_BASE_URL` | Custom OpenAI endpoint | - | -| `GOOGLE_BASE_URL` | Custom Google endpoint | - | +| Variable | Description | +|----------|-------------| +| `OPENAI_API_KEY` | OpenAI API key | +| `GOOGLE_API_KEY` | Google API key | +| `OPENAI_IMAGE_MODEL` | OpenAI model override | +| `GOOGLE_IMAGE_MODEL` | Google model override | +| `OPENAI_BASE_URL` | Custom OpenAI endpoint | +| `GOOGLE_BASE_URL` | Custom Google endpoint | -**Load Priority**: CLI args > `process.env` > `/.baoyu-skills/.env` > `~/.baoyu-skills/.env` +**Load Priority**: CLI args > env vars > `/.baoyu-skills/.env` > `~/.baoyu-skills/.env` -## Provider & Model Strategy +## Provider Selection -### Auto-Selection - -1. If `--provider` specified → use it -2. If only one API key available → use that provider -3. If both available → default to Google (multimodal LLMs more versatile) - -### API Selection by Model Type - -| Model Category | API Function | Example Models | -|----------------|--------------|----------------| -| Google Multimodal | `generateText` | `gemini-2.0-flash-exp-image-generation` | -| Google Imagen | `experimental_generateImage` | `imagen-3.0-generate-002` | -| OpenAI | `experimental_generateImage` | `gpt-image-1`, `dall-e-3` | - -### Available Models - -**Google**: -- `gemini-3-pro-image-preview` - Default, multimodal generation -- `gemini-2.0-flash-exp-image-generation` - Gemini 2.0 Flash -- `imagen-3.0-generate-002` - Imagen 3 - -**OpenAI**: -- `gpt-image-1.5` - Default, GPT Image 1.5 -- `gpt-image-1` - GPT Image 1 -- `dall-e-3` - DALL-E 3 +1. `--provider` specified → use it +2. Only one API key available → use that provider +3. Both available → default to Google ## Quality Presets -| Preset | OpenAI | Google | Use Case | -|--------|--------|--------|----------| -| `normal` | 1024x1024 | Default | Covers, illustrations | -| `2k` | 2048x2048 | "2048px" in prompt | Infographics, slides | +| Preset | Resolution | Use Case | +|--------|------------|----------| +| `normal` | ~1024px | Covers, illustrations | +| `2k` | ~2048px | Infographics, slides | -## Aspect Ratio Handling +## Aspect Ratios -- **Multimodal LLMs**: Embedded in prompt (e.g., `"... aspect ratio 16:9"`) -- **Image-only models**: Uses `aspectRatio` or `size` parameter -- **Common ratios**: 1:1, 16:9, 9:16, 4:3, 3:4, 2.35:1 +Supported: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2.35:1` -## Examples - -### Generate Cover Image - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts \ - --prompt "A minimalist tech illustration with blue gradients" \ - --image cover.png --ar 2.35:1 --quality 2k -``` - -### Generate Social Media Post - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts \ - --prompt "Instagram post about coffee" \ - --image post.png --ar 1:1 -``` - -### Edit Image with Reference - -```bash -npx -y bun ${SKILL_DIR}/scripts/main.ts \ - --prompt "Change the background to sunset" \ - --image edited.png --ref original.png --provider google -``` - -### Batch Generation from Prompt File - -```bash -# Create prompt file with detailed instructions -npx -y bun ${SKILL_DIR}/scripts/main.ts \ - --promptfiles style-guide.md scene-description.md \ - --image scene.png -``` +- Multimodal models: embedded in prompt +- Image-only models: uses `aspectRatio` or `size` parameter ## Error Handling -- **Missing API key**: Clear error with setup instructions -- **Generation failure**: Auto-retry once, then error -- **Invalid aspect ratio**: Warning, proceed with default -- **Reference images with image-only model**: Warning, ignore refs +- Missing API key → error with setup instructions +- Generation failure → auto-retry once +- Invalid aspect ratio → warning, proceed with default +- Reference images with non-multimodal model → warning, ignore refs ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-image-gen/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-image-gen/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. diff --git a/skills/baoyu-post-to-wechat/SKILL.md b/skills/baoyu-post-to-wechat/SKILL.md index 4497ea4..93b3384 100644 --- a/skills/baoyu-post-to-wechat/SKILL.md +++ b/skills/baoyu-post-to-wechat/SKILL.md @@ -1,84 +1,94 @@ --- name: baoyu-post-to-wechat -description: Post content to WeChat Official Account (微信公众号). Supports both article posting (文章) and image-text posting (图文). +description: Posts content to WeChat Official Account (微信公众号) via Chrome CDP automation. Supports article posting (文章) with full markdown formatting and image-text posting (图文) with multiple images. Use when user mentions "发布公众号", "post to wechat", "微信公众号", or "图文/文章". --- -# Post to WeChat Official Account (微信公众号) - -Post content to WeChat Official Account using Chrome CDP automation. +# Post to WeChat Official Account ## Script Directory -**Important**: All scripts are located in the `scripts/` subdirectory of this skill. +**Agent Execution**: Determine this SKILL.md directory as `SKILL_DIR`, then use `${SKILL_DIR}/scripts/.ts`. -**Agent Execution Instructions**: -1. Determine this SKILL.md file's directory path as `SKILL_DIR` -2. Script path = `${SKILL_DIR}/scripts/.ts` -3. Replace all `${SKILL_DIR}` in this document with the actual path - -**Script Reference**: | Script | Purpose | |--------|---------| | `scripts/wechat-browser.ts` | Image-text posts (图文) | -| `scripts/wechat-article.ts` | Full article posting (文章) | -| `scripts/md-to-wechat.ts` | Markdown → WeChat HTML conversion | -| `scripts/copy-to-clipboard.ts` | Copy content to clipboard | -| `scripts/paste-from-clipboard.ts` | Send real paste keystroke | +| `scripts/wechat-article.ts` | Article posting (文章) | +| `scripts/md-to-wechat.ts` | Markdown → WeChat HTML | -## Quick Usage +## Preferences (EXTEND.md) -### Image-Text (图文) - Multiple images with title/content +Use Bash to check EXTEND.md existence (priority order): ```bash -# From markdown file and image directory -npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/ +# Check project-level first +test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project" -# With explicit parameters -npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img1.png --image img2.png --submit +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user" ``` -### Article (文章) - Full markdown with formatting +┌────────────────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├────────────────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills/baoyu-post-to-wechat/EXTEND.md │ Project directory │ +├────────────────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md │ User home │ +└────────────────────────────────────────────────────────┴───────────────────┘ + +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, apply settings │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Use defaults │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: Default theme | Auto-submit preference | Chrome profile path + +## Usage + +### Image-Text (图文) + +```bash +npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --markdown article.md --images ./images/ +npx -y bun ${SKILL_DIR}/scripts/wechat-browser.ts --title "标题" --content "内容" --image img.png --submit +``` + +### Article (文章) ```bash -# Post markdown article npx -y bun ${SKILL_DIR}/scripts/wechat-article.ts --markdown article.md --theme grace ``` -> **Note**: `${SKILL_DIR}` represents this skill's installation directory. Agent replaces with actual path at runtime. +## Detailed References -## References +| Topic | Reference | +|-------|-----------| +| Image-text parameters, auto-compression | [references/image-text-posting.md](references/image-text-posting.md) | +| Article themes, image handling | [references/article-posting.md](references/article-posting.md) | -- **Image-Text Posting**: See `references/image-text-posting.md` for detailed image-text posting guide -- **Article Posting**: See `references/article-posting.md` for detailed article posting guide - -## Prerequisites - -- Google Chrome installed -- `bun` runtime (via `npx -y bun`) -- First run: log in to WeChat Official Account in the opened browser window - -## Features +## Feature Comparison | Feature | Image-Text | Article | |---------|------------|---------| | Multiple images | ✓ (up to 9) | ✓ (inline) | | Markdown support | Title/content extraction | Full formatting | -| Auto title compression | ✓ (to 20 chars) | ✗ | -| Content compression | ✓ (to 1000 chars) | ✗ | +| Auto compression | ✓ (title: 20, content: 1000 chars) | ✗ | | Themes | ✗ | ✓ (default, grace, simple) | +## Prerequisites + +- Google Chrome +- First run: log in to WeChat Official Account (session preserved) + ## Troubleshooting -- **Not logged in**: First run opens browser - scan QR code to log in, session is preserved -- **Chrome not found**: Set `WECHAT_BROWSER_CHROME_PATH` environment variable -- **Paste fails**: Check system clipboard permissions +| Issue | Solution | +|-------|----------| +| Not logged in | First run opens browser - scan QR to log in | +| Chrome not found | Set `WECHAT_BROWSER_CHROME_PATH` env var | +| Paste fails | Check system clipboard permissions | ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-post-to-wechat/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. diff --git a/skills/baoyu-post-to-x/SKILL.md b/skills/baoyu-post-to-x/SKILL.md index cf31272..07dcb81 100644 --- a/skills/baoyu-post-to-x/SKILL.md +++ b/skills/baoyu-post-to-x/SKILL.md @@ -1,11 +1,11 @@ --- name: baoyu-post-to-x -description: Post content and articles to X (Twitter). Supports regular posts with images/videos and X Articles (long-form Markdown). Uses real Chrome with CDP to bypass anti-automation. +description: Posts content and articles to X (Twitter). Supports regular posts with images/videos and X Articles (long-form Markdown). Uses real Chrome with CDP to bypass anti-automation. Use when user asks to "post to X", "tweet", "publish to Twitter", or "share on X". --- # Post to X (Twitter) -Post content, images, videos, and long-form articles to X using real Chrome browser (bypasses anti-bot detection). +Posts text, images, videos, and long-form articles to X via real Chrome browser (bypasses anti-bot detection). ## Script Directory @@ -27,11 +27,41 @@ Post content, images, videos, and long-form articles to X using real Chrome brow | `scripts/copy-to-clipboard.ts` | Copy content to clipboard | | `scripts/paste-from-clipboard.ts` | Send real paste keystroke | +## Preferences (EXTEND.md) + +Use Bash to check EXTEND.md existence (priority order): + +```bash +# Check project-level first +test -f .baoyu-skills/baoyu-post-to-x/EXTEND.md && echo "project" + +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md" && echo "user" +``` + +┌──────────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├──────────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills/baoyu-post-to-x/EXTEND.md │ Project directory │ +├──────────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md │ User home │ +└──────────────────────────────────────────────────┴───────────────────┘ + +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, apply settings │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Use defaults │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: Default Chrome profile | Auto-submit preference + ## Prerequisites -- Google Chrome or Chromium installed -- `bun` installed (for running scripts) -- First run: log in to X in the opened browser window +- Google Chrome or Chromium +- `bun` runtime +- First run: log in to X manually (session saved) ## References @@ -45,72 +75,57 @@ Post content, images, videos, and long-form articles to X using real Chrome brow Text + up to 4 images. ```bash -# Preview mode (doesn't post) -npx -y bun ${SKILL_DIR}/scripts/x-browser.ts "Hello from Claude!" --image ./screenshot.png - -# Actually post -npx -y bun ${SKILL_DIR}/scripts/x-browser.ts "Hello!" --image ./photo.png --submit +npx -y bun ${SKILL_DIR}/scripts/x-browser.ts "Hello!" --image ./photo.png # Preview +npx -y bun ${SKILL_DIR}/scripts/x-browser.ts "Hello!" --image ./photo.png --submit # Post ``` -> **Note**: `${SKILL_DIR}` represents this skill's installation directory. Agent replaces with actual path at runtime. - **Parameters**: | Parameter | Description | |-----------|-------------| -| `` | Post content (positional argument) | -| `--image ` | Image file path (can be repeated, max 4) | -| `--submit` | Actually post (default: preview only) | -| `--profile ` | Custom Chrome profile directory | +| `` | Post content (positional) | +| `--image ` | Image file (repeatable, max 4) | +| `--submit` | Post (default: preview) | +| `--profile ` | Custom Chrome profile | --- ## Video Posts -Text + video file (MP4, MOV, WebM). +Text + video file. ```bash -# Preview mode (doesn't post) -npx -y bun ${SKILL_DIR}/scripts/x-video.ts "Check out this video!" --video ./clip.mp4 - -# Actually post -npx -y bun ${SKILL_DIR}/scripts/x-video.ts "Amazing content" --video ./demo.mp4 --submit +npx -y bun ${SKILL_DIR}/scripts/x-video.ts "Check this out!" --video ./clip.mp4 # Preview +npx -y bun ${SKILL_DIR}/scripts/x-video.ts "Amazing content" --video ./demo.mp4 --submit # Post ``` **Parameters**: | Parameter | Description | |-----------|-------------| -| `` | Post content (positional argument) | -| `--video ` | Video file path (required) | -| `--submit` | Actually post (default: preview only) | -| `--profile ` | Custom Chrome profile directory | +| `` | Post content (positional) | +| `--video ` | Video file (MP4, MOV, WebM) | +| `--submit` | Post (default: preview) | +| `--profile ` | Custom Chrome profile | -**Video Limits**: -- Regular accounts: 140 seconds max -- X Premium: up to 60 minutes -- Supported formats: MP4, MOV, WebM -- Processing time: 30-60 seconds depending on file size +**Limits**: Regular 140s max, Premium 60min. Processing: 30-60s. --- ## Quote Tweets -Quote an existing tweet with your comment - a way to share content while giving credit to the original creator. +Quote an existing tweet with comment. ```bash -# Preview mode (doesn't post) -npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123456789 "Great insight!" - -# Actually post -npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123456789 "I agree!" --submit +npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123 "Great insight!" # Preview +npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123 "I agree!" --submit # Post ``` **Parameters**: | Parameter | Description | |-----------|-------------| -| `` | URL of the tweet to quote (positional argument) | -| `` | Your comment text (positional argument, optional) | -| `--submit` | Actually post (default: preview only) | -| `--profile ` | Custom Chrome profile directory | +| `` | URL to quote (positional) | +| `` | Comment text (positional, optional) | +| `--submit` | Post (default: preview) | +| `--profile ` | Custom Chrome profile | --- @@ -119,47 +134,29 @@ npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123456789 " Long-form Markdown articles (requires X Premium). ```bash -# Preview mode -npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md - -# With cover image -npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --cover ./cover.jpg - -# Publish -npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --submit +npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md # Preview +npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --cover ./cover.jpg # With cover +npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --submit # Publish ``` **Parameters**: | Parameter | Description | |-----------|-------------| -| `` | Markdown file path (positional argument) | -| `--cover ` | Cover image path | -| `--title ` | Override article title | -| `--submit` | Actually publish (default: preview only) | +| `` | Markdown file (positional) | +| `--cover ` | Cover image | +| `--title ` | Override title | +| `--submit` | Publish (default: preview) | -**Frontmatter** (optional): -```yaml ---- -title: My Article Title -cover_image: /path/to/cover.jpg ---- -``` +**Frontmatter**: `title`, `cover_image` supported in YAML front matter. --- ## Notes -- First run requires manual login (session is saved) -- Always preview before using `--submit` -- Browser closes automatically after operation -- Supports macOS, Linux, and Windows +- First run: manual login required (session persists) +- Always preview before `--submit` +- Cross-platform: macOS, Linux, Windows ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-post-to-x/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-post-to-x/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. diff --git a/skills/baoyu-url-to-markdown/SKILL.md b/skills/baoyu-url-to-markdown/SKILL.md index 3958a5a..1664d33 100644 --- a/skills/baoyu-url-to-markdown/SKILL.md +++ b/skills/baoyu-url-to-markdown/SKILL.md @@ -21,6 +21,36 @@ Fetches any URL via Chrome CDP and converts HTML to clean markdown. |--------|---------| | `scripts/main.ts` | CLI entry point for URL fetching | +## Preferences (EXTEND.md) + +Use Bash to check EXTEND.md existence (priority order): + +```bash +# Check project-level first +test -f .baoyu-skills/baoyu-url-to-markdown/EXTEND.md && echo "project" + +# Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) +test -f "$HOME/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md" && echo "user" +``` + +┌────────────────────────────────────────────────────────┬───────────────────┐ +│ Path │ Location │ +├────────────────────────────────────────────────────────┼───────────────────┤ +│ .baoyu-skills/baoyu-url-to-markdown/EXTEND.md │ Project directory │ +├────────────────────────────────────────────────────────┼───────────────────┤ +│ $HOME/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md │ User home │ +└────────────────────────────────────────────────────────┴───────────────────┘ + +┌───────────┬───────────────────────────────────────────────────────────────────────────┐ +│ Result │ Action │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Found │ Read, parse, apply settings │ +├───────────┼───────────────────────────────────────────────────────────────────────────┤ +│ Not found │ Use defaults │ +└───────────┴───────────────────────────────────────────────────────────────────────────┘ + +**EXTEND.md Supports**: Default output directory | Default capture mode | Timeout settings + ## Features - Chrome CDP for full JavaScript rendering @@ -52,103 +82,28 @@ npx -y bun ${SKILL_DIR}/scripts/main.ts -o output.md ## Capture Modes -### Auto Mode (default) +| Mode | Behavior | Use When | +|------|----------|----------| +| Auto (default) | Capture on network idle | Public pages, static content | +| Wait (`--wait`) | User signals when ready | Login-required, lazy loading, paywalls | -Page loads → waits for network idle → captures immediately. - -Best for: -- Public pages -- Static content -- No login required - -### Wait Mode (`--wait`) - -Page opens → user can interact (login, scroll, etc.) → user signals ready → captures. - -Best for: -- Login-required pages -- Dynamic content needing interaction -- Pages with lazy loading - -**Agent workflow for wait mode**: -1. Run script with `--wait` flag -2. Script outputs: `Page opened. Press Enter when ready to capture...` -3. Use `AskUserQuestion` to ask user if page is ready -4. When user confirms, send newline to stdin to trigger capture +**Wait mode workflow**: +1. Run with `--wait` → script outputs "Press Enter when ready" +2. Ask user to confirm page is ready +3. Send newline to stdin to trigger capture ## Output Format -```markdown ---- -url: https://example.com/page -title: "Page Title" -description: "Meta description if available" -author: "Author if available" -published: "2024-01-01" -captured_at: "2024-01-15T10:30:00Z" ---- - -# Page Title - -Converted markdown content... -``` - -## Mode Selection Guide - -When user requests URL capture, help select appropriate mode: - -**Suggest Auto Mode when**: -- URL is public (no login wall visible) -- Content appears static -- User doesn't mention login requirements - -**Suggest Wait Mode when**: -- User mentions needing to log in -- Site known to require authentication -- User wants to scroll/interact before capture -- Content is behind paywall - -**Ask user when unclear**: -``` -The page may require login or interaction before capturing. - -Which mode should I use? -1. Auto - Capture immediately when loaded -2. Wait - Wait for you to interact first -``` +YAML front matter with `url`, `title`, `description`, `author`, `published`, `captured_at` fields, followed by converted markdown content. ## Output Directory -Each capture creates a file organized by domain: - ``` -url-to-markdown/ -└── / - └── .md +url-to-markdown//.md ``` -**Path Components**: -- ``: Site domain (e.g., `example.com`, `github.com`) -- ``: Generated from page title or URL path (kebab-case) - -**Slug Generation**: -1. Extract from page title (preferred) or URL path -2. Convert to kebab-case, 2-6 words -3. Example: "Getting Started with React" → `getting-started-with-react` - -**Conflict Resolution**: -If `url-to-markdown//.md` already exists: -- Append timestamp: `-YYYYMMDD-HHMMSS.md` -- Example: `getting-started.md` exists → `getting-started-20260118-143052.md` - -## Error Handling - -| Error | Resolution | -|-------|------------| -| Chrome not found | Install Chrome or set `URL_CHROME_PATH` env | -| Page timeout | Increase `--timeout` value | -| Capture failed | Try wait mode for complex pages | -| Empty content | Page may need JS rendering time | +- ``: From page title or URL path (kebab-case, 2-6 words) +- Conflict resolution: Append timestamp `-YYYYMMDD-HHMMSS.md` ## Environment Variables @@ -158,12 +113,8 @@ If `url-to-markdown//.md` already exists: | `URL_DATA_DIR` | Custom data directory | | `URL_CHROME_PROFILE_DIR` | Custom Chrome profile directory | +**Troubleshooting**: Chrome not found → set `URL_CHROME_PATH`. Timeout → increase `--timeout`. Complex pages → try `--wait` mode. + ## Extension Support -Custom configurations via EXTEND.md. - -**Check paths** (priority order): -1. `.baoyu-skills/baoyu-url-to-markdown/EXTEND.md` (project) -2. `~/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md` (user) - -If found, load before workflow. Extension content overrides defaults. +Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options.