Skip to content

LeoYeAI/agent-master-skills / skills/anygen-diagram-generator

anygen-diagram

Verified

Use this skill any time the user wants to create diagrams, flowcharts, or visual structures. This includes: architecture diagrams, mind maps, org charts, user journey maps, system design diagrams, ER diagrams, sequence diagrams, process flows, decision trees, network topologies, class diagrams, Gantt charts, SWOT analysis diagrams, wireframes, and sitemaps. Also trigger when: user says 画个流程图, 做个架构图, 思维导图, 组织架构图, 用户旅程图, 系统设计图, 甘特图. If a diagram or visual structure needs to be drawn, use this skill.

FileKindSize
SKILL.mdskill md18.5 KB
_meta.jsonconfig1006 B
scripts/anygen.pyscript35.8 KB
scripts/auth.pyscript1000 B
scripts/diagram-to-image.tsscript13.8 KB
scripts/fileutil.pyscript2.1 KB
scripts/package-lock.jsonmanifest18.0 KB
scripts/package.jsonmanifest335 B
scripts/render-diagram.shscript4.1 KB
skill.mdmarkdown13.2 KB

scripts/render-diagram.sh

View on GitHub
#!/usr/bin/env bash
# render-diagram.sh — Convert Excalidraw/DrawIO diagrams to PNG
#
# Usage: render-diagram.sh <type> <input> <output> [options]
#
# Arguments:
#   type    Diagram type: excalidraw | drawio
#   input   Input file path (use "-" for stdin)
#   output  Output PNG file path
#
# Options:
#   --scale <n>        PNG scale factor (default: 2)
#   --background <hex> Background color (default: #ffffff)
#   --padding <n>      Export padding in px (default: 20)
#
# Dependencies (playwright, tsx) are auto-installed on first run.

set -euo pipefail

# ---- Colors ----

GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# ---- Paths ----

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# ---- Usage ----

usage() {
  cat <<EOF
Usage: $(basename "$0") <type> <input> <output> [options]

Arguments:
  type    Diagram type: excalidraw | drawio
  input   Input file path (use "-" for stdin)
  output  Output PNG file path

Options:
  --scale <n>        PNG scale factor (default: 2)
  --background <hex> Background color (default: #ffffff)
  --padding <n>      Export padding in px (default: 20)

Examples:
  $(basename "$0") excalidraw diagram.json output.png
  $(basename "$0") drawio diagram.xml output.png
  $(basename "$0") excalidraw diagram.json output.png --scale 3
  cat diagram.json | $(basename "$0") excalidraw - output.png
EOF
}

# ---- Show usage if no arguments or --help ----

if [[ $# -eq 0 ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
  usage
  exit 0
fi

# ---- Parse positional arguments ----

TYPE="${1:-}"
INPUT_FILE="${2:-}"
OUTPUT_FILE="${3:-}"

if [[ -z "$TYPE" ]] || [[ -z "$INPUT_FILE" ]] || [[ -z "$OUTPUT_FILE" ]]; then
  echo -e "${RED}✗ Missing required arguments${NC}" >&2
  echo "" >&2
  usage >&2
  exit 1
fi

# ---- Validate diagram type ----

if [[ "$TYPE" != "excalidraw" ]] && [[ "$TYPE" != "drawio" ]]; then
  echo -e "${RED}✗ Unsupported diagram type: $TYPE${NC}" >&2
  echo -e "${YELLOW}  Supported types: excalidraw, drawio${NC}" >&2
  exit 1
fi

# ---- Validate input file ----

if [[ "$INPUT_FILE" != "-" ]] && [[ ! -f "$INPUT_FILE" ]]; then
  echo -e "${RED}✗ Input file not found: $INPUT_FILE${NC}" >&2
  exit 1
fi

# ---- Check Node.js ----

if ! command -v node &> /dev/null; then
  echo -e "${RED}✗ Node.js not found${NC}" >&2
  echo -e "${YELLOW}  Please install Node.js (v18+): https://nodejs.org${NC}" >&2
  exit 1
fi

if ! command -v npm &> /dev/null; then
  echo -e "${RED}✗ npm not found${NC}" >&2
  echo -e "${YELLOW}  Please install npm${NC}" >&2
  exit 1
fi

# ---- Auto-install npm dependencies ----

if [[ ! -d "$SCRIPT_DIR/node_modules/playwright" ]] || [[ ! -d "$SCRIPT_DIR/node_modules/tsx" ]]; then
  echo -e "${BLUE}⚙ First run, installing dependencies...${NC}"
  if (cd "$SCRIPT_DIR" && npm install --no-audit --no-fund --loglevel=error); then
    echo -e "${GREEN}✓ Dependencies installed${NC}"
  else
    echo -e "${RED}✗ Failed to install dependencies${NC}" >&2
    echo -e "${YELLOW}  Please run manually: cd $SCRIPT_DIR && npm install${NC}" >&2
    exit 1
  fi
fi

# ---- Auto-install Playwright Chromium ----

PLAYWRIGHT_BIN="$SCRIPT_DIR/node_modules/.bin/playwright"
if [[ -x "$PLAYWRIGHT_BIN" ]]; then
  # Check if chromium browser is available
  if ! "$PLAYWRIGHT_BIN" install --dry-run chromium &> /dev/null; then
    echo -e "${BLUE}⚙ Installing Chromium browser...${NC}"
    if "$PLAYWRIGHT_BIN" install chromium; then
      echo -e "${GREEN}✓ Chromium installed${NC}"
    else
      echo -e "${YELLOW}⚠ Chromium installation may have issues, will try system browser${NC}"
    fi
  fi
fi

# ---- Create output directory ----

OUTPUT_DIR="$(dirname "$OUTPUT_FILE")"
if [[ "$OUTPUT_DIR" != "." ]] && [[ ! -d "$OUTPUT_DIR" ]]; then
  mkdir -p "$OUTPUT_DIR"
fi

# ---- Render ----

echo -e "${BLUE}▶ Rendering $TYPE diagram -> PNG${NC}"
echo -e "${BLUE}  Input:  $INPUT_FILE${NC}"
echo -e "${BLUE}  Output: $OUTPUT_FILE${NC}"

TSX_BIN="$SCRIPT_DIR/node_modules/.bin/tsx"

if "$TSX_BIN" "$SCRIPT_DIR/diagram-to-image.ts" "$@"; then
  echo -e "${GREEN}✓ Render complete: $OUTPUT_FILE${NC}"
  exit 0
else
  echo -e "${RED}✗ Render failed${NC}" >&2
  exit 1
fi
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall