name: report-generator
version: 1.0.0

description: "Generates HTML reports from external data using predefined templates. Accepts JSON data and outputs HTML visualization."
---

# Report Generator Skill

## When to Use
Use this skill when:
- You have external data (from other skills) that needs to be visualized
- You need to generate HTML reports from JSON data
- You want to use predefined visualization templates for data presentation
- Other skills (like load-forecasting and pv-prediction-model) require report generation for their outputs

## 调用指南
当其他skill需要生成报告时，必须按照以下步骤调用report-generator：

### 步骤1：模板选择
1. 向用户发送进度信息：`PROGRESS: ⏳ 正在分析数据，选择合适的可视化模板...`
2. 调用 `step1_select.py` 脚本，根据用户查询和数据结构选择合适的可视化模板

### 步骤2：生成报告
1. 向用户发送进度信息：`PROGRESS: ⏳ 正在将数据渲染为图表报告...`
2. 调用 `step2_render.py` 脚本，使用选定的模板渲染HTML报告

### 步骤3：返回结果
1. 分析脚本输出的 `summary` 字段，生成数据分析摘要
2. 使用 `@@@@@` 包裹报告地址，作为倒数第二行
3. 使用 `#####` 包裹优化建议，作为最后一行

## How to Execute

### Step 1: Select Template
**FIRST**, write this exact text to the user (do not use tool yet):
`PROGRESS: ⏳ 正在分析数据，选择合适的可视化模板...`

**THEN**, run this command:
```bash
cd /workspace/skills/report-generator && python3 scripts/step1_select.py --query "{{USER_QUERY}}" --data "{{DATA_JSON}}"
```
*Replace `{{USER_QUERY}}` with the user's query text and `{{DATA_JSON}}` with the JSON data.*

The script will output a JSON like:
```json
{"status": "success", "template_name": "barChart", "reason": "..."}
```

### Step 2: Render HTML Report
**FIRST**, write this exact text to the user:
`PROGRESS: ⏳ 正在将数据渲染为图表报告...`

**THEN**, run this command:
```bash
cd /workspace/skills/report-generator && python3 scripts/step2_render.py --query "{{USER_QUERY}}" --template "{{template_name}}" --data "{{DATA_JSON}}"
```
*Replace variables with the output from Step 1 and the original data.*

The script will output a JSON at the end like:
```json
{"status": "success", "message": "Report generated successfully", "template": "barChart", "address": "/skills/report-generator/output/report_1773642266.html", "summary": "..."}
```

---

### Final Reply Format
Your final reply MUST have exactly three parts:

**Part 1 — Data Analysis Summary（必须，不可省略）**
Write a concise analysis in Chinese based on the `summary` field from the Step 2 script output, or expand on it if needed.
**禁止**只写"报告已生成"之类的话，必须真正分析数据内容。

**Part 2 — Address Tag（倒数第二行，格式固定）**
The second-to-last line of your reply MUST be the `address` field value wrapped in `@@@@@`:
```
@@@@@/skills/report-generator/output/report_1773642266.html@@@@@
```
⚠️ **ADDRESS TAG FORMAT — ABSOLUTE RULES:**
- The path MUST be copied EXACTLY from the `address` field in the script JSON output
- DO NOT fabricate, guess, or approximate the report filename
- Output ONLY the plain file path between the two `@@@@@` markers
- NO spaces between `@@@@@` and the path

**Part 3 — Optimization Suggestions Tag（最后一行，格式固定）**
The very last line of your reply MUST be the optimization suggestions wrapped in `#####`:
```
#####%查看详细数据%￥点击上方链接查看完整的数据分析报告￥ %继续深入分析%￥基于当前数据进行更深度的挖掘￥ %导出报告%￥将当前报告导出为PDF或图片格式￥#####
```

## Bundled Resources
- `templates/*.html`: HTML visualization templates
- `templates/*.md`: Documentation for each HTML template's required JSON structure
- `scripts/step1_select.py`, `step2_render.py`: The execution scripts