Created
April 13, 2026 05:52
-
-
Save halu0915/2dce2a5dbaae9699807f0d3f8e51549e to your computer and use it in GitHub Desktop.
報告生成+Fireworks技能一鍵安裝
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "📄🎨 安裝報告生成 + Fireworks Tech Graph 技能包" | |
| echo "================================================" | |
| CLAUDE_SKILLS="$HOME/.claude/skills" | |
| HERMES_SKILLS="$HOME/.hermes/skills/productivity" | |
| # 1. Report Generator | |
| echo "" | |
| echo "1️⃣ 安裝報告生成技能..." | |
| mkdir -p "$CLAUDE_SKILLS/report-generator/scripts" | |
| mkdir -p "$CLAUDE_SKILLS/report-generator/templates" | |
| mkdir -p "$HERMES_SKILLS/report-generator/scripts" | |
| mkdir -p "$HERMES_SKILLS/report-generator/templates" | |
| # Download templates and scripts from gist | |
| GIST_BASE="https://gist.githubusercontent.com/halu0915" | |
| # Generate PDF script | |
| cat > "$CLAUDE_SKILLS/report-generator/scripts/generate-pdf.sh" << 'PDFSCRIPT' | |
| #!/bin/bash | |
| # PDF 報告生成器 — Markdown → HTML → PDF (Playwright) | |
| INPUT="$1"; OUTPUT="$2" | |
| [ -z "$INPUT" ] || [ -z "$OUTPUT" ] && echo "用法: bash $0 input.md output.pdf" && exit 1 | |
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | |
| TEMPLATE="$SCRIPT_DIR/../templates/standard.html" | |
| # Find playwright | |
| for dir in $(npm root -g)/playwright /usr/local/lib/node_modules/playwright; do | |
| [ -d "$dir" ] && PLAYWRIGHT_DIR="$(dirname $dir)" && break | |
| done | |
| TEMP=$(mktemp -d) | |
| # Convert MD to HTML with template | |
| python3 -c " | |
| import re, sys | |
| with open('$INPUT', 'r') as f: md = f.read() | |
| title = re.search(r'^#\s+(.+)', md, re.MULTILINE) | |
| title = title.group(1) if title else 'Report' | |
| # Simple MD to HTML | |
| html = md | |
| html = re.sub(r'^### (.+)$', r'<h3>\1</h3>', html, flags=re.MULTILINE) | |
| html = re.sub(r'^## (.+)$', r'<h2>\1</h2>', html, flags=re.MULTILINE) | |
| html = re.sub(r'^# (.+)$', r'<h1>\1</h1>', html, flags=re.MULTILINE) | |
| html = re.sub(r'\*\*(.+?)\*\*', r'<strong>\1</strong>', html) | |
| html = re.sub(r'^\- (.+)$', r'<li>\1</li>', html, flags=re.MULTILINE) | |
| html = re.sub(r'(<li>.*</li>)', r'<ul>\1</ul>', html, flags=re.DOTALL) | |
| with open('$TEMPLATE', 'r') as f: template = f.read() | |
| result = template.replace('{{TITLE}}', title).replace('{{CONTENT}}', html) | |
| with open('$TEMP/report.html', 'w') as f: f.write(result) | |
| " | |
| NODE_PATH="$PLAYWRIGHT_DIR" node -e " | |
| const{chromium}=require('playwright');(async()=>{ | |
| const b=await chromium.launch();const p=await b.newPage(); | |
| await p.goto('file://$TEMP/report.html');await p.waitForTimeout(2000); | |
| await p.pdf({path:'$OUTPUT',format:'A4',printBackground:true,margin:{top:'18mm',bottom:'22mm',left:'14mm',right:'14mm'}}); | |
| await b.close();console.log('PDF generated: $OUTPUT'); | |
| })().catch(e=>{console.error(e.message);process.exit(1)}); | |
| " | |
| rm -rf "$TEMP" | |
| PDFSCRIPT | |
| chmod +x "$CLAUDE_SKILLS/report-generator/scripts/generate-pdf.sh" | |
| # Copy to Hermes | |
| cp "$CLAUDE_SKILLS/report-generator/scripts/generate-pdf.sh" "$HERMES_SKILLS/report-generator/scripts/" | |
| # Download templates | |
| curl -fsSL "https://raw.githubusercontent.com/nicepkg/openclaw/main/src/entrypoints/cli/components/chat/lib/hooks/template-standard.html" -o "$CLAUDE_SKILLS/report-generator/templates/standard.html" 2>/dev/null || { | |
| # Create basic template | |
| cat > "$CLAUDE_SKILLS/report-generator/templates/standard.html" << 'TMPL' | |
| <!DOCTYPE html><html lang="zh-TW"><head><meta charset="UTF-8"><title>{{TITLE}}</title> | |
| <style>@page{size:A4;margin:18mm 14mm 22mm 14mm}*{box-sizing:border-box;margin:0;padding:0}body{font-family:"PingFang TC","Noto Sans TC",sans-serif;font-size:12.5px;line-height:1.75;color:#2c3e50;max-width:780px;margin:0 auto}h1{font-size:24px;color:#fff;background:linear-gradient(135deg,#1a3a5c,#2a6496);padding:14px 20px;margin:36px -14px 20px;border-radius:4px}h2{font-size:16px;color:#1a3a5c;margin:28px 0 14px;padding:8px 0 8px 14px;border-left:5px solid #2a6496;background:linear-gradient(90deg,#e8f4fd,transparent)}h3{font-size:13.5px;color:#2a6496;margin:18px 0 8px}table{width:100%;border-collapse:collapse;margin:12px 0;font-size:11.5px}th{background:#1a3a5c;color:#fff;padding:8px 10px;text-align:left}td{padding:6px 10px;border-bottom:1px solid #e0e6ec}tr:nth-child(even){background:#f4f7fa}ul,ol{padding-left:20px;margin:8px 0}li{margin:4px 0}strong{color:#1a3a5c}blockquote{background:#fff8e1;border-left:4px solid #ffc107;padding:12px 16px;margin:12px 0;border-radius:0 6px 6px 0}code{background:#f0f4f8;padding:2px 6px;border-radius:3px;font-size:11px}pre{background:#1e293b;color:#e2e8f0;padding:14px;border-radius:6px;overflow-x:auto;margin:12px 0}img{max-width:100%;max-height:500px;height:auto}</style></head><body>{{CONTENT}}</body></html> | |
| TMPL | |
| } | |
| cp "$CLAUDE_SKILLS/report-generator/templates/standard.html" "$HERMES_SKILLS/report-generator/templates/" | |
| echo "✅ 報告生成器安裝完成" | |
| # 2. Fireworks Tech Graph | |
| echo "" | |
| echo "2️⃣ 安裝 Fireworks Tech Graph..." | |
| git clone --depth 1 https://github.com/yizhiyanhua-ai/fireworks-tech-graph.git "$CLAUDE_SKILLS/fireworks-tech-graph" 2>/dev/null || { | |
| echo " 已存在,更新中..." | |
| cd "$CLAUDE_SKILLS/fireworks-tech-graph" && git pull 2>/dev/null | |
| } | |
| cp -r "$CLAUDE_SKILLS/fireworks-tech-graph" "$HERMES_SKILLS/fireworks-tech-graph" 2>/dev/null | |
| echo "✅ Fireworks Tech Graph 安裝完成" | |
| # 3. Dependencies | |
| echo "" | |
| echo "3️⃣ 安裝依賴..." | |
| brew install librsvg 2>/dev/null || echo " librsvg 已安裝" | |
| npm install -g playwright 2>/dev/null || echo " playwright 已安裝" | |
| echo "" | |
| echo "================================================" | |
| echo "✅ 全部安裝完成!" | |
| echo "" | |
| echo "報告生成:" | |
| echo " bash ~/.claude/skills/report-generator/scripts/generate-pdf.sh input.md output.pdf" | |
| echo "" | |
| echo "Fireworks 圖表(在 Claude Code 直接說):" | |
| echo " 「畫一個XXX架構圖,dark風格」" | |
| echo " 7 種風格 × 14 種圖表類型" | |
| echo "================================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment