初始发布: 21 个 skills (Claude Code / Codex / DSH)

This commit is contained in:
2026-08-14 01:51:44 +08:00
commit ea0857bedb
129 changed files with 35566 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
---
name: grok-imagine
description: Generate or edit images with xAI Grok Imagine. Use when the user asks to create an image with Grok, draw/paint something, generate concept art, posters, illustrations, photos, or edit an existing image with Grok Imagine. Trigger words include "grok imagine", "用 grok 生图", "grok 画", "imagine 生图". Requires an authenticated `grok` CLI (SuperGrok or X Premium+ subscription).
---
# Grok Imagine
Generate or edit images with xAI's Grok Imagine models.
## Prerequisites
- Install the Grok CLI (already present at `~/.grok/bin/grok`) and sign in once: `grok login`
- No API key needed; the SuperGrok / X Premium+ subscription provides `/imagine` access.
## Interactive mode (grok CLI)
Run `grok`, then use the TUI slash command:
```text
/imagine <prompt>
/imagine-video <prompt>
```
The same `/imagine` command also works in headless mode (`grok -p "/imagine ..."`), which the script below wraps.
## Scripted generation
Run `scripts/grok_imagine.py`:
```bash
V=~/.codex/skills/grok-imagine/scripts/grok_imagine.py
# Text to image
python3 "$V" "a cozy bar at night, anime style" -a 16:9
# Copy the result into a specific folder
python3 "$V" "neon cyberpunk alley" -a 9:16 -o ./outputs
```
The script prints the absolute path of the saved image. Images land in the grok session directory by default; use `-o DIR` to copy them somewhere stable.
## Notes
- `/imagine` consumes the subscription's image-generation quota.
- Image editing is interactive-only: paste the image in the grok TUI, then run `/imagine <edit instruction>`.
- For videos, use Grok Build's `/imagine-video` interactively.
+4
View File
@@ -0,0 +1,4 @@
interface:
display_name: "Grok Imagine"
short_description: "用 Grok CLI 生成与编辑图片,支持文生图、图生图和画质参数"
default_prompt: "Use $grok-imagine to generate an image with Grok CLI."
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
"""Generate images via the Grok Build CLI /imagine command.
Requires an authenticated grok CLI (SuperGrok/X Premium+ subscription):
grok login
"""
import argparse
import re
import shutil
import subprocess
import sys
import time
from pathlib import Path
from typing import Optional
GROK = shutil.which("grok") or str(Path.home() / ".grok" / "bin" / "grok")
SESSION_ROOT = Path.home() / ".grok" / "sessions"
IMAGE_EXTS = {".jpg", ".jpeg", ".png", ".webp"}
def die(msg: str) -> None:
print(f"error: {msg}", file=sys.stderr)
sys.exit(1)
def newest_image(since_ts: float) -> Optional[Path]:
best = None
if not SESSION_ROOT.is_dir():
return None
for p in SESSION_ROOT.rglob("*"):
if not p.is_file() or p.suffix.lower() not in IMAGE_EXTS:
continue
try:
mtime = p.stat().st_mtime
except OSError:
continue
if mtime >= since_ts and (best is None or mtime > best.stat().st_mtime):
best = p
return best
def path_from_output(text: str) -> Optional[Path]:
m = re.search(r"`([^`]+\.(?:jpg|jpeg|png|webp))`", text, re.I)
if not m:
m = re.search(r"([\w./\\-]+\.(?:jpg|jpeg|png|webp))", text, re.I)
if not m:
return None
candidate = Path(m.group(1))
if candidate.is_file():
return candidate.resolve()
# Output paths are usually relative to the session dir; resolve via search below.
return None
def main() -> None:
parser = argparse.ArgumentParser(
description="Generate images with Grok Imagine through the grok CLI"
)
parser.add_argument("prompt", help="text description of the image")
parser.add_argument("-a", "--aspect-ratio", help="e.g. 1:1, 16:9, 9:16, 4:3")
parser.add_argument("-o", "--output", help="copy the result into this directory")
args = parser.parse_args()
if not shutil.which(GROK):
die("grok CLI not found. Install with: curl -fsSL https://x.ai/cli/install.sh | bash")
full_prompt = f"/imagine {args.prompt}"
if args.aspect_ratio:
full_prompt += f", aspect ratio {args.aspect_ratio}"
before = time.time()
proc = subprocess.run(
[GROK, "-p", full_prompt, "--no-auto-update"],
capture_output=True,
text=True,
timeout=600,
)
output = proc.stdout + proc.stderr
print(output)
if proc.returncode != 0:
die(f"grok exited with code {proc.returncode}")
image = newest_image(before - 2) or path_from_output(output)
if image is None:
die("could not locate the generated image (check the output above)")
image = image.resolve()
if args.output:
outdir = Path(args.output)
outdir.mkdir(parents=True, exist_ok=True)
dest = outdir / image.name
if dest.exists():
dest = outdir / f"{image.stem}-{int(time.time())}{image.suffix}"
shutil.copy2(image, dest)
image = dest.resolve()
print(image)
if __name__ == "__main__":
main()