forked from farhoodlabs/skills
refactor: apply FAR-95 skills review follow-ups
- Remove `playwright-ephemeral/` and `shannon/` entirely per board direction - Fix `minimax-image-generation/SKILL.md` so YAML frontmatter is at line 1 - Add `minimax-image-generation/scripts/generate.sh` (argparse, error-checked, executable) and document invoking it via `bash scripts/generate.sh ...` - Deduplicate `minimax-image-generation/CLAUDE.md` against SKILL.md - `github-app-token`: write token to `$GH_CONFIG_DIR/.gh-token` (preferred) or `$AGENT_HOME/.gh-token` (fallback), fail loudly if neither is set instead of leaking to `mktemp` - Refresh root `CLAUDE.md` to match actual directory contents and patterns - Add root `README.md` with human-facing skills index Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,62 +1,32 @@
|
||||
# MiniMax Image Generation — Implementation Notes
|
||||
|
||||
User-facing docs (aspect ratios, usage, env vars) live in `SKILL.md`. This file is for maintenance notes only.
|
||||
|
||||
## API Reference
|
||||
|
||||
- **Endpoint**: `POST /v1/image_generation`
|
||||
- **Base URL**: `https://api.minimax.io` (international) or `https://api.minimaxi.com` (China)
|
||||
- **Auth**: `Authorization: Bearer <MINIMAX_API_KEY>`
|
||||
- **Model**: `image-01`
|
||||
- **Response**: JSON with `data.image_base64[]` array
|
||||
|
||||
## Example API Call
|
||||
|
||||
```bash
|
||||
curl -X POST "https://api.minimax.io/v1/image_generation" \
|
||||
-H "Authorization: Bearer ${MINIMAX_API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "image-01",
|
||||
"prompt": "men Dressing in white t shirt, full-body stand front view image :25, outdoor",
|
||||
"aspect_ratio": "16:9",
|
||||
"num_images": 1,
|
||||
"response_format": "base64"
|
||||
}'
|
||||
```
|
||||
- **Response**: JSON with `data.image_base64[]` array; errors surface in `base_resp.status_code` / `base_resp.status_msg`.
|
||||
|
||||
## Response Format
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"image_base64": ["<base64-encoded-jpeg>"]
|
||||
},
|
||||
"data": { "image_base64": ["<base64-encoded-jpeg>"] },
|
||||
"model": "image-01",
|
||||
"request_id": "<id>"
|
||||
"request_id": "<id>",
|
||||
"base_resp": { "status_code": 0, "status_msg": "success" }
|
||||
}
|
||||
```
|
||||
|
||||
## Aspect Ratios
|
||||
|
||||
| Ratio | Dimensions | Use Case |
|
||||
|-------|-----------|----------|
|
||||
| `16:9` | 1920×1080 | Desktop wallpaper, banners |
|
||||
| `1:1` | 1024×1024 | Social media, profile images |
|
||||
| `9:16` | 1080×1920 | Mobile wallpaper, stories |
|
||||
| `4:3` | 1024×768 | Presentations |
|
||||
| `3:4` | 768×1024 | Posters, portraits |
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `curl` — HTTP requests
|
||||
- `jq` — JSON parsing
|
||||
- `base64` — Decode image data (coreutils)
|
||||
|
||||
All three are standard Unix tools. No Python or Node required.
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
minimax-image-generation/
|
||||
├── SKILL.md # Skill definition + user-facing docs
|
||||
└── CLAUDE.md # These implementation notes
|
||||
├── SKILL.md # Skill definition + user-facing docs
|
||||
├── CLAUDE.md # These implementation notes
|
||||
└── scripts/
|
||||
└── generate.sh # Generate images (invoke via `bash scripts/generate.sh …`)
|
||||
```
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
# MiniMax Image Generation Skill
|
||||
|
||||
Claude Code skill for generating images via the MiniMax API.
|
||||
Wraps the MiniMax `/v1/image_generation` endpoint as a `/minimax-image-generation` slash command.
|
||||
|
||||
## Structure
|
||||
- `SKILL.md` — skill definition + usage documentation
|
||||
- `CLAUDE.md` — implementation notes
|
||||
|
||||
## Rules
|
||||
- Set `MINIMAX_API_KEY` env var before use
|
||||
- Images are written to disk as `output-0.jpeg`, `output-1.jpeg`, etc.
|
||||
|
||||
---
|
||||
name: minimax-image-generation
|
||||
version: "1.0.0"
|
||||
@@ -48,57 +35,31 @@ metadata:
|
||||
|
||||
```bash
|
||||
export MINIMAX_API_KEY="your-minimax-api-key"
|
||||
/minimax-image-generation "a cat wearing a spacesuit, cinematic photography"
|
||||
bash minimax-image-generation/scripts/generate.sh "a cat wearing a spacesuit, cinematic photography"
|
||||
```
|
||||
|
||||
---
|
||||
Always invoke the script via `bash scripts/generate.sh …` (or `bash minimax-image-generation/scripts/generate.sh …` when running from the repo root). Do **not** rely on the executable bit — invoking through `bash` is the supported entry point, and works even when the file permissions were not preserved during deployment.
|
||||
|
||||
## Parse User Intent
|
||||
|
||||
Extract from the user's input:
|
||||
|
||||
1. **PROMPT**: The image description (required)
|
||||
2. **ASPECT_RATIO**: `16:9` (default), `1:1`, `9:16`, `4:3`, `3:4`
|
||||
1. **PROMPT**: The image description (required, positional argument)
|
||||
2. **ASPECT_RATIO**: `16:9` (default), `1:1`, `9:16`, `4:3`, `3:4` — via `--aspect-ratio=<ratio>`
|
||||
3. **COUNT**: number of images to generate (default `1`) — via `--count=<N>`
|
||||
4. **OUTPUT_PREFIX**: filename stem (default `output`) — via `--output=<stem>`
|
||||
|
||||
---
|
||||
|
||||
## API Call Example
|
||||
## Script Usage
|
||||
|
||||
```bash
|
||||
# Verify credentials
|
||||
if [ -z "${MINIMAX_API_KEY:-}" ]; then
|
||||
echo "ERROR: MINIMAX_API_KEY is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API_BASE_URL="${MINIMAX_API_BASE_URL:-https://api.minimax.io}"
|
||||
PROMPT="<your prompt here>"
|
||||
ASPECT_RATIO="16:9"
|
||||
|
||||
# Call the API
|
||||
response=$(curl -s -X POST "${API_BASE_URL}/v1/image_generation" \
|
||||
-H "Authorization: Bearer ${MINIMAX_API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"model\": \"image-01\",
|
||||
\"prompt\": \"${PROMPT}\",
|
||||
\"aspect_ratio\": \"${ASPECT_RATIO}\",
|
||||
\"response_format\": \"base64\"
|
||||
}")
|
||||
|
||||
# Decode and save
|
||||
images=$(echo "$response" | jq -r '.data.image_base64[]')
|
||||
idx=0
|
||||
for image_b64 in $images; do
|
||||
echo "$image_b64" | base64 -d > "output-${idx}.jpeg"
|
||||
echo "Saved: output-${idx}.jpeg"
|
||||
idx=$((idx + 1))
|
||||
done
|
||||
bash minimax-image-generation/scripts/generate.sh \
|
||||
"a sunset over the ocean, cinematic" \
|
||||
--aspect-ratio=16:9 \
|
||||
--count=1 \
|
||||
--output=sunset
|
||||
```
|
||||
|
||||
**Replace `<your prompt here>` with the user's image description.**
|
||||
|
||||
---
|
||||
The script writes `<output>-0.jpeg`, `<output>-1.jpeg`, … to the current working directory. On failure it exits non-zero with a descriptive error.
|
||||
|
||||
## Aspect Ratio Guide
|
||||
|
||||
@@ -110,28 +71,13 @@ done
|
||||
| `4:3` | Standard — presentations, blog images |
|
||||
| `3:4` | Portrait standard — posters, portraits |
|
||||
|
||||
---
|
||||
|
||||
## Configuration Reference
|
||||
|
||||
### Environment Variables
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Required | Description |
|
||||
|----------|----------|-------------|
|
||||
| `MINIMAX_API_KEY` | Yes | Your MiniMax API key |
|
||||
| `MINIMAX_API_BASE_URL` | No | API base URL (default: `https://api.minimax.io`) |
|
||||
|
||||
### API Parameters
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-----------|------|---------|-------------|
|
||||
| `model` | string | `image-01` | Model to use |
|
||||
| `prompt` | string | required | Image description |
|
||||
| `aspect_ratio` | string | `16:9` | Image aspect ratio |
|
||||
| `response_format` | string | `base64` | Output format |
|
||||
|
||||
---
|
||||
|
||||
## Example Output
|
||||
|
||||
```
|
||||
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# generate.sh — Generate images via MiniMax /v1/image_generation.
|
||||
# Usage: bash scripts/generate.sh "<prompt>" [--aspect-ratio=16:9] [--count=1] [--output=output]
|
||||
set -euo pipefail
|
||||
|
||||
die() { echo "ERROR: $*" >&2; exit 1; }
|
||||
|
||||
# --- Dependencies ---
|
||||
for cmd in curl jq base64; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || die "Required command not found: $cmd"
|
||||
done
|
||||
|
||||
# --- Credentials ---
|
||||
[[ -z "${MINIMAX_API_KEY:-}" ]] && die "MINIMAX_API_KEY is not set"
|
||||
API_BASE_URL="${MINIMAX_API_BASE_URL:-https://api.minimax.io}"
|
||||
|
||||
# --- Parse args ---
|
||||
PROMPT=""
|
||||
ASPECT_RATIO="16:9"
|
||||
COUNT=1
|
||||
OUTPUT_PREFIX="output"
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--aspect-ratio=*) ASPECT_RATIO="${arg#*=}" ;;
|
||||
--count=*) COUNT="${arg#*=}" ;;
|
||||
--output=*) OUTPUT_PREFIX="${arg#*=}" ;;
|
||||
--*) die "Unknown flag: $arg" ;;
|
||||
*) if [[ -z "$PROMPT" ]]; then PROMPT="$arg"; else die "Unexpected positional argument: $arg"; fi ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -z "$PROMPT" ]] && die "Usage: bash scripts/generate.sh \"<prompt>\" [--aspect-ratio=16:9] [--count=1] [--output=output]"
|
||||
|
||||
case "$ASPECT_RATIO" in
|
||||
16:9|1:1|9:16|4:3|3:4) ;;
|
||||
*) die "Unsupported aspect ratio: $ASPECT_RATIO (valid: 16:9, 1:1, 9:16, 4:3, 3:4)" ;;
|
||||
esac
|
||||
|
||||
if ! [[ "$COUNT" =~ ^[0-9]+$ ]] || (( COUNT < 1 )); then
|
||||
die "Invalid --count: $COUNT (must be a positive integer)"
|
||||
fi
|
||||
|
||||
echo "🎨 MiniMax Image Generation" >&2
|
||||
echo "├─ Prompt: \"$PROMPT\"" >&2
|
||||
echo "├─ Aspect ratio: $ASPECT_RATIO" >&2
|
||||
echo "├─ Count: $COUNT" >&2
|
||||
echo "└─ Model: image-01" >&2
|
||||
echo "" >&2
|
||||
|
||||
# --- Build JSON payload safely (jq handles escaping) ---
|
||||
PAYLOAD=$(jq -n \
|
||||
--arg prompt "$PROMPT" \
|
||||
--arg ratio "$ASPECT_RATIO" \
|
||||
--argjson n "$COUNT" \
|
||||
'{model:"image-01", prompt:$prompt, aspect_ratio:$ratio, num_images:$n, response_format:"base64"}')
|
||||
|
||||
# --- Call API ---
|
||||
RESPONSE=$(curl -sS -X POST "${API_BASE_URL}/v1/image_generation" \
|
||||
-H "Authorization: Bearer ${MINIMAX_API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$PAYLOAD") || die "MiniMax API request failed"
|
||||
|
||||
# --- Check for API error ---
|
||||
ERR=$(echo "$RESPONSE" | jq -r '.base_resp.status_msg // empty')
|
||||
CODE=$(echo "$RESPONSE" | jq -r '.base_resp.status_code // 0')
|
||||
if [[ "$CODE" != "0" && -n "$ERR" ]]; then
|
||||
die "MiniMax API error (code=$CODE): $ERR"
|
||||
fi
|
||||
|
||||
# --- Decode and save ---
|
||||
COUNT_SAVED=0
|
||||
while IFS= read -r image_b64; do
|
||||
[[ -z "$image_b64" ]] && continue
|
||||
OUT="${OUTPUT_PREFIX}-${COUNT_SAVED}.jpeg"
|
||||
echo "$image_b64" | base64 -d > "$OUT" || die "Failed to decode image $COUNT_SAVED"
|
||||
echo "Saved: $OUT" >&2
|
||||
COUNT_SAVED=$((COUNT_SAVED + 1))
|
||||
done < <(echo "$RESPONSE" | jq -r '.data.image_base64[]?')
|
||||
|
||||
(( COUNT_SAVED == 0 )) && die "No images returned: $RESPONSE"
|
||||
|
||||
echo "Done." >&2
|
||||
Reference in New Issue
Block a user