SuperAPI AI 工具集

new-compiler-feature

编程与开发

查看项目

更新于 10-16 11:26

技能介绍

New Compiler Feature Setup

在 dotnet/roslyn 中,从实现 PR 开始,为一个新的 C# 语言特性建立追踪。

重要:在执行任何更改前,先展示完整计划并取得用户明确确认。

幂等性:可安全重复运行。创建前会检查已有产物。可用它补齐缺失的部分。

先决条件

gh CLI 已认证,并具有 dotnet/roslyn 的写入权限(用 gh auth status 验证)

若先决条件不满足,不要继续。改为引导用户完成必要操作(安装 gh、认证等)。

阶段 1:收集

1.1 解析 PR

gh pr view <NUMBER> --repo dotnet/roslyn --json title,body,author,baseRefName,labels,number

从 PR 正文中提取(如果缺失则询问用户):

csharplang issue URL:https://github.com/dotnet/csharplang/issues/NNNN

Spec URL:https://github.com/dotnet/csharplang/blob/main/proposals/*.md

从元数据中提取:

Developer:PR 作者

Branch:PR base ref(features/* 或 main)

1.2 校验 csharplang issue

gh issue view <NUMBER> --repo dotnet/csharplang --json title,labels,assignees

如果该 issue 缺少 Proposal champion 标签,则中止。

从 assignees 中提取 LDM champ(如果有多人,询问用户选择)。

1.3 特性名称

提供两个候选,询问用户选择或编辑:

来自 spec 文件名(kebab-case → 可读文本)

来自 csharplang issue 标题(去掉 [Proposal]: 前缀)

此名称用于标签(Feature - <Name>)和测试计划标题。

1.4 评审者与 IDE buddy

询问用户(两者默认均为 "TBD")。

1.5 验证特性分支

如果 base ref ≠ main,验证其存在(为 API 调用对分支名进行 URL 编码)。如果缺失则警告。

1.6 收集相关 PR

始终包含输入 PR

解析正文中堆叠 PR 列表里的 #NNNN 引用;通过 gh pr view 验证每个都是 PR

搜索以同一特性分支为目标的开放 PR(如果不是 main)

去重;向用户展示列表以确认

1.7 检查已有产物

标签:gh label list --repo dotnet/roslyn --search "Feature - <Name>"

测试计划 issue:gh issue list --repo dotnet/roslyn --search "<csharplang_url>" --label "Area-Compilers" — 按正文中的 csharplang URL 匹配

特性状态行:在 docs/Language Feature Status.md 中 grep csharplang issue URL

状态 PR:gh pr list --repo dotnet/roslyn --head "feature-status/<spec-filename>" --state open

阶段 2:计划

展示所有已收集信息和计划操作。用 ✓ 标记已有产物。请求明确确认。

阶段 3:执行

3.1 创建特性标签

若已存在则跳过。颜色:2ad0ad。

gh label create "Feature - <Name>" --repo dotnet/roslyn --color "2ad0ad"

3.2 创建测试计划 issue

若已存在则跳过。指派给开发者和评审者(对外部贡献者的指派可能会静默失败,这没关系)。

gh issue create --repo dotnet/roslyn --title 'Test plan for "<Name>" feature' --body "Championed proposal: <csharplang_url>nSpec: <spec_url>nn(created by new-compiler-feature skill)" --label "Area-Compilers" --label "Feature - <Name>" ` --assignee "<developer>" --assignee "<reviewer1>" --assignee "<reviewer2>"

通过 GraphQL 将 issue 类型设为 "Feature":

Get issue type ID for "Feature"

gh api graphql -f query='{ repository(owner: "dotnet", name: "roslyn") { issueTypes(first: 20) { nodes { id name } } } }'

Get issue node ID, then update

gh api graphql -f query='mutation { updateIssue(input: {id: "<issueId>", issueTypeId: "<featureTypeId>"}) { issue { issueType { name } } } }'

3.3 给相关 PR 打标签

对每个 PR,如果尚未应用,添加 Feature - <Name> 标签。

3.4 评论相关 PR

对每个 PR,检查是否已存在包含确切测试计划 URL 的评论。如果没有:

gh pr comment <NUMBER> --repo dotnet/roslyn --body "Test plan: <test_plan_url>`n(created by new-compiler-feature skill)"

3.5 更新 Language Feature Status 页面

如果文件中已出现该 csharplang issue URL,则跳过。

行格式:

| <Title> | <branch_col> | In progress | <dev> | <reviewers> | <ide_buddy> | <ldm> |

分支列:特性分支使用 <short-name>;否则使用纯 main

评审者/IDE buddy:TBD 或 <user>(多个用逗号分隔)

插入到 Working Set C# 表中最后一个 "In progress" 行之后、第一个 "Merged" 行之前。如果没有 Merged 行,则追加到最后一行之后。

3.6 为特性状态更新创建 PR

如果已有开放 PR,则跳过。

当当前工作树干净且基于 main 时,在本地进行状态页编辑:

从 main 创建 feature-status/<spec-filename>。

在工作树中编辑 docs/Language Feature Status.md。

检查生成的 diff,并在提交或发布前向用户展示确切更改以供批准。

批准后,提交更改。在推送前取得明确许可,然后推送分支并创建 PR。

仅当工作树不干净或不是基于 main 时,使用 GitHub API:

Get latest main SHA

$mainSha = gh api repos/dotnet/roslyn/git/refs/heads/main --jq '.object.sha'

Create branch

gh api -X POST repos/dotnet/roslyn/git/refs -f ref="refs/heads/feature-status/<spec-filename>" -f sha="$mainSha"

Get current file content and SHA from main

$fileMeta = gh api "repos/dotnet/roslyn/contents/docs/Language Feature Status.md" --jq '{sha: .sha, content: .content}' | ConvertFrom-Json

Decode content, insert the new row, re-encode to base64, then update:

gh api -X PUT "repos/dotnet/roslyn/contents/docs/Language Feature Status.md" -f message='Track status for feature "<Name>"' -f branch="feature-status/<spec-filename>" -f sha="$($fileMeta.sha)" -f content="$newContentBase64"

Create PR

gh pr create --repo dotnet/roslyn --title 'Track status for feature "<Name>"' --body "Adds feature status tracking row.nn- csharplang issue: <csharplang_url>n- Test plan: <test_plan_url>nnFYI @<developer> @<reviewer(s)> @<ldm_champ>nn(created by new-compiler-feature skill)" --head "feature-status/<spec-filename>" --base main ` --label "Area-Compilers" --label "Documentation"

向用户展示 PR URL。

总结

✅ 特性 "<Name>" 设置完成

  • 标签:Feature - <Name>
  • 测试计划:<url>
  • 特性状态 PR:<url>
  • 已打标签并关联的 PR:#NNN, #NNN

错误处理

gh 命令失败 → 停止并报告

缺少 "Proposal champion" 标签 → 中止

缺少特性分支(非 main)→ 警告,让用户决定

创建前始终检查已有产物