@drunkcoding/agents-and-skills 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.claude-plugin/marketplace.json +26 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -0
  4. package/package.json +33 -0
  5. package/plugins/tech-graph/.claude-plugin/plugin.json +17 -0
  6. package/plugins/tech-graph/README.md +66 -0
  7. package/plugins/tech-graph/agents/tech-graph.md +89 -0
  8. package/plugins/tech-graph/commands/tech-graph.md +13 -0
  9. package/plugins/tech-graph/scripts/check-deps.sh +55 -0
  10. package/plugins/tech-graph/skills/tech-graph/LICENSE +21 -0
  11. package/plugins/tech-graph/skills/tech-graph/README.md +555 -0
  12. package/plugins/tech-graph/skills/tech-graph/README.zh.md +514 -0
  13. package/plugins/tech-graph/skills/tech-graph/SKILL.md +559 -0
  14. package/plugins/tech-graph/skills/tech-graph/agents/openai.yaml +4 -0
  15. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style1-flat.png +0 -0
  16. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style2-dark.png +0 -0
  17. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style3-blueprint.png +0 -0
  18. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style4-notion.png +0 -0
  19. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style5-glass.png +0 -0
  20. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style6-claude.png +0 -0
  21. package/plugins/tech-graph/skills/tech-graph/assets/samples/sample-style7-openai.png +0 -0
  22. package/plugins/tech-graph/skills/tech-graph/fixtures/agent-memory-types-style4.json +181 -0
  23. package/plugins/tech-graph/skills/tech-graph/fixtures/api-flow-style7.json +40 -0
  24. package/plugins/tech-graph/skills/tech-graph/fixtures/mem0-style1.json +297 -0
  25. package/plugins/tech-graph/skills/tech-graph/fixtures/microservices-style3.json +64 -0
  26. package/plugins/tech-graph/skills/tech-graph/fixtures/multi-agent-style5.json +45 -0
  27. package/plugins/tech-graph/skills/tech-graph/fixtures/system-architecture-style6.json +48 -0
  28. package/plugins/tech-graph/skills/tech-graph/fixtures/tool-call-style2.json +182 -0
  29. package/plugins/tech-graph/skills/tech-graph/package.json +42 -0
  30. package/plugins/tech-graph/skills/tech-graph/references/icons.md +406 -0
  31. package/plugins/tech-graph/skills/tech-graph/references/style-1-flat-icon.md +108 -0
  32. package/plugins/tech-graph/skills/tech-graph/references/style-2-dark-terminal.md +107 -0
  33. package/plugins/tech-graph/skills/tech-graph/references/style-3-blueprint.md +113 -0
  34. package/plugins/tech-graph/skills/tech-graph/references/style-4-notion-clean.md +95 -0
  35. package/plugins/tech-graph/skills/tech-graph/references/style-5-glassmorphism.md +125 -0
  36. package/plugins/tech-graph/skills/tech-graph/references/style-6-claude-official.md +209 -0
  37. package/plugins/tech-graph/skills/tech-graph/references/style-7-openai.md +215 -0
  38. package/plugins/tech-graph/skills/tech-graph/references/style-diagram-matrix.md +135 -0
  39. package/plugins/tech-graph/skills/tech-graph/references/svg-layout-best-practices.md +100 -0
  40. package/plugins/tech-graph/skills/tech-graph/scripts/README.md +269 -0
  41. package/plugins/tech-graph/skills/tech-graph/scripts/generate-diagram.sh +181 -0
  42. package/plugins/tech-graph/skills/tech-graph/scripts/generate-from-template.py +1587 -0
  43. package/plugins/tech-graph/skills/tech-graph/scripts/test-all-styles.sh +143 -0
  44. package/plugins/tech-graph/skills/tech-graph/scripts/validate-svg.sh +306 -0
  45. package/plugins/tech-graph/skills/tech-graph/templates/agent-architecture.svg +28 -0
  46. package/plugins/tech-graph/skills/tech-graph/templates/architecture.svg +23 -0
  47. package/plugins/tech-graph/skills/tech-graph/templates/comparison-matrix.svg +14 -0
  48. package/plugins/tech-graph/skills/tech-graph/templates/data-flow.svg +28 -0
  49. package/plugins/tech-graph/skills/tech-graph/templates/er-diagram.svg +21 -0
  50. package/plugins/tech-graph/skills/tech-graph/templates/flowchart.svg +21 -0
  51. package/plugins/tech-graph/skills/tech-graph/templates/sequence.svg +20 -0
  52. package/plugins/tech-graph/skills/tech-graph/templates/state-machine.svg +20 -0
  53. package/plugins/tech-graph/skills/tech-graph/templates/timeline.svg +19 -0
  54. package/plugins/tech-graph/skills/tech-graph/templates/use-case.svg +21 -0
@@ -0,0 +1,269 @@
1
+ # Fireworks Tech Graph - Scripts
2
+
3
+ 辅助脚本集合,用于提高 SVG 图表生成的稳定性和效率。
4
+
5
+ ## 脚本列表
6
+
7
+ ### 1. validate-svg.sh
8
+
9
+ SVG 验证脚本,检查 SVG 语法并报告详细错误。
10
+
11
+ **用法:**
12
+ ```bash
13
+ ./validate-svg.sh <svg-file>
14
+ ```
15
+
16
+ **检查项目:**
17
+ - 标签平衡(开标签 vs 闭标签)
18
+ - 属性引号完整性
19
+ - 特殊字符转义
20
+ - Marker 引用完整性
21
+ - 闭合标签 `</svg>`
22
+ - 渲染验证(cairosvg 优先,rsvg-convert 兜底)
23
+
24
+ **示例:**
25
+ ```bash
26
+ ./validate-svg.sh /path/to/diagram.svg
27
+ ```
28
+
29
+ ### 2. generate-diagram.sh
30
+
31
+ SVG 图表生成脚本,提供自动验证和 PNG 导出。
32
+
33
+ **用法:**
34
+ ```bash
35
+ ./generate-diagram.sh [OPTIONS]
36
+ ```
37
+
38
+ **选项:**
39
+ - `-t, --type TYPE` - 图表类型(见脚本帮助)
40
+ - `-s, --style STYLE` - 风格编号(1-7,默认:1)
41
+ - `-o, --output PATH` - 输出路径(默认:当前目录)
42
+ - `-w, --width WIDTH` - PNG 宽度(像素,默认:1920)
43
+ - `--no-validate` - 跳过验证
44
+ - `-h, --help` - 显示帮助
45
+
46
+ **示例:**
47
+ ```bash
48
+ # 生成架构图(Style 1)
49
+ ./generate-diagram.sh -t architecture -s 1 -o ./output/arch.svg
50
+
51
+ # 生成流程图(Style 2,2400px 宽)
52
+ ./generate-diagram.sh -t flowchart -s 2 -w 2400
53
+ ```
54
+
55
+ **注意:** SVG 内容需要先准备好;这个脚本只负责验证与导出。
56
+
57
+ ### 3. generate-from-template.py
58
+
59
+ 基于风格配置和 JSON 数据生成 SVG。当前版本不再只是简单塞入 `nodes/arrows`,
60
+ 而是会执行 style guide 中的部分可计算规则,例如:
61
+
62
+ - `style` - 风格编号(1-7)
63
+ - `containers` - 泳道 / 分组容器
64
+ - `containers[].header_prefix` / `containers[].header_text` - 工程编号式分区标题
65
+ - `containers[].side_label` - 左侧 layer label
66
+ - `nodes[].kind` - 语义组件类型,例如 `double_rect`、`cylinder`、`document`、`terminal`、`circle_cluster`
67
+ - `arrows[].flow` - 语义箭头类型,例如 `control`、`write`、`read`、`data`
68
+ - `source_port` / `target_port` - 指定端口锚点
69
+ - `route_points` / `corridor_x` / `corridor_y` - 控制复杂图的走线质量
70
+ - `style_overrides` - 对现有 style 做局部覆盖
71
+ - `window_controls` / `meta_*` - 顶部终端 chrome
72
+ - `blueprint_title_block` - 工程蓝图右下角 title block
73
+
74
+ **用法:**
75
+ ```bash
76
+ python3 ./generate-from-template.py architecture ./output/arch.svg '{"style":1,"title":"My Diagram","containers":[],"nodes":[],"arrows":[]}'
77
+ ```
78
+
79
+ **示例:**
80
+ ```bash
81
+ python3 ./generate-from-template.py memory ./output/mem0.svg '{
82
+ "style": 1,
83
+ "title": "Mem0 Memory Architecture",
84
+ "containers": [
85
+ {"x":30,"y":90,"width":900,"height":90,"label":"Input Layer","header_prefix":"01"}
86
+ ],
87
+ "nodes": [
88
+ {"id":"manager","kind":"double_rect","x":360,"y":220,"width":300,"height":72,"label":"Memory Manager"},
89
+ {"id":"vector","kind":"cylinder","x":90,"y":360,"width":140,"height":110,"label":"Vector Store"}
90
+ ],
91
+ "arrows": [
92
+ {"source":"manager","target":"vector","flow":"write","dashed":true}
93
+ ]
94
+ }'
95
+ ```
96
+
97
+ ### 4. test-all-styles.sh
98
+
99
+ 批量测试脚本,测试 7 种风格的回归样例图。
100
+
101
+ **用法:**
102
+ ```bash
103
+ ./test-all-styles.sh
104
+ ```
105
+
106
+ **功能:**
107
+ - 检查所有风格的参考文件
108
+ - 渲染 `fixtures/*.json` 回归样例
109
+ - 验证生成出的 SVG 文件
110
+ - 导出 PNG 文件到 `test-output/` 目录
111
+ - 生成测试报告
112
+
113
+ **输出:**
114
+ - 测试摘要(通过/失败统计)
115
+ - PNG 文件(带时间戳)
116
+ - 详细的验证错误信息
117
+
118
+ **示例:**
119
+ ```bash
120
+ ./test-all-styles.sh
121
+ ```
122
+
123
+ ## 依赖
124
+
125
+ 所有脚本需要至少一个 PNG 渲染器(推荐 cairosvg):
126
+
127
+ - **cairosvg**(推荐)- SVG 转 PNG,CSS 支持最好
128
+ ```bash
129
+ pip install cairosvg
130
+ ```
131
+
132
+ - **rsvg-convert**(备选)- 系统包;复杂 SVG 可能丢失 CSS / `<foreignObject>`
133
+ ```bash
134
+ brew install librsvg # macOS
135
+ sudo apt install librsvg2-bin # Ubuntu/Debian
136
+ ```
137
+
138
+ - **puppeteer**(最高保真)- 真实 Chromium 渲染
139
+ ```bash
140
+ npm install puppeteer
141
+ ```
142
+
143
+ `generate-diagram.sh` 会优先调用 cairosvg,缺失时自动回退到 rsvg-convert。完整对比与 puppeteer 脚本见 [SKILL.md → SVG → PNG Conversion](../SKILL.md)。
144
+
145
+ - **grep, sed, awk** - 文本处理(macOS 自带)
146
+
147
+ ## 目录结构
148
+
149
+ ```
150
+ fireworks-tech-graph/
151
+ ├── SKILL.md # Skill 主文档
152
+ ├── references/ # 风格参考文件
153
+ │ ├── style-1-flat-icon.md
154
+ │ ├── style-2-dark-terminal.md
155
+ │ └── ...
156
+ ├── fixtures/ # 回归测试样例(JSON)
157
+ │ ├── mem0-style1.json
158
+ │ ├── tool-call-style2.json
159
+ │ └── ...
160
+ ├── scripts/ # 辅助脚本(本目录)
161
+ │ ├── README.md # 本文档
162
+ │ ├── validate-svg.sh # SVG 验证
163
+ │ ├── generate-diagram.sh # SVG 验证与 PNG 导出
164
+ │ ├── generate-from-template.py # 模板化生成 SVG
165
+ │ └── test-all-styles.sh # 批量测试
166
+ └── test-output/ # 测试输出目录(自动创建)
167
+ ```
168
+
169
+ ## 使用场景
170
+
171
+ ### 场景 1:验证现有 SVG
172
+
173
+ ```bash
174
+ cd ~/.claude/skills/fireworks-tech-graph/scripts
175
+ ./validate-svg.sh /path/to/your-diagram.svg
176
+ ```
177
+
178
+ ### 场景 2:生成并验证图表
179
+
180
+ 1. 使用 Claude Code 生成 SVG 内容
181
+ 2. 运行验证和导出:
182
+ ```bash
183
+ ./generate-diagram.sh -t architecture -s 1 -o ./output/arch.svg
184
+ ```
185
+
186
+ ### 场景 3:批量测试所有风格
187
+
188
+ ```bash
189
+ cd ~/.claude/skills/fireworks-tech-graph/scripts
190
+ ./test-all-styles.sh
191
+ ```
192
+
193
+ 测试脚本会自动:
194
+ 1. 读取 `../fixtures/*.json`
195
+ 2. 按 `template_type + style` 调用 `generate-from-template.py`
196
+ 3. 运行 `validate-svg.sh`
197
+ 4. 导出 PNG 到 `../test-output/`
198
+
199
+ 查看测试输出:
200
+ ```bash
201
+ ls -lh ../test-output/
202
+ ```
203
+
204
+ ## 故障排除
205
+
206
+ ### 问题:找不到 PNG 渲染器
207
+
208
+ **解决方案(任选其一,推荐 cairosvg):**
209
+ ```bash
210
+ pip install cairosvg # 推荐
211
+ brew install librsvg # macOS 系统包
212
+ sudo apt install librsvg2-bin # Ubuntu/Debian
213
+ ```
214
+
215
+ ### 问题:rsvg-convert 渲染缺框/缺文字
216
+
217
+ **原因:** rsvg-convert 对 `<foreignObject>`、CSS `filter`、复杂 `<style>` 块支持有限。
218
+
219
+ **解决方案:** 切换到 cairosvg:
220
+ ```bash
221
+ pip install cairosvg
222
+ ```
223
+ 脚本会自动优先使用 cairosvg。如果仍需要像素级还原(例如浏览器生成的 SVG),改用 puppeteer(见 SKILL.md)。
224
+
225
+ ### 问题:权限被拒绝
226
+
227
+ **解决方案:**
228
+ ```bash
229
+ chmod +x *.sh
230
+ ```
231
+
232
+ ### 问题:SVG 验证失败
233
+
234
+ **解决方案:**
235
+ 1. 查看详细错误信息
236
+ 2. 使用 Edit 工具修复语法错误
237
+ 3. 重新运行验证
238
+
239
+ ## 开发说明
240
+
241
+ ### 添加新的验证规则
242
+
243
+ 编辑 `validate-svg.sh`,在现有检查项后添加新的检查逻辑:
244
+
245
+ ```bash
246
+ # Check N: Your new check
247
+ echo -n "Checking something... "
248
+ # Your validation logic here
249
+ if [ condition ]; then
250
+ echo -e "${GREEN}✓ Pass${NC}"
251
+ else
252
+ echo -e "${RED}✗ Fail${NC}"
253
+ fi
254
+ ```
255
+
256
+ ### 扩展支持的图表类型
257
+
258
+ 编辑 `generate-diagram.sh`,在 `--type` 参数处理中添加新类型。
259
+
260
+ ## 版本历史
261
+
262
+ - **v1.0.0** (2026-04-11) - 初始版本
263
+ - SVG 验证脚本
264
+ - 图表生成脚本
265
+ - 批量测试脚本
266
+
267
+ ## 许可证
268
+
269
+ MIT License - 与 fireworks-tech-graph skill 相同
@@ -0,0 +1,181 @@
1
+ #!/bin/bash
2
+ # SVG Diagram Generation - Validates and exports SVG diagrams with PNG export
3
+
4
+ set -euo pipefail
5
+
6
+ # Colors
7
+ RED='\033[0;31m'
8
+ GREEN='\033[0;32m'
9
+ YELLOW='\033[1;33m'
10
+ BLUE='\033[0;34m'
11
+ NC='\033[0m'
12
+
13
+ # Default values
14
+ STYLE="1"
15
+ WIDTH="1920"
16
+ OUTPUT_DIR="."
17
+ VALIDATE=true
18
+
19
+ # Valid diagram types
20
+ VALID_TYPES="architecture|data-flow|flowchart|sequence|comparison|timeline|mind-map|agent|memory|use-case|class|state-machine|er-diagram|network-topology"
21
+
22
+ usage() {
23
+ cat << USAGE
24
+ Usage: $0 [OPTIONS]
25
+
26
+ Options:
27
+ -t, --type TYPE Diagram type ($VALID_TYPES)
28
+ -s, --style STYLE Style number (1-7, default: 1)
29
+ -o, --output PATH Output path (default: current directory)
30
+ -w, --width WIDTH PNG width in pixels (default: 1920)
31
+ --no-validate Skip validation
32
+ -h, --help Show this help
33
+
34
+ Examples:
35
+ $0 -t architecture -s 1 -o ./output/arch.svg
36
+ $0 -t class -s 2 -w 2400
37
+ $0 -t sequence -s 6
38
+ USAGE
39
+ exit 0
40
+ }
41
+
42
+ # Parse arguments
43
+ while [[ $# -gt 0 ]]; do
44
+ case $1 in
45
+ -t|--type)
46
+ TYPE="$2"
47
+ shift 2
48
+ ;;
49
+ -s|--style)
50
+ STYLE="$2"
51
+ shift 2
52
+ ;;
53
+ -o|--output)
54
+ OUTPUT_PATH="$2"
55
+ shift 2
56
+ ;;
57
+ -w|--width)
58
+ WIDTH="$2"
59
+ shift 2
60
+ ;;
61
+ --no-validate)
62
+ VALIDATE=false
63
+ shift
64
+ ;;
65
+ -h|--help)
66
+ usage
67
+ ;;
68
+ *)
69
+ echo -e "${RED}Unknown option: $1${NC}"
70
+ usage
71
+ ;;
72
+ esac
73
+ done
74
+
75
+ # Check required parameters
76
+ if [ -z "${TYPE:-}" ]; then
77
+ echo -e "${RED}Error: Diagram type is required${NC}"
78
+ usage
79
+ fi
80
+
81
+ # Validate type
82
+ VALID_TYPE=false
83
+ for t in architecture data-flow flowchart sequence comparison timeline mind-map agent memory use-case class state-machine er-diagram network-topology; do
84
+ if [ "$TYPE" = "$t" ]; then
85
+ VALID_TYPE=true
86
+ break
87
+ fi
88
+ done
89
+
90
+ if [ "$VALID_TYPE" = false ]; then
91
+ echo -e "${RED}Error: Invalid diagram type '$TYPE'${NC}"
92
+ echo "Valid types: $VALID_TYPES"
93
+ exit 1
94
+ fi
95
+
96
+ # Determine output path
97
+ if [ -z "${OUTPUT_PATH:-}" ]; then
98
+ BASENAME="${TYPE}-style${STYLE}"
99
+ SVG_FILE="${OUTPUT_DIR}/${BASENAME}.svg"
100
+ PNG_FILE="${OUTPUT_DIR}/${BASENAME}.png"
101
+ else
102
+ SVG_FILE="$OUTPUT_PATH"
103
+ PNG_FILE="${OUTPUT_PATH%.svg}.png"
104
+ fi
105
+
106
+ echo -e "${BLUE}Generating ${TYPE} diagram (style ${STYLE})...${NC}"
107
+ echo "Output: $SVG_FILE"
108
+
109
+ # Load style reference
110
+ SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
111
+ STYLE_FILE=$(find "${SKILL_DIR}/references" -maxdepth 1 -type f -name "style-${STYLE}-*.md" | head -n 1)
112
+
113
+ if [ -z "${STYLE_FILE:-}" ] || [ ! -f "$STYLE_FILE" ]; then
114
+ echo -e "${RED}Error: Style file not found: ${STYLE_FILE}${NC}"
115
+ echo "Available styles: 1-7"
116
+ exit 1
117
+ fi
118
+
119
+ # Note: Actual SVG generation is done by Claude Code
120
+ # This script provides validation and export only
121
+
122
+ echo -e "${YELLOW}Note: SVG content generation requires Claude Code${NC}"
123
+ echo -e "${YELLOW}This script provides validation and export only${NC}"
124
+
125
+ # Validate if SVG exists
126
+ if [ -f "$SVG_FILE" ]; then
127
+ if [ "$VALIDATE" = true ]; then
128
+ echo -e "\n${BLUE}Validating SVG...${NC}"
129
+ if "${SKILL_DIR}/scripts/validate-svg.sh" "$SVG_FILE"; then
130
+ echo -e "${GREEN}Validation passed${NC}"
131
+ else
132
+ echo -e "${RED}Validation failed${NC}"
133
+ exit 1
134
+ fi
135
+ fi
136
+
137
+ # Export PNG
138
+ echo -e "\n${BLUE}Exporting PNG (width: ${WIDTH}px)...${NC}"
139
+
140
+ # Compute scale for cairosvg (default scale=2 ≈ 1920px wide for 960 viewBox)
141
+ SCALE=$(python3 -c "print(round(${WIDTH}/960, 2))" 2>/dev/null || echo "2")
142
+
143
+ PNG_OK=false
144
+
145
+ # Method 1 (preferred): cairosvg — best CSS support, good fidelity
146
+ if python3 -c "import cairosvg" 2>/dev/null; then
147
+ echo -e "${BLUE}Using cairosvg (recommended)...${NC}"
148
+ if python3 -c "import cairosvg; cairosvg.svg2png(url='${SVG_FILE}', write_to='${PNG_FILE}', scale=${SCALE})" 2>/dev/null; then
149
+ PNG_OK=true
150
+ else
151
+ echo -e "${YELLOW}cairosvg failed, falling back...${NC}"
152
+ fi
153
+ fi
154
+
155
+ # Method 2 (fallback): rsvg-convert — may drop CSS / foreignObject
156
+ if [ "$PNG_OK" = false ] && command -v rsvg-convert &> /dev/null; then
157
+ echo -e "${BLUE}Using rsvg-convert (fallback)...${NC}"
158
+ echo -e "${YELLOW}Warning: rsvg-convert may drop CSS styles or <foreignObject> — install cairosvg for better fidelity${NC}"
159
+ echo -e "${YELLOW} pip install cairosvg${NC}"
160
+ if rsvg-convert -w "$WIDTH" "$SVG_FILE" -o "$PNG_FILE" 2>/dev/null; then
161
+ PNG_OK=true
162
+ fi
163
+ fi
164
+
165
+ if [ "$PNG_OK" = true ]; then
166
+ PNG_SIZE=$(du -h "$PNG_FILE" | cut -f1)
167
+ echo -e "${GREEN}PNG exported: $PNG_FILE (${PNG_SIZE})${NC}"
168
+ else
169
+ echo -e "${RED}PNG export failed${NC}"
170
+ echo -e "${YELLOW}Install one of:${NC}"
171
+ echo -e " ${YELLOW}pip install cairosvg${NC} (recommended)"
172
+ echo -e " ${YELLOW}brew install librsvg${NC} (macOS) / apt install librsvg2-bin (Debian)"
173
+ echo -e " ${YELLOW}npm install puppeteer${NC} (highest fidelity)"
174
+ exit 1
175
+ fi
176
+ else
177
+ echo -e "${YELLOW}SVG file not found. Generate it first with Claude Code.${NC}"
178
+ exit 1
179
+ fi
180
+
181
+ echo -e "\n${GREEN}Done${NC}"