labels-sync
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLabels Sync: GitHub Label Synchronization
Labels Sync:GitHub标签同步
Purpose
用途
Synchronize GitHub repository labels with a predefined set of standard labels, or export the current repository labels as reusable JSON. The skill can compare the repo against a JSON definition, apply the missing changes, or return the repo's current label definitions in copy-ready form.
将GitHub仓库标签与预定义的标准标签集同步,或者将当前仓库的标签导出为可复用的JSON格式。本工具可以将仓库标签与JSON定义进行对比,应用缺失的更改,或者以可复制的形式返回仓库当前的标签定义。
When to Use This Skill
使用场景
Use when the user asks to:
- "Sync labels", "update labels", "fix labels"
- "Check labels", "show label differences", "preview label changes"
- "Manage GitHub labels", "set up labels"
- "Apply standard labels to this repo"
- "Export labels", "get current labels", "show labels JSON", "copy labels to another repo"
Trigger phrases: "labels-sync", "labels sync", "sync labels", "label sync", "github labels", "check labels", "export labels", "get labels"
当用户提出以下需求时使用:
- "同步标签"、"更新标签"、"修复标签"
- "检查标签"、"查看标签差异"、"预览标签更改"
- "管理GitHub标签"、"设置标签"
- "为当前仓库应用标准标签"
- "导出标签"、"获取当前标签"、"查看标签JSON"、"复制标签到其他仓库"
触发短语:"labels-sync"、"labels sync"、"sync labels"、"label sync"、"github labels"、"check labels"、"export labels"、"get labels"
Operations
操作说明
For sync and check flows, the script compares repository labels against the defined list and reports:
- CREATE: Labels in the definition but not in the repository
- UPDATE: Labels that exist but have different name case, description, or color
- DELETE: Labels in the repository but not in the definition
- UNCHANGED: Labels that match exactly
For export flows, the script reads the current repository labels and returns a normalized JSON array with:
namedescriptioncolor
在同步和检查流程中,脚本会将仓库标签与定义列表进行对比,并报告:
- CREATE:定义中存在但仓库中没有的标签
- UPDATE:已存在但名称大小写、描述或颜色不同的标签
- DELETE:仓库中存在但定义里没有的标签
- UNCHANGED:完全匹配的标签
在导出流程中,脚本会读取当前仓库的标签,并返回标准化的JSON数组,包含以下字段:
namedescriptioncolor
Asking the User
询问用户
Every question in this skill is written as options. Use that tool where
the host offers it, or the host's nearest structured-choice equivalent. Where the host has
neither, ask the same question in normal chat as a numbered list of 2–5 options —
recommended first, one short line of description each — and wait for the user to reply
with a number.
AskUserQuestion本工具中的所有问题均以选项形式编写。如果宿主平台提供该工具,请使用它;如果没有,请使用宿主平台最接近的结构化选择功能替代。若两者都没有,则以普通聊天形式提出问题,并列出2-5个带编号的选项——推荐将首选选项放在第一位,每个选项配一行简短描述——然后等待用户回复编号。
AskUserQuestionExecution Steps
执行步骤
Step 1: Determine Intent
步骤1:确定意图
From the command arguments or conversation context, determine the user's intent:
Apply changes if user explicitly requests (keywords in args or context):
- ,
apply,sync,update,fix,setenforce - Example: or "sync my labels"
labels-sync apply
Report only if user wants to check (keywords):
- ,
check,list,show,preview,dry-rundiff - Example: or "show label differences"
labels-sync check
Export current labels if user wants reusable output (keywords):
- ,
get,export,read,copyjson - Example: or "export current labels so I can copy them to another repo"
labels-sync get
If intent is unclear or no arguments are provided, ask per Asking the User:
- (Recommended) — Compare the repo labels against the bundled definition
Check - — Export the repo's current labels as reusable JSON
Get - — Sync the repo labels to match the bundled definition
Apply
从命令参数或对话上下文判断用户的意图:
应用更改 如果用户明确要求(参数或上下文中包含以下关键词):
- 、
apply、sync、update、fix、setenforce - 示例:或 "同步我的标签"
labels-sync apply
仅生成报告 如果用户想要检查(包含以下关键词):
- 、
check、list、show、preview、dry-rundiff - 示例:或 "查看标签差异"
labels-sync check
导出当前标签 如果用户想要可复用的输出(包含以下关键词):
- 、
get、export、read、copyjson - 示例:或 "导出当前标签以便复制到其他仓库"
labels-sync get
如果意图不明确或未提供参数,请按照「询问用户」部分的方式提问:
- (推荐)—— 将仓库标签与内置定义进行对比
Check - —— 将仓库当前标签导出为可复用的JSON
Get - —— 同步仓库标签以匹配内置定义
Apply
Step 2: Export Current Labels When Requested
步骤2:按需导出当前标签
For get/export mode, fetch and return the current repository labels directly:
bash
scripts/sync-labels.sh --getReturn the output in a fenced block so the user can copy it into another repository later. Keep the fields in the reusable definition shape:
jsonjson
[
{
"name": "bug",
"description": "Something isn't working",
"color": "B60205"
}
]If the user explicitly asks for only and , summarize those fields in the prose response, but keep the script output in the full reusable format unless they ask to omit descriptions.
namecolor在get/export模式下,直接获取并返回当前仓库的标签:
bash
scripts/sync-labels.sh --get将输出放在带围栏的代码块中,方便用户稍后复制到其他仓库。保持字段为可复用的定义格式:
jsonjson
[
{
"name": "bug",
"description": "Something isn't working",
"color": "B60205"
}
]如果用户明确要求只返回和,则在文本回复中汇总这些字段,但除非用户要求省略描述,否则脚本输出仍保持完整的可复用格式。
namecolorStep 3: Read Label Definitions for Sync/Check
步骤3:读取同步/检查用的标签定义
Read the label definitions from the bundled JSON file:
references/labels.jsonUse the Read tool to load the file contents.
Skip this step for get/export mode.
从内置的JSON文件中读取标签定义:
references/labels.json使用读取工具加载文件内容。
get/export模式下跳过此步骤。
Step 4: Execute Sync Script
步骤4:执行同步脚本
Pipe the label JSON to the sync script:
For dry-run (report only):
bash
cat references/labels.json | scripts/sync-labels.shFor applying changes, add flag:
--applybash
cat references/labels.json | scripts/sync-labels.sh --apply将标签JSON传入同步脚本:
对于dry-run(仅报告):
bash
cat references/labels.json | scripts/sync-labels.sh对于应用更改,添加参数:
--applybash
cat references/labels.json | scripts/sync-labels.sh --applyStep 5: Present Results
步骤5:展示结果
Parse the JSON output and present as a readable markdown report:
解析JSON输出并以易读的markdown报告形式展示:
Labels to Create
待创建标签
| Name | Description | Color |
|---|---|---|
| ... | ... | ... |
| 名称 | 描述 | 颜色 |
|---|---|---|
| ... | ... | ... |
Labels to Update
待更新标签
| Name | Field | From | To |
|---|---|---|---|
| ... | ... | ... | ... |
| 名称 | 字段 | 当前值 | 目标值 |
|---|---|---|---|
| ... | ... | ... | ... |
Labels to Delete
待删除标签
| Name |
|---|
| ... |
| 名称 |
|---|
| ... |
Unchanged Labels
未更改标签
- label1, label2, label3...
If no changes are needed, report that all labels are already in sync.
If changes were applied, confirm success. If any errors occurred, report them.
For get/export mode, prefer returning the exact JSON in a fenced code block first, then optionally add a short summary table of label names and colors if that helps the user scan it.
- label1、label2、label3...
如果无需更改,报告所有标签已同步。
如果更改已应用,确认操作成功。若发生任何错误,报告错误信息。
对于get/export模式,优先返回带围栏代码块的精确JSON,然后可选择性添加标签名称和颜色的简短汇总表格,方便用户快速浏览。
Customization
自定义
To customize the label set, edit the JSON file at:
references/labels.jsonEach label entry requires three fields:
- — Label name (case-sensitive)
name - — Short description
description - — Hex color without
colorprefix (e.g.,#)B60205
要自定义标签集,请编辑以下JSON文件:
references/labels.json每个标签条目需要三个字段:
- —— 标签名称(区分大小写)
name - —— 简短描述
description - —— 不带
color前缀的十六进制颜色(例如:#)B60205
Bundled Files
内置文件
- — Generic sync/export script (exports current labels, or reads stdin JSON, diffs via
scripts/sync-labels.sh, and applies viajq)gh - — Label definitions (single source of truth)
references/labels.json
- —— 通用同步/导出脚本(导出当前标签,或读取标准输入的JSON,通过
scripts/sync-labels.sh对比差异,并通过jq应用更改)gh - —— 标签定义(唯一可信来源)
references/labels.json
Prerequisites
前置条件
- CLI authenticated (
gh)gh auth login - installed
jq - Must be run from within a GitHub repository
- CLI已完成认证(执行
gh)gh auth login - 已安装
jq - 必须在GitHub仓库目录内运行