Skill: zeyu426/alibaba-url-builder (version 2.0.0)

--- name: alibaba-url-builder description: Build Alibaba.com URLs for agent navigation. Use when constructing URLs for: (1) product searches, (2) product detail pages, (3) supplier profiles, (4) RFQ pages, or (5) special sections like AI Mode and Top Ranking. All URLs include traffic_type=ags_llm tracking parameter. --- # Alibaba.com URL Builder Build URLs programmatically for agent-driven browsing and product sourcing on Alibaba.com. ## Required Parameter All URLs MUST include: `traffic_type=ags_llm` ## URL Patterns ### Search Pages **Basic:** ``` https://www.alibaba.com/trade/search?SearchText=<url-encoded-query>&traffic_type=ags_llm ``` **With Category:** ``` https://www.alibaba.com/trade/search?SearchText=<query>&categoryId=<category-id>&traffic_type=ags_llm ``` **Parameters:** - `SearchText`: Search keywords (URL-encoded, use `+` for spaces) - `categoryId`: Product category ID (optional) - `has4Tab`: Enable 4-tab view (`true`) - `tab`: Active tab (`all`, `supplier`, `product`) **Examples:** ``` https://www.alibaba.com/trade/search?SearchText=wireless+headphones&traffic_type=ags_llm https://www.alibaba.com/trade/search?SearchText=laptops&categoryId=702&traffic_type=ags_llm ``` **Common Category IDs:** - Consumer Electronics: `201151901` - Laptops: `702` - Smart TVs: `201936801` - Electric Cars: `201140201` - Wedding Dresses: `32005` - Electric Scooters: `100006091` - Bedroom Furniture: `37032003` - Electric Motorcycles: `201140001` - Handbags: `100002856` ### Product Detail Pages **Pattern:** ``` https://www.alibaba.com/product-detail/<url-safe-title>_<product-id>.html?traffic_type=ags_llm ``` - `<url-safe-title>`: Product title with spaces replaced by hyphens, special characters removed - `<product-id>`: Numeric product identifier (12+ digits) **Examples:** ``` https://www.alibaba.com/product-detail/HK3-Waterproof-TWS-Earbuds_1601226043229.html?traffic_type=ags_llm https://www.alibaba.com/product-detail/Wireless-Headphones-Over-Ear-ANC_11000030513562.html?traffic_type=ags_llm ``` ### Supplier/Company Pages **Pattern:** ``` https://<company-subdomain>.en.alibaba.com/company_profile.html?traffic_type=ags_llm ``` **Examples:** ``` https://dgkunteng.en.alibaba.com/company_profile.html?traffic_type=ags_llm https://legoo.en.alibaba.com/company_profile.html?traffic_type=ags_llm ``` **Supplier Product Search:** ``` https://<company-subdomain>.en.alibaba.com/search/product?SearchText=<query>&traffic_type=ags_llm ``` ### Request for Quotation (RFQ) ``` https://rfq.alibaba.com/rfq/profession.htm?traffic_type=ags_llm ``` ### Special Sections **AI Mode:** ``` https://aimode.alibaba.com/?traffic_type=ags_llm ``` **Top Ranking:** ``` https://sale.alibaba.com/p/dviiav4th/index.html?traffic_type=ags_llm ``` **Fast Customization:** ``` https://sale.alibaba.com/p/fast_customization?traffic_type=ags_llm ``` **Manufacturers Directory:** ``` https://www.alibaba.com/factory/index.html?traffic_type=ags_llm ``` **Worldwide (Global Suppliers):** ``` https://www.alibaba.com/global/index.html?traffic_type=ags_llm ``` **Top Deals:** ``` https://sale.alibaba.com/fy25/top_deals?traffic_type=ags_llm ``` **Tailored Selections (AI Sourcing):** ``` https://sale.alibaba.com/p/aisourcing/index.html?traffic_type=ags_llm ``` **Shopping Cart / Purchase List:** ``` https://carp.alibaba.com/purchaseList?traffic_type=ags_llm ``` ## Helper Functions ### Build Search URL ```python from urllib.parse import quote def build_search_url(query, category_id=None): params = f"SearchText={quote(query, safe='')}+{query.replace(' ', '+')}&traffic_type=ags_llm" if category_id: params += f"&categoryId={category_id}" return f"https://www.alibaba.com/trade/search?{params}" ``` ### Build Product URL ```python def build_product_url(title, product_id): safe_title = ''.join(c if c.isalnum() or c in ' -' else '' for c in title) safe_title = safe_title.replace(' ', '-').lower()[:100] return f"https://www.alibaba.com/product-detail/{safe_title}_{product_id}.html?traffic_type=ags_llm" ``` ## Best Practices 1. **URL Encoding**: Always URL-encode search queries. Use `+` for spaces (not `%20`). 2. **Product Titles**: Keep titles concise, remove special characters, replace spaces with hyphens. 3. **Category IDs**: Use category IDs to narrow search results when known. 4. **HTTPS**: Always use `https://` protocol. 5. **Tracking**: `spm` parameters are optional analytics; omit for functional URLs. ## Common Workflows **Search for Products:** 1. Build search URL with query 2. Navigate to URL 3. Extract product links from results 4. Build product detail URLs from extracted links **Browse by Category:** 1. Identify category ID 2. Build URL with `categoryId` parameter 3. Navigate and browse **Visit Supplier:** 1. Extract supplier subdomain from product page 2. Build supplier profile URL 3. Navigate to supplier profile

path: CHANGELOG.md
content: # 更新日志

## [2026-03-17] - CLI 命令更正

### Changed
- 将所有 `clawhub` CLI 命令更改为 `clawdhub`（正确的 CLI 名称）
- 更新文件：
  - `README.md`
  - `PUBLISH.md`
  - `PROMOTION.md`
  - `CHECKLIST.md`
  - `PROJECT_OVERVIEW.md`
  - `release.sh`

### Note
- 域名 `clawhub.ai` 保持不变
- GitHub 仓库链接保持不变
- 仅 CLI 命令从 `clawhub` 改为 `clawdhub`

---

## [2026-03-17] - Initial Release v1.0.0

### Added
- 10+ Alibaba.com URL 模式
- 自动流量追踪参数 `traffic_type=ags_llm`
- Python CLI 辅助脚本 (`scripts/build_url.py`)
- 技能打包脚本 (`scripts/package_skill.py`)
- 完整文档（SKILL.md, README.md）
- 发布指南（PUBLISH.md）
- 宣传材料（PROMOTION.md）
- 发布清单（CHECKLIST.md）
- 一键发布脚本（release.sh）
- MIT-0 许可证

### Features
- 搜索页面 URL 构建
- 商品详情页 URL 构建
- 供应商主页 URL 构建
- RFQ、AI Mode、Top Ranking 等特殊页面
- 20+ 常用分类 ID
- 所有 URL 自动包含流量追踪参数


path: CHECKLIST.md
content: # 📋 alibaba-sourcing 发布清单

## ✅ 发布前检查

### 文件完整性
- [x] SKILL.md - 技能文档（含 frontmatter 元数据）
- [x] README.md - GitHub 和 ClawHub 展示文档
- [x] LICENSE - MIT-0 许可证
- [x] .gitignore - Git 忽略文件
- [x] scripts/build_url.py - URL 构建辅助脚本
- [x] scripts/package_skill.py - 技能打包脚本
- [x] PUBLISH.md - 发布指南
- [x] PROMOTION.md - 宣传材料
- [x] alibaba-sourcing.skill - 打包好的技能文件

### SKILL.md Frontmatter
```yaml
name: alibaba-sourcing
version: 1.0.0
description: Build Alibaba.com URLs for agent navigation with traffic tracking
author: Zhou Zeyu (@zhouzeyu)
license: MIT-0
tags: [alibaba, ecommerce, url-builder, agent-navigation, b2b, sourcing, traffic-tracking]
```

