# Test Report Generator

> Skill: test-report-generator

- Skill: `ganyangyu/test-report-generator` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add ganyangyu/test-report-generator`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ganyangyu/test-report-generator/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: Ganyangyu (https://skillmd.com/u/ganyangyu)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/ganyangyu/test-report-generator

---

# Skill: test-report-generator

# Test Report Generator

Generate a formal hardware electromagnetic test report (检测报告) whose **format matches the示范 file `生成报告示范.docx`**, driven by the data files in the working directory. The report is generic — it handles any measurement data type (RCS, 反射损耗, 复介电常数, 屏蔽效能, …), creating one test subsection per data file.

Generation is **co-creative**: ask the user for every variable, and default anything the user does not answer to the示范 report's own values (see `references/defaults.md`). The **结论 (conclusion)** is NOT copied from the sample — it must be drafted from the actual data and charts.

## How it works

The示范 document is used as a fixed "shell": its 封面, 说明, 目录, 1.试验概况 and 3/4/5 section headings are kept. `scripts/report_generator.py` fills the variable metadata and rebuilds the dynamic parts (2.试验内容和结果 per data file, 5.附件 data tables) and the conclusion.

## Step 1 — Discover data files

Scan the working directory for CSV / TXT / Excel files. Preview each:

```bash
python .opencode/skills/test-report-generator/scripts/data_reader.py "<file_path>"
```

Auto-classify by filename/columns (RCS / 反射损耗 / 复介电常数 / 屏蔽效能 / 通用).

**Ask the user**: "发现以下数据文件，是否都用于本次报告？" (list them, with row/column counts). The user may exclude files.

## Step 2 — Collect metadata (co-create, with defaults)

Ask the user for each item, **showing the示范 default**. The user may answer all at once, or answer "默认" / skip to accept the sample value.

| 项 | 默认值 |
|---|---|
| 报告编号 | SXCL-20260322-1 |
| 客户名称 / 地址 | 浙江大学 / 浙江省杭州市西湖区浙大路38号 |
| 样品名称 / 数量 | 智能电磁隐身斗篷 / 1 套 |
| 收样/开始/结束/签发日期 | 2026.3.21 / 3.21 / 3.22 / 3.23 |
| 编制/审核/批准 | 杨欢 / 陈波波 / 李向洋 |
| 单位地址 / 电话 | 陕西省宝鸡市渭滨区清姜路75号 / 0917-3608033 3624433 |
| 设备清单 | （模板默认） |
| 检测地点 / 温度 / 湿度 / 干扰 | 浙江大学杭州国际科创中心信息港园区9218室 / 23℃±10℃ / <80% / 无 |

If the user changes 客户/样品, also ask whether the narrative text (1.1 任务来源、1.2 被试品 等) should be updated accordingly.

## Step 3 — Confirm data parsing per file (co-create)

For each data file, auto-detect and **confirm with the user**:
- X column (first numeric/frequency column)
- Y columns (remaining numeric columns)
- chart type (line for frequency sweeps, scatter for discrete points)
- statistics (mean/min/max; bandwidth/peak for 反射损耗; similarity for RCS)

Ask: "文件 `X`：X轴=`列`, Y轴=`列1,列2…`，图表=折线，统计=均值/最值。是否正确？"

## Step 4 — Compute statistics & charts

```bash
python .opencode/skills/test-report-generator/scripts/statistics.py "<file>" "<x_col>" "<y_col>" "mean,min,max"
python .opencode/skills/test-report-generator/scripts/chart_generator.py "<file>" "<x_col>" "<y1,y2>" "line" "<title>" "<out.png>"
```

For RCS with comparable groups, also compute similarity and include it in the analysis text.

## Step 5 — Draft analysis + conclusion (co-create)

- For each data file, draft a 2–3 sentence analysis from its stats/chart. Show the user and let them edit.
- Draft the **conclusion** (第4章) from ALL results + charts. **This is not copied from the sample.** Show it to the user for confirmation.

## Step 6 — Assemble JSON and generate

Build `report_data.json` (schema below), then:

```bash
python .opencode/skills/test-report-generator/scripts/report_generator.py "<report_data.json>" "<output.docx>"
```

Save to `<working_dir>/检测报告_<YYYYMMDD>_<HHMMSS>.docx`. Tell the user the path.

### JSON schema

```json
{
  "report_no": "SXCL-20260322-1",
  "client": {"name": "浙江大学", "address": "...", "sample_name": "...", "sample_quantity": "1"},
  "timeline": {"receipt_date": "2026.3.21", "start_date": "2026.3.21", "end_date": "2026.3.22", "issue_date": "2026.3.23"},
  "meta": {"prepared_by": "杨欢", "reviewed_by": "陈波波", "approved_by": "李向洋",
           "organization": "陕西长岭电子科技有限责任公司", "address": "...", "phone": "..."},
  "equipment": "...",                 // optional; default = sample
  "test_location": "...",
  "environment": {"temperature": "...", "humidity": "...", "interference": "..."},
  "test_groups": [
    {"name": "反射损耗测试", "purpose": "...", "procedure": "...",
     "stats": {"headers": [...], "rows": [[...]]},
     "chart_path": "...", "chart_caption": "图1 ...", "analysis": "..."}
  ],
  "issues": "无。",
  "conclusion": ["段落1", "段落2"],
  "appendix": [{"name": "表1 ...", "headers": [...], "rows": [[...]]}]
}
```

Every field is optional; anything omitted keeps the sample default. `test_groups` = one per data file. `conclusion` is a list of paragraphs (drafted, not copied).

## Processing rules

- **Defaults**: always from `references/defaults.md`. Never invent new defaults.
- **Conclusion**: always drafted from data + charts, never copied from the sample.
- **Narrative (1.1–1.9, 3)**: default = sample text; only change when the user asks.
- **Charts**: use `chart_generator.py` (its SimHei font handling avoids missing CJK glyphs).
- **Encoding**: CSVs with UTF-8 BOM are handled by the scripts (chardet → UTF-8-SIG).
- **Determinism**: same JSON + same PNGs → same .docx.
- **Report language**: 中文.

---

Base directory: `C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator`

<skill_files>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\scripts\report_generator.py</file>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\scripts\data_reader.py</file>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\scripts\statistics.py</file>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\scripts\chart_generator.py</file>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\assets\report_template.docx</file>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\references\defaults.md</file>
<file>C:\Users\ganyangyu\Desktop\agent skill\.opencode\skills\test-report-generator\references\report_structure.md</file>
</skill_files>

