AgentSkillsCN

fill-metric-ids

一款通用工具,可根据Excel/CSV字典,将度量ID填充至HTML文件中。支持模糊匹配与上下文前缀(例如,在“登录”选项卡中,“Count”可前缀为“登录用户数”)。

SKILL.md
--- frontmatter
name: fill-metric-ids
description: A generic tool to populate Metric IDs into HTML files based on an Excel/CSV dictionary. Supports fuzzy matching and contextual prefixing (e.g. "Count" in "Login" tab to "Login User Count").

Fill Metric IDs (Generic)

This skill provides a generic utility to scan an HTML file for text (metric names) and append their corresponding IDs from a provided data source.

Capabilities

  1. Generic Matching: Matches text in HTML against a Name->ID dictionary (Excel or CSV).
  2. Fuzzy Matching: Uses difflib to handle slight variations (e.g. "User Count" vs "Count", "访问数" vs "访问人数").
  3. Context Aware: Can prepend prefixes to keys based on parent element IDs/Classes (defined in config).
  4. Flexible Selectors: Target specific tags (default h3, th, td).

Usage

1. Unified Metric Filler

bash
python3 .agent/skills/fill-metric-ids/scripts/fill_metrics.py \
  --html <input.html> \
  --source <metrics.xlsx>

The script automatically handles:

  1. Specialized Logic: Fixes known structural issues (Bound Users, Retention Tables).
  2. Context Mapping: Uses miniprogram_context.json to map specific tabs to metric prefixes.
  3. Generic Filling: Scans for remaining metrics using Fuzzy and Substring matching.
  4. Optimizations: Excludes "Date" column, applies manual mappings for known aliases.

Context Config Example

context.json:

json
{
  "#login-tab": ["Login User"],
  ".share-section": ["Share User"]
}

If the tool finds "Count" inside <div id="login-tab">, it looks for "Login UserCount" in the Excel.