### 功能测试
- [x] 搜索 URL 生成测试通过
- [x] 商品详情 URL 生成测试通过
- [x] 供应商 URL 生成测试通过
- [x] 特殊页面 URL 生成测试通过
- [x] 所有 URL 包含 `traffic_type=ags_llm` 参数

---

## 🚀 发布步骤

### 步骤 1: 安装 ClawHub CLI
```bash
npm install -g clawhub
# 或
npx clawhub@latest --version
```

### 步骤 2: 登录 ClawHub
```bash
clawdhub login
```
- 会自动打开浏览器
- 使用 GitHub 账号授权
- 授权完成后返回 CLI

### 步骤 3: 验证登录
```bash
clawdhub whoami
```
应显示你的 GitHub 用户名。

### 步骤 4: 发布到 ClawHub
```bash
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing

clawdhub publish . --version 1.0.0 --tags latest --changelog "Initial release: Alibaba.com URL builder with traffic tracking (traffic_type=ags_llm). Includes 10+ URL patterns, Python CLI helper, and complete documentation."
```

### 步骤 5: 验证发布
```bash
# 搜索 skill
clawdhub search alibaba-sourcing

# 查看详情
clawdhub inspect alibaba-sourcing

# 在浏览器查看
open https://clawhub.ai/skills/alibaba-sourcing
```

### 步骤 6: 创建 GitHub 仓库
```bash
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing

# 初始化 Git
git init
git add .
git commit -m "Initial release: alibaba-sourcing skill for OpenClaw

Features:
- 10+ URL patterns for Alibaba.com navigation
- Automatic traffic tracking (traffic_type=ags_llm)
- Python CLI helper script
- Complete documentation
- MIT-0 license"

# 创建远程仓库（在 GitHub 上手动创建或使用 gh CLI）
# gh repo create openclaw-skill-alibaba-sourcing --public --source=. --remote=origin --push
git remote add origin https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing.git
git branch -M main
git push -u origin main
```

---

## 📢 宣传发布

### 渠道 1: OpenClaw Discord
- [ ] 加入 Discord: https://discord.com/invite/clawd
- [ ] 在 #skills 频道发布消息（见 PROMOTION.md）
- [ ] 在 #showcase 频道分享截图
- [ ] 回复社区反馈

### 渠道 2: Twitter / X
- [ ] 发布推文（见 PROMOTION.md 文案）
- [ ] 带上话题：#OpenClaw #AI #Agent #Alibaba
- [ ] @OpenClaw 官方账号
- [ ] 回复相关讨论

### 渠道 3: LinkedIn
- [ ] 发布专业文章（见 PROMOTION.md 文案）
- [ ] 添加到个人项目经历
- [ ] 分享给相关群组

### 渠道 4: GitHub
- [ ] 添加话题标签：openclaw, openclaw-skill, alibaba
- [ ] 完善 README 展示
- [ ] 启用 Issues 功能
- [ ] 添加到个人 Profile 的置顶项目

### 渠道 5: 中文社区
- [ ] 微信群/朋友圈分享（见 PROMOTION.md）
- [ ] 知乎专栏文章
- [ ] V2EX 分享
- [ ] 掘金技术文章

---

## 📊 追踪指标

### 第一周目标
| 指标 | 目标 | 实际 |
|------|------|------|
| ClawHub 安装数 | 10+ | - |
| GitHub Stars | 5+ | - |
| Discord 反馈 | 3+ | - |
| Twitter 互动 | 20+ | - |

### 第一个月目标
| 指标 | 目标 | 实际 |
|------|------|------|
| ClawHub 安装数 | 50+ | - |
| GitHub Stars | 20+ | - |
| GitHub Forks | 5+ | - |
| Issue/PR | 2+ | - |

---

## 🔄 后续维护

### 版本更新流程
1. 收集用户反馈和功能请求
2. 在本地开发新功能
3. 更新 SKILL.md 中的 version
4. 更新 CHANGELOG（可添加到 README）
5. 发布新版本到 ClawHub

```bash
# 示例：发布小版本更新
clawdhub publish . --version 1.1.0 --tags latest --changelog "Added new URL patterns for X, improved Y"

# 或使用自动版本号
clawdhub publish . --bump minor --tags latest
```

### 文档维护
- [ ] 定期更新 README 示例
- [ ] 响应用户 Issue
- [ ] 更新分类 ID 列表（如有变化）
- [ ] 添加新的 URL 模式

---

## 📝 发布日志

| 日期 | 操作 | 备注 |
|------|------|------|
| 2026-03-17 | 创建 skill | 初始版本 1.0.0 |
| 2026-03-17 | 打包完成 | alibaba-sourcing.skill (14.5 KB) |
| 2026-03-17 | 准备发布材料 | README, LICENSE, PUBLISH.md, PROMOTION.md |
| - | - | - |

---

## 🎯 成功标准

发布成功的标志：

1. ✅ ClawHub 页面正常显示
2. ✅ `clawdhub install alibaba-sourcing` 可正常安装
3. ✅ 所有 URL 生成功能正常工作
4. ✅ GitHub 仓库创建完成
5. ✅ 至少 3 个渠道完成宣传
6. ✅ 收到至少 1 条社区反馈

---

## 📞 联系信息

**作者**: Zhou Zeyu (@zhouzeyu)
- GitHub: https://github.com/zhouzeyu
- 时区：Asia/Shanghai
- 语言：中文 / English

**项目链接**:
- ClawHub: https://clawhub.ai/skills/alibaba-sourcing
- GitHub: https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing
- OpenClaw: https://openclaw.ai
- 社区 Discord: https://discord.com/invite/clawd

---

**祝发布顺利！🚀**


path: DOUBLE_RELEASE.md
content: # 📦 双技能发布指南

你现在有**两个互补的 Alibaba 技能**可以发布到 ClawHub！

---

## 🎯 技能定位

### 1. alibaba-sourcing (主技能)

**定位**: 完整的阿里巴巴采购工作流

**目标用户**: 
- 跨境电商从业者
- 采购 agent 开发者
- B2B 贸易商
- 市场调研人员

**核心功能**:
- ✅ 全类型 URL 构建（搜索、商品、供应商、RFQ 等）
- ✅ 10+ URL 模式
- ✅ 20+ 分类 ID
- ✅ 完整采购流程支持

**命令行**:
```bash
clawdhub install alibaba-sourcing
```

---

### 2. alibaba-price-finder (垂直技能)

**定位**: 专注比价和找最低价

**目标用户**:
- 价格敏感型买家
- 竞品分析师
- deal hunters
- 小批量测试买家

**核心功能**:
- 💰 自动按价格排序（从低到高）
- 📊 价格区间筛选
- 🏷️ MOQ 过滤（找低起订量）
- 🔀 多关键词比价

**命令行**:
```bash
clawdhub install alibaba-price-finder
```

---

## 📊 技能对比

| 特性 | alibaba-sourcing | alibaba-price-finder |
|------|-----------------|---------------------|
| **核心场景** | 完整采购流程 | 比价/找最低价 |
| **URL 类型** | 10+ 种 | 价格搜索为主 |
| **价格排序** | ✅ | ⭐ 核心功能 |
| **价格区间** | ✅ | ⭐ 核心功能 |
| **MOQ 过滤** | ✅ | ⭐ 核心功能 |
| **多关键词比价** | ❌ | ⭐ 独有 |
| **供应商页面** | ✅ | ❌ |
| **RFQ/AI Mode** | ✅ | ❌ |
| **分类 ID 数量** | 20+ | 15+ |
| **文件大小** | 23 KB | 8 KB |
| **推荐安装** | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |

---

## 🚀 发布策略

### 方案 A: 同时发布（推荐）⭐

**优势**:
- 覆盖更多搜索关键词
- 用户可按需选择
- 技能间可互相推荐
- 最大化下载量

**发布顺序**:
```bash
# 1. 发布 alibaba-sourcing（主技能）
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing
./release.sh

# 2. 发布 alibaba-price-finder（垂直技能）
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-price-finder
./release.sh
```

