---
name: ggs-sales-report
description: >
  Generate standardized Alibaba.com industry insight & business proposal
  presentations (.pptx) for the GGS sales team. Accepts a single JSON file,
  runs build-report.js to produce a branded PowerPoint with charts and tables.
---

# Alibaba.com Industry Report Generator

> **⛔ MANDATORY RULES — Read before doing ANYTHING else:**
>
> 1. **DO NOT write your own pptxgenjs/PPTX generation code.** A complete build script already exists. Your only job is to **assemble the JSON data file** and **run the build script**.
> 2. **DO NOT copy example values from this document or module spec files into your output data.** All example values are placeholders. You must use real data from CRM tools or user-provided sources.
> 3. **DO NOT skip reading the module spec files** in `modules/` — they define the exact JSON schema each module requires.

---

## Execution SOP (Step-by-Step)

**You MUST follow these steps in order. Do NOT deviate.**

### Step 0 — Clarify Required Parameters (MANDATORY)

生成报告前，必须确认以下信息已知。**如果当前对话上下文中无法获取，必须先向用户提问，不得跳过或自行假设。**

| 需用户提供 | 说明 | AI 处理方式 |
|------|------|----------|
| **客户所在国家** | 自然语言即可，如"越南"、"韩国" | 转换为 2 位国家码（`VN`、`KR` 等） |
| **客户主营行业** | 自然语言描述，如"家具"、"服装" | 调用 `ggs-crm industry-mapping` 自动匹配 lv1/lv2 行业 ID |

> ⚠️ **一级行业 ID 和二级行业 ID 由 AI 自动推断，无需用户提供。** 用户只需告知国家和行业描述即可。

**澄清话术（当国家或行业信息缺失时，向用户提问）：**

> 为了生成报告，我需要确认以下信息：
> 1. **客户所在国家**是哪个？（如：越南、韩国、印度）
> 2. **客户主营行业**是什么？（如：家具、服装、电子产品）
>
> 我会根据行业描述自动匹配行业 ID，无需您手动提供 ID。

以上信息确认后，AI 执行：
1. 将国家名转为 2 位国家码
2. 运行 `ggs-crm industry-mapping`，根据行业描述匹配 `cate_lv1_id` 和 `cate_lv2_id`
3. 确认 lv1/lv2 ID 后，进入 Step 1

### Step 1 — Fix Dependencies (run once per environment)

If you see `ERR_DLOPEN_FAILED` or `sharp` errors, run:

```bash
cd <skill-directory>
npm rebuild sharp
# If still failing on macOS, try:
npm remove sharp && npm install sharp
```

Verify with: `node -e "require('sharp'); console.log('sharp OK')"`

### Step 2 — Gather Data & Build JSON

Create a single JSON file (e.g., `report-data.json`) following the schema below. Data sources:

| Module | Data Source |
|--------|-----------|
| SWOT (swot_data) | LLM analysis of client company (web search + user info) |
| Macro Trends (macro_data) | LLM web search for country export statistics |
| Success Stories (success_stories) | **`ggs-crm crm-industry-success-story`** or user-provided |
| Industry Outlook (industry_outlook_data) | **`ggs-crm crm-industry-traffic`** + **`crm-industry-buyer-country`** |
| Trending Products (trending_products_data) | **`ggs-crm crm-industry-product`** |
| Benchmarks (benchmark_data) | **`ggs-crm crm-industry-benchmark`** |
| Action Plan (action_plan) | LLM-generated recommendations |

**For Modules 03, 04, 05, 07: You MUST call the ggs-crm CLI tools to get real data.** See "CRM CLI Reference" section below. Do NOT fabricate these numbers.

### Step 3 — Run the Build Script

```bash
node scripts/build-report.js --input report-data.json --output proposal.pptx
```

That's it. The script handles all HTML template rendering, chart generation, table layout, image processing, and PPTX assembly automatically. **Do NOT modify the script or write your own.**

### Step 4 — Deliver the .pptx File

Return the generated `.pptx` file to the user. Do NOT return HTML, PDF, or markdown.

---

## Input JSON Schema

A single JSON file drives the entire report. **Omit a key to skip that module.**

Reference example: `scripts/sample-data.json` (read this file for the complete structure).

### Top-Level Fields

| Field | Required | Description |
|-------|----------|-------------|
| `title` | Yes | Report title on cover (e.g., "Alibaba.com Business Proposal") |
| `company_name` | Yes | Client company name |
| `main_category` | Yes | Client's primary industry/category |
| `target_country` | No | Client's country (e.g., "Vietnam") |
| `target_industry` | No | Export industry for data lookups (defaults to `main_category`) |
| `sales_name` | Yes | Sales representative name |
| `sales_email` | Yes | Sales representative email |
| `language` | No | Target language code (default: "en") |
| `include_about` | No | Set `false` to skip About Alibaba.com module (default: true) |

