From 49e4f3e35b86218c7fcd89ac7840ff0f65eaf172 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 24 Aug 2026 14:47:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(pr):=20=E6=96=B0=E5=A2=9E=20slugify.sh=20?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=91=BD=E5=90=8D=E5=B7=A5=E5=85=B7=E4=B8=A6?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20pr=20=E6=8A=80=E8=83=BD=E7=A8=BD=E6=A0=B8?= =?UTF-8?q?=E9=A0=85=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What: 新增 tools/slugify.sh 腳本,將分支類型與短語轉成 ASCII slug;修改 skills/pr/SKILL.md,把原本內嵌在文字說明中的 slugify 規則改為呼叫 tools/slugify.sh,並把 Rules 段落中「分支標題摘要」與「描述撰寫」都標記為必須交由 sub agent 執行(原本只有描述撰寫一項),同時把一個非英文範例字串替換成全英文範例;plugin.json、.claude-plugin/plugin.json、.codex-plugin/plugin.json 三份 manifest 版本號由 0.0.1 升到 0.0.2。 Why: 因應 jsc-meta:skill-check 稽核結果,pr 技能有兩項不合規:決定性的分支名稱 slugify 流程應該工具化而非寫成文字規則,避免各 agent 各自理解出現落差;另外,需要判斷力的步驟(分支標題摘要、描述撰寫)標記不一致,只標了描述撰寫一項會讓分支標題摘要漏掉必要的 sub agent 隔離;範例字串混雜非英文也不符合技能文件全英文的要求。 How: 新增可執行的 tools/slugify.sh(小寫化、非 a-z0-9 字元轉連字號、合併連續連字號、去除頭尾連字號),並在 SKILL.md 步驟 3.2 改為呼叫此腳本;同步更新 Rules 第 3 項,把「分支標題摘要」與「描述撰寫」都列為必須交由 sub agent 執行;把範例改成全英文;三份 plugin manifest 版本號同步升版以反映此次修改。 Who: 影響 jsc-git 的 pr 技能與其新增的 slugify.sh 工具,屬 pr 流程分支命名與稽核合規的功能性變更。 Co-Authored-By: Claude Sonnet 5 --- .claude-plugin/plugin.json | 2 +- .codex-plugin/plugin.json | 2 +- plugin.json | 2 +- skills/pr/SKILL.md | 4 ++-- tools/slugify.sh | 20 ++++++++++++++++++++ 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100755 tools/slugify.sh diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 3626e8b..1cd6538 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-git", - "version": "0.0.1", + "version": "0.0.2", "description": "Commit 分組認可與 Push Request 建立", "skills": "./skills", "author": { diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 8aaf802..b12513f 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-git", - "version": "0.0.1", + "version": "0.0.2", "description": "Commit 分組認可與 Push Request 建立", "skills": "./skills" } diff --git a/plugin.json b/plugin.json index 73278b6..d4ad52c 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "jsc-git", - "version": "0.0.1", + "version": "0.0.2", "description": "Commit 分組認可與 Push Request 建立", "skills": "./skills/" } diff --git a/skills/pr/SKILL.md b/skills/pr/SKILL.md index 1832ce9..c8b27d2 100644 --- a/skills/pr/SKILL.md +++ b/skills/pr/SKILL.md @@ -12,7 +12,7 @@ description: Commit all changes via jsc-git:commit, create a target branch named 3. Create the target branch from the remote base branch: 1. Take the type with the highest priority across all commits: `revert > fix > feat > perf > refactor > test > docs > style > chore`. 2. Summarize one title from all commit messages. - 3. Branch names allow **ASCII only**; always slugify as `{type}/{requirement or feature}-{title}`. Translate the requirement and title into a short English phrase first, then lowercase, replace every character outside `a-z0-9` with a hyphen, collapse consecutive hyphens, and trim leading and trailing hyphens (example: `feat/order-匯出報表` → `feat/order-export-report`). No spaces, parentheses, colons, or any non-ASCII character. + 3. Branch names allow **ASCII only**; always slugify as `{type}/{requirement or feature}-{title}`. Translate the requirement and title into a short English phrase first, then call `tools/slugify.sh {type} {phrase}` to produce the final slug (example: translate a non-English request to English first, then slugify — "export report" → export-report → feat/order-export-report). No spaces, parentheses, colons, or any non-ASCII character. 4. Run `git push -u origin {target branch}`. 5. Create the PR: `jsc-gitea/tools/gitea.sh pr-create {owner}/{repo} {target branch} {base branch} "{branch name}" {description file}`. - Title = branch name. @@ -26,4 +26,4 @@ description: Commit all changes via jsc-git:commit, create a target branch named 1. No template section may stay empty: fill the literal 「無」 when there is no plan page, analyze page, or prerequisite PR. 2. Take the plan page and analyze page links from the `jsc-sdlc` wiki pages; the analyze link must point at the work package heading anchor. -3. The description drafting details **MUST run as a sub agent**. +3. Branch title summarization (step 3.2) and description drafting MUST run as a sub agent. diff --git a/tools/slugify.sh b/tools/slugify.sh new file mode 100755 index 0000000..a83abf1 --- /dev/null +++ b/tools/slugify.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh +# slugify.sh — 把分支類型與描述轉成 ASCII 分支名 slug。 +# 用法: slugify.sh {type} {phrase} +# 規則: 全部轉小寫,非 a-z0-9 的字元換成連字號, +# 連續連字號合併成一個,並去除開頭與結尾的連字號。 +# 輸出: {type}/{slug}(例如: slugify.sh feat "export report" → feat/export-report) +set -u + +if [ "$#" -lt 2 ]; then + echo "用法: slugify.sh {type} {phrase}" >&2 + exit 1 +fi + +TYPE="$1" +shift +PHRASE="$*" + +slug=$(printf '%s' "$PHRASE" | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-z0-9]/-/g' -e 's/-\{2,\}/-/g' -e 's/^-//' -e 's/-$//') + +printf '%s/%s\n' "$TYPE" "$slug"