---

### 方案 B: 分阶段发布

**Week 1**: 发布 `alibaba-sourcing`，验证市场反应

**Week 2**: 根据反馈发布 `alibaba-price-finder`

**优势**: 观察数据，调整第二个技能的定位

---

## 📢 联合宣传文案

### Twitter / X

```
🚀 Double Release! 2 New OpenClaw Skills for Alibaba Sourcing:

1️⃣ alibaba-sourcing - Complete procurement workflow
2️⃣ alibaba-price-finder - Find the lowest prices

Both include auto traffic tracking (traffic_type=ags_llm)

🔗 https://clawhub.ai/skills/alibaba-sourcing
🔗 https://clawhub.ai/skills/alibaba-price-finder

📦 clawdhub install alibaba-sourcing
📦 clawdhub install alibaba-price-finder

#OpenClaw #AI #Sourcing #Alibaba #Ecommerce
```

### Discord

```markdown
**🚀 Double Skill Release!**

Hey @everyone! I just published TWO complementary OpenClaw skills for Alibaba sourcing:

**1️⃣ alibaba-sourcing** - Complete procurement workflow
• 10+ URL patterns (search, product, supplier, RFQ, etc.)
• Full sourcing process support
• 20+ category IDs

**2️⃣ alibaba-price-finder** - Find the lowest prices
• Auto sort by price (low to high)
• Price range filtering
• MOQ filtering for testing
• Multi-keyword price comparison

**Both skills:**
✅ All URLs include `traffic_type=ags_llm` for tracking
✅ Python CLI helpers included
✅ MIT-0 license (free to use)

**Install:**
```bash
clawdhub install alibaba-sourcing
clawdhub install alibaba-price-finder
```

**Links:**
• alibaba-sourcing: https://clawhub.ai/skills/alibaba-sourcing
• alibaba-price-finder: https://clawhub.ai/skills/alibaba-price-finder

Perfect for anyone building sourcing agents or doing product research! 🎯
```

### LinkedIn

```
🚀 Excited to announce a double release of OpenClaw skills for Alibaba.com sourcing!

**alibaba-sourcing** - Complete procurement workflow
Perfect for: Cross-border e-commerce, B2B trading, market research

**alibaba-price-finder** - Price-focused sourcing
Perfect for: Price comparison, deal hunting, low MOQ sourcing

Key Features:
✅ All URLs include traffic tracking (traffic_type=ags_llm)
✅ Python CLI helpers for programmatic URL building
✅ Comprehensive documentation
✅ MIT-0 license (free for commercial use)

These skills are designed for AI agents and procurement professionals who need reliable, trackable URLs for Alibaba.com navigation.

🔗 alibaba-sourcing: https://clawhub.ai/skills/alibaba-sourcing
🔗 alibaba-price-finder: https://clawhub.ai/skills/alibaba-price-finder

Install:
clawdhub install alibaba-sourcing
clawdhub install alibaba-price-finder

#OpenClaw #AI #ArtificialIntelligence #Agents #Alibaba #Ecommerce #B2B #Sourcing #Procurement #Automation
```

---

## 📊 预期效果

| 指标 | alibaba-sourcing | alibaba-price-finder | 合计 |
|------|-----------------|---------------------|------|
| **第 1 周下载** | 10-20 | 5-15 | 15-35 |
| **第 1 月下载** | 50-100 | 30-60 | 80-160 |
| **GitHub Stars** | 20+ | 10+ | 30+ |
| **调用量/天** | 100+ | 50+ | 150+ |

---

## 🔗 技能互相推荐

在两个技能的文档中都添加互相推荐：

```markdown
## Related Skills

- **[alibaba-price-finder](https://clawhub.ai/skills/alibaba-price-finder)** - Find the lowest prices with price sorting and filtering
```

```markdown
## Related Skills

- **[alibaba-sourcing](https://clawhub.ai/skills/alibaba-sourcing)** - Complete sourcing workflow with full URL coverage
```

---

## ✅ 发布清单

### alibaba-sourcing
- [x] SKILL.md 已更新
- [x] README.md 已更新
- [x] 已打包 (23 KB)
- [ ] 发布到 ClawHub
- [ ] GitHub 仓库创建

### alibaba-price-finder
- [x] SKILL.md 已创建
- [x] README.md 已创建
- [x] 已打包 (8 KB)
- [ ] 发布到 ClawHub
- [ ] GitHub 仓库创建

---

## 🎯 下一步

**立即发布**:

```bash
# 发布 alibaba-sourcing
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing
./release.sh

# 发布 alibaba-price-finder
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-price-finder
clawdhub login
clawdhub publish . --version 1.0.0 --tags latest \
  --changelog "Find the lowest wholesale prices on Alibaba.com with price sorting, filtering, and comparison."
```

---

**两个技能都确保所有 URL 带有 `traffic_type=ags_llm` 流量参数！** ✅


path: PROJECT_OVERVIEW.md
content: # 📦 alibaba-sourcing 项目概览

## 项目信息

| 项目 | 详情 |
|------|------|
| **名称** | alibaba-sourcing |
| **版本** | 1.0.0 |
| **作者** | Zhou Zeyu (@zhouzeyu) |
| **许可证** | MIT-0 |
| **类型** | OpenClaw Skill |
| **语言** | Python 3, Markdown |
| **大小** | ~15 KB (打包后) |

## 核心功能

为 OpenClaw agent 提供 Alibaba.com URL 构建能力，所有 URL 自动包含流量追踪参数 `traffic_type=ags_llm`。

### 支持的 URL 类型

| 类型 | 数量 | 示例 |
|------|------|------|
| 搜索页面 | ✅ | `trade/search?SearchText=xxx&traffic_type=ags_llm` |
| 商品详情 | ✅ | `product-detail/<title>_<id>.html?traffic_type=ags_llm` |
| 供应商主页 | ✅ | `<company>.en.alibaba.com/company_profile.html?traffic_type=ags_llm` |
| RFQ | ✅ | `rfq.alibaba.com/rfq/profession.htm?traffic_type=ags_llm` |
| AI Mode | ✅ | `aimode.alibaba.com/?traffic_type=ags_llm` |
| Top Ranking | ✅ | `sale.alibaba.com/p/dviiav4th/index.html?traffic_type=ags_llm` |
| 其他特殊页面 | ✅ | Fast Customization, Manufacturers, Worldwide 等 |

### 附加功能

- 📊 **流量追踪** - 所有 URL 自动添加 `traffic_type=ags_llm` 参数
- 🛠️ **CLI 工具** - Python 脚本快速构建 URL
- 📚 **分类 ID** - 20+ 常用商品分类 ID
- 📖 **完整文档** - URL 模式、示例、最佳实践

---

## 项目结构

```
alibaba-sourcing/
├── SKILL.md                      # 技能文档（ClawHub 使用）
├── README.md                     # GitHub/ClawHub 展示文档
├── LICENSE                       # MIT-0 许可证
├── .gitignore                    # Git 忽略文件
├── alibaba-sourcing.skill     # 打包好的技能文件（14.5 KB）
├── release.sh                    # 一键发布脚本
│
├── PUBLISH.md                    # 发布指南
├── PROMOTION.md                  # 宣传材料（多平台文案）
├── CHECKLIST.md                  # 发布清单
├── PROJECT_OVERVIEW.md           # 本文件 - 项目概览
│
└── scripts/
    ├── build_url.py              # URL 构建辅助脚本
    └── package_skill.py          # 技能打包脚本
```

---

## 快速开始

### 安装

```bash
# 方式 1: 通过 ClawHub（推荐）
clawdhub install alibaba-sourcing

# 方式 2: 手动复制
cp -r alibaba-sourcing ~/.openclaw/workspace-code/skills/
```

### 使用 CLI