### Module Data Keys

| JSON Key | Module | Pages |
|----------|--------|-------|
| `swot_data` | SWOT Analysis | 2 |
| `macro_data` | Macroeconomic Trends | 1 |
| _(include_about)_ | About Alibaba.com | 2 (fixed content) |
| `success_stories` | Seller Success Stories | 1–N |
| `industry_outlook_data` | Local Industry Outlook | 2 |
| `trending_products_data` | Trending Product Insights | 1–4 |
| `benchmark_data` | Industry Leaders & Benchmarks | 1–5 |
| `action_plan` | Your Action Plan | 1 |

### Sub-Schema Quick Reference

**Read the module spec files for complete field definitions.** Each spec is in `modules/`:

- `modules/module-swot.md` — SWOT schema
- `modules/module-01-macro-trends.md` — macro_data schema
- `modules/module-03-success-stories.md` — success_stories schema
- `modules/module-04-industry-outlook.md` — industry_outlook_data schema (traffic_trends + buyer_analysis)
- `modules/module-05-trending-products.md` — trending_products_data schema (4 sub-tables)
- `modules/module-07-benchmarks.md` — benchmark_data schema (peers array)

**`swot_data`**: `{ company_name, company_logo, industry, country, brief, strengths[], weaknesses[], opportunities[], threats[] }`

**`macro_data`**: `{ country, industry, currency, unit, export_data[{year,value}], cagr, ai_summary, data_sources[] }`

**`success_stories[]`**: `[{ image, category, description, company, country }]`

**`industry_outlook_data`**:
```json
{
  "country": "...", "industry": "...",
  "traffic_trends": {
    "data_range": "2025-04 ~ 2026-03",
    "months": ["2025-04", ...],
    "country_ipv": [8400, ...],
    "ggs_ipv": [720000, ...],
    "country_ipv_unit": "",
    "ggs_ipv_unit": "",
    "ai_summary": "..."
  },
  "buyer_analysis": {
    "data_range": "...",
    "buyers": [{ "country": "...", "share": 28.5, "yoy": 18.7 }],
    "ai_summary": "..."
  }
}
```

**`trending_products_data`**: Contains `hot_categories`, `hot_keywords`, `high_demand`, `high_growth`. Each has `items[]` with fields specific to its type (see module-05 spec), plus `data_source`, `data_note`, `ai_summary`.

**`benchmark_data`**: `{ peers: [{ company_name, profile_similarity[], core_strategy[], storefront_highlights[], roi_takeaways, cooperation_plan:{...} }] }`

**`action_plan`**: `{ subtitle, steps: [{ title, description }] }`

---

## CRM CLI Reference

**These tools provide real Alibaba.com platform data. You MUST use them for Modules 04, 05, and 07.**

### ID Resolution

Before calling any CRM tool, resolve the user's industry name to numeric IDs using:

```bash
ggs-crm industry-mapping
# 可配合 grep 过滤，例如查找食品饮料相关行业：
ggs-crm industry-mapping | grep -E "Food|Beverage|食品|饮料"
```

Match the user's natural-language industry input against the returned `*_desc` columns to find the best-fit IDs (`cate_lv1_id`, `cate_lv2_id`, `cate_lv3_id`).

### Commands

All commands share: `--industry-id, -i` (lv1), `--country, -c` (country code). Some commands also accept `--industry-lv2-id` (lv2).

```bash
# Module 03 — Success stories
ggs-crm crm-industry-success-story -t <token> -i <lv1_id> -c <CC>

# Module 04 Page 1 — Traffic trends
ggs-crm crm-industry-traffic -i <lv1_id> --industry-lv2-id <lv2_id> -c <CC>

# Module 04 Page 2 — Buyer country analysis
ggs-crm crm-industry-buyer-country -i <lv1_id> --industry-lv2-id <lv2_id> -c <CC>

# Module 05 — Trending products
ggs-crm crm-industry-product -i <lv1_id> --industry-lv2-id <lv2_id> -c <CC>

# Module 07 — Industry benchmarks
ggs-crm crm-industry-benchmark -i <lv1_id> --industry-lv2-id <lv2_id> -c <CC>
```

> ⚠️ **注意：** `crm-industry-success-story` 需要 `-t <token>` 参数（需先完成认证），且只需一级行业 ID（`-i`），不需要二级行业 ID。

### IPV Unit Handling

CRM traffic data may return unit indicators in the response:
- `country_ipv_unit: ''` → absolute numbers
- `ggs_ipv_unit: 'K'` → values are in thousands (build script auto-multiplies ×1000)
- `ggs_ipv_unit: 'M'` → values are in millions (build script auto-multiplies ×1000000)

**Pass these unit fields through to the JSON as-is.** The build script handles normalization.

---

## Data Processing Rules

### Currency Conversion