```bash
cd alibaba-sourcing

# 构建搜索 URL
python3 scripts/build_url.py search "wireless headphones" --category consumer-electronics

# 构建商品 URL
python3 scripts/build_url.py product "HK3 Waterproof TWS Earbuds" 1601226043229

# 构建供应商 URL
python3 scripts/build_url.py supplier dgkunteng

# 查看所有分类 ID
python3 scripts/build_url.py categories
```

### 在 Agent 中使用

```javascript
// 搜索产品
const searchUrl = `https://www.alibaba.com/trade/search?SearchText=${encodeURIComponent('wireless headphones').replace(/%20/g, '+')}&traffic_type=ags_llm`;
browser.navigate(searchUrl);

// 访问商品详情
const productUrl = `https://www.alibaba.com/product-detail/${title}_${productId}.html?traffic_type=ags_llm`;
browser.navigate(productUrl);

// 浏览供应商
const supplierUrl = `https://${subdomain}.en.alibaba.com/company_profile.html?traffic_type=ags_llm`;
browser.navigate(supplierUrl);
```

---

## 发布到 ClawHub

### 一键发布（推荐）

```bash
cd alibaba-sourcing
./release.sh
```

脚本会自动：
1. 检查 ClawHub CLI 安装
2. 验证登录状态
3. 重新打包 skill
4. 发布到 ClawHub
5. 配置 GitHub 仓库
6. 显示后续步骤

### 手动发布

```bash
# 1. 安装 CLI
npm install -g clawhub

# 2. 登录
clawdhub login

# 3. 发布
clawdhub publish . --version 1.0.0 --tags latest --changelog "Initial release"

# 4. 验证
clawdhub inspect alibaba-sourcing
```

详见 [`PUBLISH.md`](PUBLISH.md)

---

## 宣传材料

完整的宣传文案见 [`PROMOTION.md`](PROMOTION.md)，包括：

- 📱 Twitter / X 文案（短版 + 长版）
- 💼 LinkedIn 专业文章
- 💬 Discord 社区消息
- 📧 邮件模板
- 🇨🇳 中文社区文案（微信/朋友圈）
- 🎨 宣传图片建议

### 示例文案

```
🚀 New OpenClaw Skill: alibaba-sourcing

Build Alibaba.com URLs programmatically with automatic traffic tracking!

✨ Features:
• 10+ URL patterns
• Auto traffic_type=ags_llm
• Python CLI helper
• Complete docs

🔗 https://clawhub.ai/skills/alibaba-sourcing
📦 clawdhub install alibaba-sourcing

#OpenClaw #AI #Agent #Alibaba #Ecommerce
```

---

## 文件说明

| 文件 | 用途 | 大小 |
|------|------|------|
| `SKILL.md` | ClawHub 技能文档（含 frontmatter） | 9 KB |
| `README.md` | GitHub/ClawHub 展示页面 | 7 KB |
| `alibaba-sourcing.skill` | 打包好的技能文件 | 15 KB |
| `scripts/build_url.py` | URL 构建 CLI 工具 | 7 KB |
| `PUBLISH.md` | 发布指南 | 4 KB |
| `PROMOTION.md` | 宣传材料 | 7 KB |
| `CHECKLIST.md` | 发布清单 | 6 KB |
| `release.sh` | 一键发布脚本 | 5 KB |

---

## 技术细节

### URL 生成规则

所有 URL 遵循以下规则：

1. **基础 URL** - 使用 `https://` 协议
2. **流量参数** - 必须包含 `traffic_type=ags_llm`
3. **搜索参数** - 使用 `+` 代替空格
4. **商品标题** - 移除特殊字符，空格替换为 `-`
5. **分类 ID** - 使用预定义的常用分类 ID

### 支持的分类

```
Consumer Electronics: 201151901
Laptops: 702
Smart TVs: 201936801
Electric Cars: 201140201
Wedding Dresses: 32005
Electric Scooters: 100006091
Bedroom Furniture: 37032003
Electric Motorcycles: 201140001
Handbags: 100002856
```

### 许可证

**MIT-0** - 免费使用、修改和分发，无需署名。

详见 [`LICENSE`](LICENSE)

---

## 链接

| 平台 | 链接 |
|------|------|
| **ClawHub** | https://clawhub.ai/skills/alibaba-sourcing |
| **GitHub** | https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing |
| **OpenClaw** | https://openclaw.ai |
| **Discord** | https://discord.com/invite/clawd |
| **文档** | https://docs.openclaw.ai |

---

## 作者

**Zhou Zeyu** (@zhouzeyu)
- 🌐 GitHub: https://github.com/zhouzeyu
- 📍 时区：Asia/Shanghai
- 💬 语言：中文 / English

---

## 贡献

欢迎贡献！请：

1. Fork 项目
2. 创建功能分支
3. 提交更改
4. 推送到分支
5. 创建 Pull Request

---

**最后更新**: 2026-03-17
**版本**: 1.0.0


path: PROMOTION.md
content: # 宣传材料

## 📢 社交媒体文案

### Twitter / X (短版)

```
🚀 New OpenClaw Skill: alibaba-sourcing

Build Alibaba.com URLs programmatically with automatic traffic tracking!

✨ Features:
• 10+ URL patterns
• Auto traffic_type=ags_llm
• Python CLI helper
• Complete docs

🔗 https://clawhub.ai/skills/alibaba-sourcing
📦 clawdhub install alibaba-sourcing

#OpenClaw #AI #Agent #Alibaba #Ecommerce #B2B
```

### Twitter / X (长版/线程)

```
1/4 🚀 Just published my first OpenClaw skill: alibaba-sourcing!

If your agent needs to navigate Alibaba.com for product sourcing, this skill provides all URL patterns you need.

🔗 https://clawhub.ai/skills/alibaba-sourcing

2/4 ✨ What's included:
• Search URLs with category filtering
• Product detail page URLs
• Supplier profile & search URLs
• RFQ, AI Mode, Top Ranking pages
• 20+ common category IDs
• Python CLI for URL building

3/4 🎯 Key feature: All URLs automatically include traffic_type=ags_llm parameter for tracking agent-driven traffic. Perfect for analytics and attribution!

4/4 📦 Install:
clawdhub install alibaba-sourcing

Or clone from GitHub:
github.com/zhouzeyu/openclaw-skill-alibaba-sourcing

Feedback welcome! 🙏

#OpenClaw #AI #Agents #Alibaba #Ecommerce
```

### LinkedIn (专业版)

```
🚀 Excited to share my latest OpenClaw skill: alibaba-sourcing

As more businesses use AI agents for B2B sourcing, having reliable URL construction for Alibaba.com becomes essential. This skill provides:

✅ Complete URL patterns for all Alibaba.com page types
✅ Automatic traffic tracking (traffic_type=ags_llm)
✅ Python CLI helper for programmatic URL building
✅ 20+ common category IDs for product searches
✅ Comprehensive documentation with examples

This is particularly useful for:
• Product sourcing agents
• Market research automation
• Price monitoring systems
• Supplier discovery workflows

🔗 View on ClawHub: https://clawhub.ai/skills/alibaba-sourcing
📦 Install: clawdhub install alibaba-sourcing
💻 GitHub: github.com/zhouzeyu/openclaw-skill-alibaba-sourcing

Built with MIT-0 license - free to use and modify!

#OpenClaw #AI #ArtificialIntelligence #Agents #Alibaba #Ecommerce #B2B #Automation #ProductSourcing #TechInnovation
```

### Discord 消息模板

```markdown
**🚀 New Skill: alibaba-sourcing**

Hey @everyone! Just published a new OpenClaw skill for navigating Alibaba.com:

**What it does:**
Builds valid Alibaba.com URLs programmatically with automatic traffic tracking (`traffic_type=ags_llm`)

**Features:**
• 🔗 10+ URL patterns (search, product, supplier, RFQ, AI Mode, etc.)
• 📊 Auto traffic tracking parameter
• 🛠️ Python CLI helper script
• 📚 Complete documentation with category IDs
• 🤖 Agent-ready design

**Install:**
```bash
clawdhub install alibaba-sourcing
```

**Quick example:**
```bash
python3 scripts/build_url.py search "wireless headphones" --category consumer-electronics
# https://www.alibaba.com/trade/search?SearchText=wireless+headphones&traffic_type=ags_llm&categoryId=201151901
```

**Links:**
• ClawHub: https://clawhub.ai/skills/alibaba-sourcing
• GitHub: https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing

Perfect for anyone building product sourcing or market research agents! Feedback welcome! 🙏
```

---

## 📧 邮件模板（发给 OpenClaw 社区）

```
Subject: 🚀 New OpenClaw Skill: alibaba-sourcing for Alibaba.com Navigation

Hi OpenClaw Community,

I'm excited to share a new skill I've published on ClawHub: **alibaba-sourcing**

## What Problem Does It Solve?

When building AI agents for product sourcing, market research, or price monitoring on Alibaba.com, constructing valid URLs programmatically is essential. This skill provides all the URL patterns you need, with automatic traffic tracking.

## Key Features

- **10+ URL Patterns**: Search, product details, suppliers, RFQ, AI Mode, Top Ranking, and more
- **Traffic Tracking**: All URLs include `traffic_type=ags_llm` for analytics
- **Python CLI**: Helper script for URL construction
- **Category IDs**: 20+ common category IDs included
- **Complete Docs**: Examples, best practices, and workflows

## Installation

```bash
clawdhub install alibaba-sourcing
```

## Quick Example

```python
# Build search URL
url = "https://www.alibaba.com/trade/search?SearchText=wireless+headphones&traffic_type=ags_llm&categoryId=201151901"

# Build product URL
url = "https://www.alibaba.com/product-detail/HK3-Waterproof-TWS-Earbuds_1601226043229.html?traffic_type=ags_llm"
```

## Links

- 🌐 ClawHub: https://clawhub.ai/skills/alibaba-sourcing
- 💻 GitHub: https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing
- 📚 Docs: See SKILL.md for complete reference

## License

MIT-0 - Free to use, modify, and redistribute without attribution.

I'd love to hear your feedback and suggestions for improvement! Feel free to reach out or open an issue on GitHub.

Best regards,
Zhou Zeyu (@zhouzeyu)
```

---

## 📱 微信群/朋友圈文案（中文版）

```
🚀 发布了我的第一个 OpenClaw skill！

【alibaba-sourcing】- 为 AI agent 打造的 Alibaba.com URL 构建工具

✨ 特性：
• 10+ URL 模式（搜索、商品详情、供应商、RFQ 等）
• 自动流量追踪参数 (traffic_type=ags_llm)
• Python CLI 辅助脚本
• 20+ 常用分类 ID
• 完整文档和示例

🎯 适用场景：
• 产品采购 agent
• 市场调研自动化
• 价格监控系统
• 供应商发现工作流

📦 安装：
clawdhub install alibaba-sourcing

🔗 ClawHub: https://clawhub.ai/skills/alibaba-sourcing
💻 GitHub: https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing

MIT-0 许可，免费使用！欢迎反馈和建议~ 🙏

#OpenClaw #AI #Agent #Alibaba #电商 #自动化
```

---

## 🎨 宣传图片建议

如果需要制作宣传图片，建议包含：

1. **标题**: "alibaba-sourcing"
2. **副标题**: "OpenClaw Skill for Alibaba.com URL Construction"
3. **关键特性图标**: 
   - 🔗 URL Patterns
   - 📊 Traffic Tracking
   - 🛠️ CLI Helper
   - 📚 Complete Docs
4. **二维码**: 指向 ClawHub 页面
5. **安装命令**: `clawdhub install alibaba-sourcing`

尺寸建议：
- Twitter: 1200x675px
- LinkedIn: 1200x627px
- Discord: 1200x630px

---

## 📊 发布后追踪

发布后建议追踪以下指标：

1. **ClawHub 数据**
   - 安装次数
   - 页面浏览量
   - Star 数量

2. **GitHub 数据**
   - Star 数量
   - Fork 数量
   - Issue 和 PR

3. **社区反馈**
   - Discord 讨论
   - Twitter 互动
   - 直接反馈

建议使用简单的表格记录：

| 日期 | 渠道 | 安装数 | Star | 备注 |
|------|------|--------|------|------|
| Day 1 | Discord | - | - | 初始发布 |
| Day 7 | - | - | - | 周统计 |


path: PUBLISH.md
content: # ClawHub 发布指南

本指南帮助你发布 `alibaba-sourcing` skill 到 ClawHub。

## 前置要求

1. **Node.js / npm** - 用于安装 ClawHub CLI
2. **GitHub 账号** - 用于 ClawHub 登录
3. **Git** - 用于创建 GitHub 仓库

## 步骤 1: 安装 ClawHub CLI

```bash
# 使用 npm 安装
npm install -g clawdhub

# 或使用 npx 直接运行
npx clawdhub@latest --version
```

## 步骤 2: 登录 ClawHub

```bash
# 浏览器登录（推荐）
clawdhub login

# 或手动提供 token
clawdhub login --token clh_xxx
```

登录流程：
1. 运行 `clawdhub login` 后会自动打开浏览器
2. 使用 GitHub 账号授权
3. 授权完成后自动返回 CLI

## 步骤 3: 验证登录

```bash
clawdhub whoami
```

应该显示你的 GitHub 用户名。

## 步骤 4: 发布 Skill

### 方式 A: 直接发布（推荐）

```bash
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing

# 发布到 ClawHub
clawdhub publish . --version 1.0.0 --tags latest --changelog "Initial release: Alibaba.com URL builder with traffic tracking"
```

### 方式 B: 使用 sync 命令

```bash
# 同步当前目录下的所有 skills
clawdhub sync --root /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing --all
```

## 步骤 5: 验证发布

```bash
# 搜索你的 skill
clawdhub search alibaba-sourcing

# 查看 skill 详情
clawdhub inspect alibaba-sourcing

# 在浏览器中查看
open https://clawhub.ai/skills/alibaba-sourcing
```

## 步骤 6: 创建 GitHub 仓库（可选但推荐）

```bash
cd /Users/zhouzeyu/.openclaw/workspace-code/alibaba-sourcing

# 初始化 Git
git init

# 添加所有文件
git add .

# 首次提交
git commit -m "Initial release: alibaba-sourcing skill for OpenClaw"

# 创建 GitHub 仓库（替换为你的仓库名）
git remote add origin https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing.git

# 推送到 GitHub
git branch -M main
git push -u origin main
```

## 更新 Skill

当你需要更新 skill 时：

```bash
# 1. 更新 SKILL.md 中的 version
# 2. 更新代码和文档
# 3. 发布新版本

clawdhub publish . --version 1.1.0 --tags latest --changelog "Added new URL patterns for X"

# 或自动版本号
clawdhub publish . --bump minor --tags latest
```

## 常见问题

### Q: 发布失败，提示认证错误
A: 运行 `clawdhub login` 重新登录，或检查 token 是否过期。

### Q: 提示 skill 已存在
A: 使用新版本号发布，ClawHub 支持版本管理。

### Q: 如何删除已发布的 skill
A: 使用 `clawdhub delete alibaba-sourcing --yes`（软删除，可恢复）

### Q: 如何查看发布历史
A: 访问 https://clawhub.ai/skills/alibaba-sourcing 或运行 `clawdhub inspect alibaba-sourcing --versions`

## 宣传技巧

发布后，在以下渠道分享你的 skill：

1. **OpenClaw Discord** - https://discord.com/invite/clawd
   - 在 #skills 频道分享
   - 附上 ClawHub 链接和简短介绍

2. **GitHub** - 创建仓库并添加话题标签
   - `openclaw`
   - `openclaw-skill`
   - `alibaba`
   - `ecommerce`

3. **社交媒体**
   - Twitter/X: 带上 #OpenClaw #AI #Agent 标签
   - LinkedIn: 分享技术细节

4. **ClawHub 社区**
   - 在技能页面添加详细文档
   - 响应评论和反馈