Upstream monetary values are in **RMB**. Report displays **USD**. Fixed rate: 1 USD = 7.2 RMB.

If `benchmark_data.peers[].cooperation_plan_currency` is `"RMB"`, build script auto-converts. Otherwise values are assumed USD.

### Data Desensitization (Module 07)

Company names are auto-masked. USD amounts are auto-approximated (e.g., 38889 → "~39K"). The build script handles this — just pass raw values.

---

## Presentation Structure

```
 Slide                              | Data Key
-------------------------------------|---------
 Cover Page                          | (top-level fields)
 SWOT Analysis (2 pages)             | swot_data
 Table of Contents                   | (auto-generated)
 01 Macroeconomic Trends             | macro_data
 02 About Alibaba.com (2 pages)      | include_about
 03 Seller Success Stories (1–N)     | success_stories
 04 Local Industry Outlook (2 pages) | industry_outlook_data
 05 Trending Product Insights (1–4)  | trending_products_data
 06 Market Performance (placeholder) | —
 07 Industry Leaders (1–5 pages)     | benchmark_data
 08 Your Action Plan                 | action_plan
 End Page (Thank You)                | (top-level fields)
```

SWOT appears before TOC, is NOT numbered in TOC. All other modules get sequential numbering. If a module's sub-data is missing, a 404 error page is generated automatically.

---

## Multi-Language Support

The build script (`build-report.js`) has a **built-in translation system** that handles all UI text automatically. You only need to set the `language` field in the top-level JSON.

### How It Works

1. **Language detection**: The script reads `data.language` (e.g., `"zh"`, `"es"`, `"fr"`) and selects the matching translation column from an internal `UI_TEXTS` dictionary.
2. **Automatic UI translation**: All framework text — module titles, section dividers, TOC heading, SWOT labels, cover labels, table headers, About Alibaba.com content, timeline milestones, Thank You page, error pages — is automatically translated. **You do NOT need to translate these yourself.**
3. **Fallback**: If a language is not in the dictionary, the script falls back to English (`"en"`).

### What You MUST Translate in the JSON

Even though the build script translates UI framework text, the **data content** in the JSON must also be in the target language. When `language` is not `"en"`, translate ALL of the following before writing to the JSON:

- `title` (report title)
- `swot_data.brief`, `swot_data.strengths[]`, `swot_data.weaknesses[]`, `swot_data.opportunities[]`, `swot_data.threats[]`
- `macro_data.ai_summary`
- `success_stories[].description`, `success_stories[].category`
- `industry_outlook_data.traffic_trends.ai_summary`, `industry_outlook_data.buyer_analysis.ai_summary`
- `trending_products_data.*.ai_summary`
- `benchmark_data.peers[].profile_similarity[]`, `core_strategy[]`, `storefront_highlights[]`, `roi_takeaways`
- `action_plan.subtitle`, `action_plan.steps[].title`, `action_plan.steps[].description`

### Language Consistency Rule

**ALL content must be in a single, consistent language.** No mixing.

- If the user specifies a language (e.g., "用中文生成"), set `"language": "zh"` and write all JSON data content in Chinese.
- If the user doesn't specify a language, detect the user's conversation language and use that for both `language` field and all data content.
- The build script will handle UI framework text in the matching language automatically.

### Supported Language Codes

| Code | Language |
|------|----------|
| `en` | English (default) |
| `zh` | 中文 (Chinese Simplified) |
| `es` | Español (Spanish) |
| `fr` | Français (French) |
| `pt` | Português (Portuguese) |
| `ja` | 日本語 (Japanese) |
| `ko` | 한국어 (Korean) |
| `ar` | العربية (Arabic) |
| `ru` | Русский (Russian) |
| `vi` | Tiếng Việt (Vietnamese) |
| `th` | ไทย (Thai) |
| `id` | Bahasa Indonesia |
| `tr` | Türkçe (Turkish) |

### Brand Names — Do NOT Translate

These brand names must remain in English regardless of target language:
**Alibaba.com**, **Trade Assurance**, **Smart Assistant**, **Alibaba Guaranteed**

---

## Build Architecture

```
alibaba-report/
├── SKILL.md                    # This file
├── assets/                     # Logos, backgrounds
├── slide-templates/            # HTML layout templates
├── modules/                    # Per-module schema specs (READ THESE)
├── references/                 # ggs_industry_mapping.csv
├── scripts/
│   ├── build-report.js         # ★ Production build (JSON → PPTX)
│   ├── test-build.js           # Dev build with mock data
│   └── sample-data.json        # Complete example JSON
└── node_modules/               # pptxgenjs, sharp, playwright
```

The build pipeline: JSON → HTML templates (variable substitution) → Playwright screenshot → PptxGenJS (charts/tables overlay) → .pptx output. **Everything is automated in `build-report.js`. You only need to provide the JSON.**