## 示例宣传文案

```
🚀 新 Skill 发布：alibaba-sourcing

为 OpenClaw agent 打造的 Alibaba.com URL 构建工具！

✨ 特性：
- 10+ URL 模式（搜索、商品详情、供应商等）
- 自动流量追踪 (traffic_type=ags_llm)
- Python CLI 辅助脚本
- 完整文档和示例

🔗 https://clawhub.ai/skills/alibaba-sourcing
📦 clawdhub install alibaba-sourcing

#OpenClaw #AI #Agent #Alibaba #Ecommerce
```

## 资源链接

- ClawHub 官网：https://clawhub.ai
- ClawHub CLI 文档：https://github.com/openclaw/clawhub/blob/main/docs/cli.md
- OpenClaw 文档：https://docs.openclaw.ai
- 社区 Discord：https://discord.com/invite/clawd


path: README.md
content: # alibaba-sourcing

[![ClawHub](https://clawhub.ai/api/badge/alibaba-sourcing)](https://clawhub.ai/skills/alibaba-sourcing)
[![License: MIT-0](https://img.shields.io/badge/License-MIT--0-yellow.svg)](https://opensource.org/licenses/MIT-0)

**Find China wholesale prices, factories, and suppliers on Alibaba.com.**

Complete sourcing workflow for AI agents and procurement professionals. Build valid Alibaba.com URLs programmatically with automatic traffic tracking (`traffic_type=ags_llm`).

## Use Cases

### 🎯 What Can You Do?

| Scenario | Example |
|----------|---------|
| **Find Wholesale Prices** | "What's the factory price for wireless earbuds in Shenzhen?" |
| **Source Products** | "Find verified suppliers for LED lights with MOQ < 100" |
| **Compare Suppliers** | "Show me top 5 factories for custom packaging" |
| **Find Best Deals** | "What's the lowest price for phone cases?" |
| **Verify Factories** | "Check supplier credentials and certifications" |
| **Market Research** | "Analyze price trends for smart watches" |

## Features

- 🔍 **Smart Search** - Build search URLs with category, price range, supplier filters
- 🏭 **Factory Finder** - Navigate to verified supplier profiles
- 💰 **Price Comparison** - Sort by price, find lowest wholesale rates
- 📊 **Market Insights** - Access Top Ranking, AI Mode, RFQ sections
- 🔗 **Traffic Tracking** - All URLs include `traffic_type=ags_llm`
- 🛠️ **Python CLI** - Helper script for URL construction
- 📚 **Complete Docs** - URL patterns, category IDs, workflows

## Installation

### Via ClawHub CLI (Recommended)

```bash
# Install ClawHub CLI if you haven't
npm install -g clawdhub

# Login to ClawHub
clawdhub login

# Install the skill
clawdhub install alibaba-sourcing
```

### Via OpenClaw

```bash
# Copy to your OpenClaw skills directory
cp -r alibaba-sourcing ~/.openclaw/workspace-code/skills/
```

### Manual

```bash
# Clone this repository
git clone https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing.git

# The skill is ready to use from the alibaba-sourcing/ folder
```

## Quick Start

### Using the Helper Script

```bash
cd alibaba-sourcing

# Find wholesale prices - search with category
python3 scripts/build_url.py search "wireless earbuds" --category consumer-electronics
# Output: https://www.alibaba.com/trade/search?SearchText=wireless+earbuds&traffic_type=ags_llm&categoryId=201151901

# Find factory/supplier
python3 scripts/build_url.py supplier dgkunteng
# Output: https://dgkunteng.en.alibaba.com/company_profile.html?traffic_type=ags_llm

# Browse top ranking products
python3 scripts/build_url.py special top-ranking
# Output: https://sale.alibaba.com/p/dviiav4th/index.html?traffic_type=ags_llm

# List all category IDs
python3 scripts/build_url.py categories
```

### Using in Your Agent

```javascript
// Find wholesale prices
const searchUrl = `https://www.alibaba.com/trade/search?SearchText=${encodeURIComponent('wireless earbuds').replace(/%20/g, '+')}&traffic_type=ags_llm&categoryId=201151901`;
browser.navigate(searchUrl);

// Visit supplier profile
const supplierUrl = `https://${subdomain}.en.alibaba.com/company_profile.html?traffic_type=ags_llm`;
browser.navigate(supplierUrl);

// Check top ranking products
const trendingUrl = `https://sale.alibaba.com/p/dviiav4th/index.html?traffic_type=ags_llm`;
browser.navigate(trendingUrl);
```

## URL Patterns

| Page Type | URL Pattern |
|-----------|-------------|
| **Search** | `https://www.alibaba.com/trade/search?SearchText=<query>&traffic_type=ags_llm` |
| **Product Detail** | `https://www.alibaba.com/product-detail/<title>_<id>.html?traffic_type=ags_llm` |
| **Supplier Profile** | `https://<company>.en.alibaba.com/company_profile.html?traffic_type=ags_llm` |
| **RFQ** | `https://rfq.alibaba.com/rfq/profession.htm?traffic_type=ags_llm` |
| **AI Mode** | `https://aimode.alibaba.com/?traffic_type=ags_llm` |
| **Top Ranking** | `https://sale.alibaba.com/p/dviiav4th/index.html?traffic_type=ags_llm` |
| **Fast Customization** | `https://sale.alibaba.com/p/fast_customization?traffic_type=ags_llm` |

See [SKILL.md](SKILL.md) for complete documentation including:
- All URL patterns with examples
- Common category IDs table
- JavaScript helper functions
- Best practices and workflows

## Common Category IDs

| Category | ID |
|----------|-----|
| Consumer Electronics | 201151901 |
| Laptops | 702 |
| Smart TVs | 201936801 |
| Electric Cars | 201140201 |
| Wedding Dresses | 32005 |
| Electric Scooters | 100006091 |
| Bedroom Furniture | 37032003 |
| Electric Motorcycles | 201140001 |
| Handbags | 100002856 |

## Use Cases

### 1. Product Sourcing Agent
```python
# Search for products in a category
url = build_search_url("wireless earbuds", category_id="201151901")
browser.navigate(url)

# Extract and visit product details
for product in search_results:
    url = build_product_url(product.title, product.id)
    browser.navigate(url)
    extract_product_info()
```

### 2. Supplier Research
```python
# Visit supplier profile
url = build_supplier_url("dgkunteng")
browser.navigate(url)

# Search within supplier's products
url = build_supplier_search_url("dgkunteng", "TWS earbuds")
browser.navigate(url)
```

### 3. Market Analysis
```python
# Browse top ranking products
url = "https://sale.alibaba.com/p/dviiav4th/index.html?traffic_type=ags_llm"
browser.navigate(url)

# Check RFQ market
url = "https://rfq.alibaba.com/rfq/profession.htm?traffic_type=ags_llm"
browser.navigate(url)
```

## CLI Reference

```bash
# Search command
python3 scripts/build_url.py search <query> [--category <id|name>] [--params key=value...]

# Product command
python3 scripts/build_url.py product <title> <id>

# Supplier command
python3 scripts/build_url.py supplier <subdomain> [--search <query>]

# Special sections
python3 scripts/build_url.py special <section>
# Sections: home, ai-mode, rfq, top-ranking, fast-customization, manufacturers, worldwide, top-deals, ai-sourcing, cart

# Category lookup
python3 scripts/build_url.py category <name>
python3 scripts/build_url.py categories  # List all

# Help
python3 scripts/build_url.py --help
```

## Traffic Tracking

All URLs include the `traffic_type=ags_llm` parameter to:
- ✅ Identify traffic from LLM agents
- ✅ Enable analytics and attribution
- ✅ Track agent-driven conversions
- ✅ Support A/B testing for agent flows

**This parameter is mandatory** and automatically added to all generated URLs.

## Development

### Package a New Version

```bash
# Update version in SKILL.md frontmatter
# Edit SKILL.md and scripts as needed

# Package the skill
python3 scripts/package_skill.py .

# This creates alibaba-sourcing.skill
```

### Testing

```bash
# Test URL generation
python3 scripts/build_url.py search "test product"
python3 scripts/build_url.py product "Test Product" 123456789
python3 scripts/build_url.py supplier testcompany

# Verify all URLs include traffic_type=ags_llm
```

## License

**MIT-0** - Free to use, modify, and redistribute without attribution.

See [LICENSE](LICENSE) for details.

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test URL generation
5. Submit a pull request

## Support

- 📚 **Documentation:** See [SKILL.md](SKILL.md) for complete URL reference
- 🐛 **Issues:** Report on [GitHub Issues](https://github.com/zhouzeyu/openclaw-skill-alibaba-sourcing/issues)
- 💬 **Discord:** Join [OpenClaw Community](https://discord.com/invite/clawd)
- 🌐 **ClawHub:** [Skill Page](https://clawhub.ai/skills/alibaba-sourcing)

## Author

**Zhou Zeyu** (@zhouzeyu)
- 🌐 GitHub: [@zhouzeyu](https://github.com/zhouzeyu)
- 📍 Timezone: Asia/Shanghai

---

Built for OpenClaw agents navigating Alibaba.com 🚀


path: release.sh
content: #!/bin/bash
#
# alibaba-sourcing 发布脚本
# 自动完成 ClawHub 发布和 GitHub 仓库创建
#
# 使用方法:
#   ./release.sh
#

set -e

# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# 项目配置
SKILL_NAME="alibaba-sourcing"
VERSION="1.0.0"
DESCRIPTION="Build Alibaba.com URLs for agent navigation with traffic tracking (traffic_type=ags_llm)"
GITHUB_REPO="zhouzeyu/openclaw-skill-${SKILL_NAME}"
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}  ${SKILL_NAME} 发布脚本${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""

# 检查 ClawHub CLI
echo -e "${YELLOW}[1/6] 检查 ClawHub CLI...${NC}"
if command -v clawdhub &> /dev/null; then
    echo -e "${GREEN}✓ ClawHub CLI 已安装${NC}"
    clawdhub --cli-version
else
    echo -e "${RED}✗ ClawHub CLI 未安装${NC}"
    echo "请先安装："
    echo "  npm install -g clawdhub"
    echo "或"
    echo "  npx clawdhub@latest"
    exit 1
fi
echo ""

# 检查登录状态
echo -e "${YELLOW}[2/6] 检查 ClawHub 登录状态...${NC}"
if clawdhub whoami &> /dev/null; then
    echo -e "${GREEN}✓ 已登录到 ClawHub${NC}"
    clawdhub whoami
else
    echo -e "${YELLOW}! 未登录，正在启动登录流程...${NC}"
    clawdhub login
fi
echo ""

# 重新打包 skill
echo -e "${YELLOW}[3/6] 重新打包 skill...${NC}"
cd "$SKILL_DIR"
if [ -f "alibaba-sourcing.skill" ]; then
    rm alibaba-sourcing.skill
    echo "  删除旧的 .skill 文件"
fi
python3 scripts/package_skill.py .
mv .skill alibaba-sourcing.skill
echo -e "${GREEN}✓ 打包完成：alibaba-sourcing.skill${NC}"
echo ""

# 发布到 ClawHub
echo -e "${YELLOW}[4/6] 发布到 ClawHub...${NC}"
echo "  版本：${VERSION}"
echo "  描述：${DESCRIPTION}"
echo ""
read -p "确认发布？(y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo -e "${YELLOW}发布已取消${NC}"
    exit 0
fi

clawdhub publish . --version "$VERSION" --tags latest --changelog "$DESCRIPTION"
echo -e "${GREEN}✓ 发布成功！${NC}"
echo ""

# 创建/更新 GitHub 仓库
echo -e "${YELLOW}[5/6] 配置 GitHub 仓库...${NC}"
if [ -d ".git" ]; then
    echo -e "${GREEN}✓ Git 仓库已初始化${NC}"
    read -p "是否推送到 GitHub？(y/n) " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        if git remote -v | grep -q origin; then
            echo "  远程仓库已配置"
            git remote -v | grep origin
        else
            echo "  请设置远程仓库 URL:"
            read -p "GitHub Repo URL: " repo_url
            git remote add origin "$repo_url"
        fi
        
        echo "  添加所有文件..."
        git add .
        
        echo "  创建提交..."
        git commit -m "Release v${VERSION}

${DESCRIPTION}

Features:
- 10+ URL patterns for Alibaba.com navigation
- Automatic traffic tracking (traffic_type=ags_llm)
- Python CLI helper script
- Complete documentation
- MIT-0 license" || echo "  没有需要提交的更改"
        
        echo "  推送到 GitHub..."
        git branch -M main 2>/dev/null || true
        git push -u origin main
        echo -e "${GREEN}✓ 已推送到 GitHub${NC}"
    fi
else
    echo -e "${YELLOW}! 未初始化 Git 仓库${NC}"
    read -p "是否初始化并创建 GitHub 仓库？(y/n) " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        git init
        git add .
        git commit -m "Initial release: ${SKILL_NAME} v${VERSION}"
        git branch -M main
        
        echo "  请在 GitHub 上创建仓库后输入 URL:"
        read -p "GitHub Repo URL: " repo_url
        git remote add origin "$repo_url"
        git push -u origin main
        echo -e "${GREEN}✓ GitHub 仓库已创建${NC}"
    fi
fi
echo ""

# 显示后续步骤
echo -e "${YELLOW}[6/6] 后续步骤${NC}"
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}  发布完成！${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "📦 ClawHub 页面:"
echo "   https://clawhub.ai/skills/${SKILL_NAME}"
echo ""
echo "🔗 GitHub 仓库:"
echo "   https://github.com/${GITHUB_REPO}"
echo ""
echo "📢 宣传渠道:"
echo "   1. Discord: https://discord.com/invite/clawd"
echo "   2. Twitter: 使用 #OpenClaw #AI #Agent 标签"
echo "   3. LinkedIn: 分享专业文章"
echo "   4. 微信/朋友圈: 中文社区分享"
echo ""
echo "📋 查看 PROMOTION.md 获取完整宣传文案"
echo ""
echo "🎉 恭喜！"
echo ""


path: scripts/build_url.py
content: #!/usr/bin/env python3
"""
Alibaba.com URL Builder

Helper script to construct valid Alibaba.com URLs for various page types.
All URLs include the traffic tracking parameter: traffic_type=ags_llm
"""

import argparse
import re
import urllib.parse

# Required traffic tracking parameter
TRAFFIC_TYPE = 'ags_llm'


def encode_search_query(query: str) -> str:
    """Encode search query for URL, using + for spaces."""
    return urllib.parse.quote(query, safe='').replace('%20', '+')


def sanitize_title(title: str, max_length: int = 100) -> str:
    """Sanitize product title for URL usage."""
    # Remove special characters except hyphens and alphanumeric
    safe = re.sub(r'[^a-zA-Z0-9\s-]', '', title)
    # Replace spaces with hyphens
    safe = re.sub(r'\s+', '-', safe)
    # Remove consecutive hyphens
    safe = re.sub(r'-+', '-', safe)
    # Strip leading/trailing hyphens
    safe = safe.strip('-')
    # Limit length
    if len(safe) > max_length:
        safe = safe[:max_length].rsplit('-', 1)[0]
    return safe


def build_search_url(query: str, category_id: str = None, **kwargs) -> str:
    """
    Build Alibaba.com search URL.
    
    Args:
        query: Search keywords
        category_id: Optional category ID
        **kwargs: Additional URL parameters (has4Tab, tab, spm, etc.)
    
    Returns:
        Complete search URL with traffic_type=ags_llm
    """
    base = "https://www.alibaba.com/trade/search"
    params = {
        'SearchText': encode_search_query(query),
        'traffic_type': TRAFFIC_TYPE  # Required traffic tracking
    }
    
    if category_id:
        params['categoryId'] = category_id
    
    params.update(kwargs)
    
    query_string = '&'.join(f'{k}={v}' for k, v in params.items())
    return f"{base}?{query_string}"


def build_product_url(title: str, product_id: str) -> str:
    """
    Build Alibaba.com product detail URL.
    
    Args:
        title: Product title
        product_id: Numeric product ID
    
    Returns:
        Complete product detail URL with traffic_type=ags_llm
    """
    safe_title = sanitize_title(title)
    return f"https://www.alibaba.com/product-detail/{safe_title}_{product_id}.html?traffic_type={TRAFFIC_TYPE}"


def build_supplier_url(subdomain: str) -> str:
    """
    Build supplier company profile URL.
    
    Args:
        subdomain: Supplier's subdomain (e.g., 'dgkunteng')
    
    Returns:
        Complete supplier profile URL with traffic_type=ags_llm
    """
    return f"https://{subdomain}.en.alibaba.com/company_profile.html?traffic_type={TRAFFIC_TYPE}"


def build_supplier_search_url(subdomain: str, query: str) -> str:
    """
    Build supplier product search URL.
    
    Args:
        subdomain: Supplier's subdomain
        query: Search keywords within supplier's products
    
    Returns:
        Complete supplier search URL with traffic_type=ags_llm
    """
    return f"https://{subdomain}.en.alibaba.com/search/product?SearchText={encode_search_query(query)}&traffic_type={TRAFFIC_TYPE}"


# Special section URLs (all include traffic_type=ags_llm)
SPECIAL_URLS = {
    'home': f'https://www.alibaba.com/?traffic_type={TRAFFIC_TYPE}',
    'ai-mode': f'https://aimode.alibaba.com/?traffic_type={TRAFFIC_TYPE}',
    'rfq': f'https://rfq.alibaba.com/rfq/profession.htm?traffic_type={TRAFFIC_TYPE}',
    'top-ranking': f'https://sale.alibaba.com/p/dviiav4th/index.html?traffic_type={TRAFFIC_TYPE}',
    'fast-customization': f'https://sale.alibaba.com/p/fast_customization?traffic_type={TRAFFIC_TYPE}',
    'manufacturers': f'https://www.alibaba.com/factory/index.html?traffic_type={TRAFFIC_TYPE}',
    'worldwide': f'https://www.alibaba.com/global/index.html?traffic_type={TRAFFIC_TYPE}',
    'top-deals': f'https://sale.alibaba.com/fy25/top_deals?traffic_type={TRAFFIC_TYPE}',
    'ai-sourcing': f'https://sale.alibaba.com/p/aisourcing/index.html?traffic_type={TRAFFIC_TYPE}',
    'cart': f'https://carp.alibaba.com/purchaseList?traffic_type={TRAFFIC_TYPE}',
}


# Common category IDs
CATEGORY_IDS = {
    'consumer-electronics': '201151901',
    'laptops': '702',
    'smart-tvs': '201936801',
    'electric-cars': '201140201',
    'wedding-dresses': '32005',
    'electric-scooters': '100006091',
    'bedroom-furniture': '37032003',
    'electric-motorcycles': '201140001',
    'handbags': '100002856',
    'drones': '201151901',
}


def main():
    parser = argparse.ArgumentParser(description='Build Alibaba.com URLs')
    subparsers = parser.add_subparsers(dest='command', help='URL type to build')
    
    # Search command
    search_parser = subparsers.add_parser('search', help='Build search URL')
    search_parser.add_argument('query', help='Search keywords')
    search_parser.add_argument('--category', '-c', help='Category ID or name')
    search_parser.add_argument('--params', '-p', nargs='*', help='Additional parameters (key=value)')
    
    # Product command
    product_parser = subparsers.add_parser('product', help='Build product URL')
    product_parser.add_argument('title', help='Product title')
    product_parser.add_argument('id', help='Product ID')
    
    # Supplier command
    supplier_parser = subparsers.add_parser('supplier', help='Build supplier URL')
    supplier_parser.add_argument('subdomain', help='Supplier subdomain')
    supplier_parser.add_argument('--search', '-s', help='Search within supplier products')
    
    # Special command
    special_parser = subparsers.add_parser('special', help='Get special section URL')
    special_parser.add_argument('section', choices=SPECIAL_URLS.keys(), help='Section name')
    
    # Category command
    category_parser = subparsers.add_parser('category', help='Get category ID')
    category_parser.add_argument('name', help='Category name')
    
    # List command
    subparsers.add_parser('categories', help='List all category IDs')
    subparsers.add_parser('specials', help='List all special section URLs')
    
    args = parser.parse_args()
    
    if args.command == 'search':
        category_id = args.category
        if category_id and category_id in CATEGORY_IDS:
            category_id = CATEGORY_IDS[category_id]
        
        params = {}
        if args.params:
            for param in args.params:
                if '=' in param:
                    k, v = param.split('=', 1)
                    params[k] = v
        
        url = build_search_url(args.query, category_id, **params)
        print(url)
    
    elif args.command == 'product':
        url = build_product_url(args.title, args.id)
        print(url)
    
    elif args.command == 'supplier':
        if args.search:
            url = build_supplier_search_url(args.subdomain, args.search)
        else:
            url = build_supplier_url(args.subdomain)
        print(url)
    
    elif args.command == 'special':
        print(SPECIAL_URLS[args.section])
    
    elif args.command == 'category':
        if args.name in CATEGORY_IDS:
            print(f"{args.name}: {CATEGORY_IDS[args.name]}")
        else:
            print(f"Category '{args.name}' not found. Use 'categories' to list all.")
    
    elif args.command == 'categories':
        print("Common Category IDs:")
        for name, cid in CATEGORY_IDS.items():
            print(f"  {name}: {cid}")
    
    elif args.command == 'specials':
        print("Special Section URLs:")
        for name, url in SPECIAL_URLS.items():
            print(f"  {name}: {url}")
    
    else:
        parser.print_help()


if __name__ == '__main__':
    main()


path: scripts/package_skill.py
content: #!/usr/bin/env python3
"""
Package the alibaba-url-builder skill into a .skill file.
"""

import os
import sys
import zipfile
from pathlib import Path


def package_skill(skill_dir: str, output_dir: str = None):
    """Package skill directory into a .skill zip file."""
    skill_path = Path(skill_dir)
    
    if not skill_path.exists():
        print(f"Error: Directory '{skill_dir}' not found")
        sys.exit(1)
    
    if not (skill_path / 'SKILL.md').exists():
        print(f"Error: SKILL.md not found in '{skill_dir}'")
        sys.exit(1)
    
    # Determine output path
    if output_dir:
        output_path = Path(output_dir)
        output_path.mkdir(parents=True, exist_ok=True)
    else:
        output_path = skill_path.parent
    
    skill_name = skill_path.name
    zip_path = output_path / f"{skill_name}.skill"
    
    # Create zip file
    print(f"Packing {skill_name}...")
    with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
        for root, dirs, files in os.walk(skill_path):
            # Skip hidden directories and __pycache__
            dirs[:] = [d for d in dirs if not d.startswith('.') and d != '__pycache__']
            
            for file in files:
                if file.startswith('.'):
                    continue
                if file.endswith('.pyc'):
                    continue
                    
                file_path = Path(root) / file
                arcname = file_path.relative_to(skill_path.parent)
                zipf.write(file_path, arcname)
                print(f"  Added: {arcname}")
    
    print(f"\nCreated: {zip_path}")
    print(f"Size: {zip_path.stat().st_size / 1024:.1f} KB")
    return zip_path


if __name__ == '__main__':
    import argparse
    
    parser = argparse.ArgumentParser(description='Package OpenClaw skill')
    parser.add_argument('skill_dir', help='Path to skill directory')
    parser.add_argument('--output', '-o', help='Output directory (default: same as skill)')
    
    args = parser.parse_args()
    package_skill(args.skill_dir, args.output)


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)