@fitlab-ai/agent-infra 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +12 -7
  2. package/README.zh-CN.md +12 -7
  3. package/bin/cli.js +1 -1
  4. package/lib/version.js +2 -1
  5. package/package.json +1 -1
  6. package/templates/.agents/README.md +12 -0
  7. package/templates/.agents/README.zh-CN.md +12 -0
  8. package/templates/.agents/skills/analyze-task/SKILL.md +106 -105
  9. package/templates/.agents/skills/close-codescan/SKILL.md +64 -63
  10. package/templates/.agents/skills/close-dependabot/SKILL.md +71 -70
  11. package/templates/.agents/skills/create-issue/SKILL.md +55 -10
  12. package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +55 -10
  13. package/templates/.agents/skills/create-pr/SKILL.md +43 -6
  14. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +43 -6
  15. package/templates/.agents/skills/create-release-note/SKILL.md +18 -11
  16. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +18 -11
  17. package/templates/.agents/skills/create-task/SKILL.md +80 -78
  18. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +7 -6
  19. package/templates/.agents/skills/implement-task/SKILL.md +7 -10
  20. package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +7 -10
  21. package/templates/.agents/skills/import-codescan/SKILL.md +54 -53
  22. package/templates/.agents/skills/import-dependabot/SKILL.md +57 -56
  23. package/templates/.agents/skills/import-issue/SKILL.md +58 -58
  24. package/templates/.agents/skills/init-labels/SKILL.md +8 -0
  25. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +8 -0
  26. package/templates/.agents/skills/plan-task/SKILL.md +151 -149
  27. package/templates/.agents/skills/sync-issue/SKILL.md +252 -273
  28. package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +26 -48
  29. package/templates/.agents/skills/sync-pr/SKILL.md +5 -25
  30. package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +4 -24
  31. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +1 -1
  32. package/templates/.claude/CLAUDE.md +13 -0
  33. package/templates/.claude/CLAUDE.zh-CN.md +13 -0
  34. package/templates/AGENTS.md +13 -0
  35. package/templates/AGENTS.zh-CN.md +13 -0
package/README.md CHANGED
@@ -114,21 +114,26 @@ These are not thin command aliases. Each skill encapsulates standardized process
114
114
 
115
115
  ```bash
116
116
  npm install -g @fitlab-ai/agent-infra
117
- npx @fitlab-ai/agent-infra init
118
117
  ```
119
118
 
120
119
  **Option B - Shell script**
121
120
 
122
121
  ```bash
122
+ # Convenience wrapper — detects Node.js and runs npm install -g internally
123
123
  curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh
124
124
  ```
125
125
 
126
- **Option C - Install from source**
126
+ ### Updating agent-infra
127
127
 
128
128
  ```bash
129
- git clone https://github.com/fitlab-ai/agent-infra.git
130
- cd agent-infra
131
- sh install.sh
129
+ npm update -g @fitlab-ai/agent-infra
130
+ ```
131
+
132
+ Check your current version:
133
+
134
+ ```bash
135
+ ai version
136
+ # or: agent-infra version
132
137
  ```
133
138
 
134
139
  ### 2. Initialize a new project
@@ -164,7 +169,7 @@ agent-infra is intentionally simple: a bootstrap CLI creates the seed configurat
164
169
 
165
170
  ### End-to-End Flow
166
171
 
167
- 1. **Install** — `npm install -g @fitlab-ai/agent-infra` (or use the shell script)
172
+ 1. **Install** — `npm install -g @fitlab-ai/agent-infra` (or use the shell script wrapper)
168
173
  2. **Initialize** — `ai init` in the project root to generate `.airc.json` and install the seed command
169
174
  3. **Render** — run `update-agent-infra` in any AI TUI to pull templates and generate all managed files
170
175
  4. **Develop** — use 28 built-in skills to drive the full lifecycle: `analysis → design → implementation → review → fix → commit`
@@ -380,7 +385,7 @@ The generated `.airc.json` file is the central contract between the bootstrap CL
380
385
  "org": "my-org",
381
386
  "language": "en",
382
387
  "templateSource": "templates/",
383
- "templateVersion": "v0.3.1",
388
+ "templateVersion": "v0.3.2",
384
389
  "modules": ["ai", "github"],
385
390
  "files": {
386
391
  "managed": [
package/README.zh-CN.md CHANGED
@@ -114,21 +114,26 @@ agent-infra 的目标就是把这层协作面标准化。它为所有支持的 A
114
114
 
115
115
  ```bash
116
116
  npm install -g @fitlab-ai/agent-infra
117
- npx @fitlab-ai/agent-infra init
118
117
  ```
119
118
 
120
119
  **方式 B - Shell 脚本**
121
120
 
122
121
  ```bash
122
+ # 便捷封装:检测 Node.js 后,内部执行 npm install -g
123
123
  curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh
124
124
  ```
125
125
 
126
- **方式 C - 从源码安装**
126
+ ### 更新 agent-infra
127
127
 
128
128
  ```bash
129
- git clone https://github.com/fitlab-ai/agent-infra.git
130
- cd agent-infra
131
- sh install.sh
129
+ npm update -g @fitlab-ai/agent-infra
130
+ ```
131
+
132
+ 查看当前版本:
133
+
134
+ ```bash
135
+ ai version
136
+ # 或:agent-infra version
132
137
  ```
133
138
 
134
139
  ### 2. 初始化新项目
@@ -164,7 +169,7 @@ agent-infra 的结构刻意保持简单:引导 CLI 负责生成种子配置,
164
169
 
165
170
  ### 端到端流程
166
171
 
167
- 1. **安装** — `npm install -g @fitlab-ai/agent-infra`(或使用 shell 脚本)
172
+ 1. **安装** — `npm install -g @fitlab-ai/agent-infra`(或使用 shell 脚本便捷封装)
168
173
  2. **初始化** — 在项目根目录运行 `ai init`,生成 `.airc.json` 并安装种子命令
169
174
  3. **渲染** — 在任意 AI TUI 中执行 `update-agent-infra`,拉取模板并生成所有受管理文件
170
175
  4. **开发** — 使用 28 个内置 skill 驱动完整生命周期:`analysis → design → implementation → review → fix → commit`
@@ -380,7 +385,7 @@ import-issue #42 从 GitHub Issue 导入任务
380
385
  "org": "my-org",
381
386
  "language": "en",
382
387
  "templateSource": "templates/",
383
- "templateVersion": "v0.3.1",
388
+ "templateVersion": "v0.3.2",
384
389
  "modules": ["ai", "github"],
385
390
  "files": {
386
391
  "managed": [
package/bin/cli.js CHANGED
@@ -23,7 +23,7 @@ Shorthand: ai (e.g. ai init)
23
23
  Install methods:
24
24
  npm: npm install -g @fitlab-ai/agent-infra
25
25
  npx: npx @fitlab-ai/agent-infra init
26
- curl: curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh
26
+ curl: curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh (runs npm install -g internally)
27
27
 
28
28
  Examples:
29
29
  cd my-project && agent-infra init
package/lib/version.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
 
3
- const { version: VERSION } = JSON.parse(
3
+ const { version } = JSON.parse(
4
4
  readFileSync(new URL('../package.json', import.meta.url), 'utf8')
5
5
  );
6
+ const VERSION = `v${version}`;
6
7
 
7
8
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fitlab-ai/agent-infra",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Bootstrap tool for AI multi-tool collaboration infrastructure — works with Claude Code, Codex, Gemini CLI, and OpenCode",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -100,6 +100,18 @@ Each AI tool has different strengths. Use them accordingly:
100
100
  4. **Run the workflow**: Follow the appropriate workflow in `.agents/workflows/`.
101
101
  5. **Hand off**: When switching AIs, create a handoff document from the template.
102
102
 
103
+ ## Label Conventions
104
+
105
+ GitHub Labels in this project use the following prefixes, each with a defined scope:
106
+
107
+ | Label prefix | Issue | PR | Notes |
108
+ |---|---|---|---|
109
+ | `type:` | — | Yes | Issues use the native GitHub Type field; PRs use `type:` labels for changelog generation and categorization |
110
+ | `status:` | Yes | — | PRs already have their own state flow (Open / Draft / Merged / Closed); Issues use `status:` labels for project tracking states |
111
+ | `in:` | Yes | Yes | Both Issues and PRs can be filtered by module |
112
+
113
+ Initialize the label set with the `/init-labels` command.
114
+
103
115
  ## Skill Authoring Conventions
104
116
 
105
117
  When writing or updating `.agents/skills/*/SKILL.md` files and their templates, keep step numbering consistent:
@@ -100,6 +100,18 @@
100
100
  4. **执行工作流**:按照 `.agents/workflows/` 中相应的工作流执行。
101
101
  5. **交接**:切换 AI 时,从模板创建交接文档。
102
102
 
103
+ ## Label 规范
104
+
105
+ 本项目的 GitHub Labels 按以下前缀分类,各前缀有明确的适用范围:
106
+
107
+ | Label 前缀 | Issue | PR | 说明 |
108
+ |---|---|---|---|
109
+ | `type:` | — | Yes | Issue 使用 GitHub 原生 Type 字段;PR 无原生类型字段,通过 `type:` label 驱动 changelog 和分类 |
110
+ | `status:` | Yes | — | PR 有自身状态流转(Open / Draft / Merged / Closed);Issue 使用 `status:` label 标记等待反馈、已确认等项目管理状态 |
111
+ | `in:` | Yes | Yes | Issue 和 PR 均可按模块筛选 |
112
+
113
+ 初始化 Label 体系:使用 `/init-labels` 命令一次性创建标准 labels。
114
+
103
115
  ## Skill 编写规范
104
116
 
105
117
  编写或维护 `.agents/skills/*/SKILL.md` 及其模板时,步骤编号遵循以下规则:
@@ -1,169 +1,170 @@
1
1
  ---
2
2
  name: analyze-task
3
3
  description: >
4
- 分析已有任务并输出需求分析文档,支持多轮分析产物(analysis.md / analysis-r{N}.md)。
5
- 当用户要求分析某个任务时触发。参数:task-id。
4
+ Analyze an existing task and output a requirements analysis document,
5
+ supporting multi-round artifacts (`analysis.md` / `analysis-r{N}.md`).
6
+ Triggered when the user asks to analyze a task. Argument: task-id.
6
7
  ---
7
8
 
8
- # 分析任务
9
+ # Analyze Task
9
10
 
10
- ## 行为边界 / 关键规则
11
+ ## Boundary / Critical Rules
11
12
 
12
- - 本技能仅产出需求分析文档(`analysis.md` `analysis-r{N}.md`)—— 不修改任何业务代码
13
- - 严格基于 `task.md` 中已有的需求、上下文和来源信息展开分析
14
- - 执行本技能后,你**必须**立即更新 task.md 中的任务状态
13
+ - This skill only outputs a requirements analysis document (`analysis.md` or `analysis-r{N}.md`) and does not modify any business code
14
+ - Base the analysis strictly on the existing requirements, context, and source information in `task.md`
15
+ - After executing this skill, you **must** immediately update task status in task.md
15
16
 
16
- ## 执行步骤
17
+ ## Steps
17
18
 
18
- ### 1. 验证前置条件
19
+ ### 1. Verify Prerequisites
19
20
 
20
- 检查必要文件:
21
- - `.agent-workspace/active/{task-id}/task.md` - 任务文件
21
+ Check required files:
22
+ - `.agent-workspace/active/{task-id}/task.md` - Task file
22
23
 
23
- 注意:`{task-id}` 格式为 `TASK-{yyyyMMdd-HHmmss}`,例如 `TASK-20260306-143022`
24
+ Note: `{task-id}` format is `TASK-{yyyyMMdd-HHmmss}`, for example `TASK-20260306-143022`
24
25
 
25
- 如果缺少 `task.md`,提示用户先创建或导入任务。
26
+ If `task.md` is missing, tell the user to create or import the task first.
26
27
 
27
- ### 2. 确定分析轮次
28
+ ### 2. Determine the Analysis Round
28
29
 
29
- 扫描 `.agent-workspace/active/{task-id}/` 目录中的分析产物文件:
30
- - 如果不存在 `analysis.md` 且不存在 `analysis-r*.md` 本轮为第 1 轮,产出 `analysis.md`
31
- - 如果存在 `analysis.md` 且不存在 `analysis-r*.md` 本轮为第 2 轮,产出 `analysis-r2.md`
32
- - 如果存在 `analysis-r{N}.md` 本轮为第 N+1 轮,产出 `analysis-r{N+1}.md`
30
+ Scan `.agent-workspace/active/{task-id}/` for analysis artifact files:
31
+ - If neither `analysis.md` nor `analysis-r*.md` exists -> this is Round 1 and must create `analysis.md`
32
+ - If `analysis.md` exists and no `analysis-r*.md` exists -> this is Round 2 and must create `analysis-r2.md`
33
+ - If `analysis-r{N}.md` exists -> this is Round N+1 and must create `analysis-r{N+1}.md`
33
34
 
34
- 记录:
35
- - `{analysis-round}`:本轮分析轮次
36
- - `{analysis-artifact}`:本轮分析产物文件名
35
+ Record:
36
+ - `{analysis-round}`: the current analysis round
37
+ - `{analysis-artifact}`: the artifact filename for this round
37
38
 
38
- ### 3. 阅读任务上下文
39
+ ### 3. Read Task Context
39
40
 
40
- 仔细阅读 `task.md` 以理解:
41
- - 任务标题、描述和需求列表
42
- - 上下文信息(IssuePR、分支、告警编号等)
43
- - 当前已知的受影响文件和约束
41
+ Read `task.md` carefully to understand:
42
+ - task title, description, and requirement list
43
+ - context information (Issue, PR, branch, alert numbers, etc.)
44
+ - currently known affected files and constraints
44
45
 
45
- `task.md` 包含以下来源字段,补充读取对应来源信息:
46
+ If `task.md` contains these source fields, also read the corresponding source information:
46
47
  - `issue_number` - GitHub Issue
47
- - `codescan_alert_number` - Code Scanning 告警
48
- - `security_alert_number` - Dependabot 告警
48
+ - `codescan_alert_number` - Code Scanning alert
49
+ - `security_alert_number` - Dependabot alert
49
50
 
50
- ### 4. 执行需求分析
51
+ ### 4. Perform Requirements Analysis
51
52
 
52
- 遵循 `.agents/workflows/feature-development.yaml` 中的 `analysis` 步骤:
53
+ Follow the `analysis` step in `.agents/workflows/feature-development.yaml`:
53
54
 
54
- **必要任务**(仅分析,不编写业务代码):
55
- - [ ] 理解任务需求和目标
56
- - [ ] 搜索相关代码文件(**只读**)
57
- - [ ] 分析代码结构和影响范围
58
- - [ ] 识别潜在技术风险和依赖
59
- - [ ] 评估工作量和复杂度
55
+ **Required tasks** (analysis only, no business code changes):
56
+ - [ ] Understand the task requirements and goals
57
+ - [ ] Search related code files (**read-only**)
58
+ - [ ] Analyze code structure and impact scope
59
+ - [ ] Identify potential technical risks and dependencies
60
+ - [ ] Assess effort and complexity
60
61
 
61
- ### 5. 输出分析文档
62
+ ### 5. Output Analysis Document
62
63
 
63
- 创建 `.agent-workspace/active/{task-id}/{analysis-artifact}`。
64
+ Create `.agent-workspace/active/{task-id}/{analysis-artifact}`.
64
65
 
65
- ## 输出模板
66
+ ## Output Template
66
67
 
67
68
  ```markdown
68
- # 需求分析报告
69
+ # Requirements Analysis Report
69
70
 
70
- - **分析轮次**:Round {analysis-round}
71
- - **产物文件**:`{analysis-artifact}`
71
+ - **Analysis round**: Round {analysis-round}
72
+ - **Artifact file**: `{analysis-artifact}`
72
73
 
73
- ## 需求来源
74
+ ## Requirement Source
74
75
 
75
- **来源类型**:{用户描述 / GitHub Issue / Code Scanning / Dependabot / 其他}
76
- **来源摘要**:
77
- > {任务来源或关键上下文}
76
+ **Source type**: {User description / GitHub Issue / Code Scanning / Dependabot / Other}
77
+ **Source summary**:
78
+ > {Task source or key context}
78
79
 
79
- ## 需求理解
80
- {用自己的话重述需求以确认理解}
80
+ ## Requirement Understanding
81
+ {Restate the requirement in your own words to confirm understanding}
81
82
 
82
- ## 相关文件
83
- - `{file-path}:{line-number}` - {描述}
83
+ ## Related Files
84
+ - `{file-path}:{line-number}` - {Description}
84
85
 
85
- ## 影响评估
86
- **直接影响**:
87
- - {受影响的模块和文件}
86
+ ## Impact Assessment
87
+ **Direct impact**:
88
+ - {Affected modules and files}
88
89
 
89
- **间接影响**:
90
- - {可能受影响的其他部分}
90
+ **Indirect impact**:
91
+ - {Other parts that may be affected}
91
92
 
92
- ## 技术风险
93
- - {风险描述和缓解思路}
93
+ ## Technical Risks
94
+ - {Risk description and mitigation idea}
94
95
 
95
- ## 依赖关系
96
- - {需要的依赖和与其他模块的协调}
96
+ ## Dependencies
97
+ - {Required dependencies and coordination with other modules}
97
98
 
98
- ## 工作量和复杂度评估
99
- - 复杂度:{高/中/低}
100
- - 风险等级:{高/中/低}
99
+ ## Effort and Complexity Assessment
100
+ - Complexity: {High/Medium/Low}
101
+ - Risk level: {High/Medium/Low}
101
102
  ```
102
103
 
103
- ### 6. 更新任务状态
104
+ ### 6. Update Task Status
104
105
 
105
- 获取当前时间:
106
+ Get the current time:
106
107
 
107
108
  ```bash
108
109
  date "+%Y-%m-%d %H:%M:%S"
109
110
  ```
110
111
 
111
- 更新 `.agent-workspace/active/{task-id}/task.md`:
112
- - `current_step`:requirement-analysis
113
- - `assigned_to`:{当前 AI 代理}
114
- - `updated_at`:{当前时间}
115
- - 记录本轮分析产物:`{analysis-artifact}`(Round `{analysis-round}`)
116
- - 如任务模板包含 `## 分析` 段落,更新为指向 `{analysis-artifact}` 的链接
117
- - 在工作流进度中标记 requirement-analysis 为已完成,并注明实际轮次(如果任务模板支持)
118
- - **追加**到 `## Activity Log`(不要覆盖之前的记录):
112
+ Update `.agent-workspace/active/{task-id}/task.md`:
113
+ - `current_step`: requirement-analysis
114
+ - `assigned_to`: {current AI agent}
115
+ - `updated_at`: {current time}
116
+ - Record the analysis artifact for this round: `{analysis-artifact}` (Round `{analysis-round}`)
117
+ - If the task template contains a `## Analysis` section, update it to link to `{analysis-artifact}`
118
+ - Mark requirement-analysis as complete in workflow progress and include the actual round when the task template supports it
119
+ - **Append** to `## Activity Log` (do NOT overwrite previous entries):
119
120
  ```
120
121
  - {yyyy-MM-dd HH:mm:ss} — **Requirement Analysis (Round {N})** by {agent} — Analysis completed → {analysis-artifact}
121
122
  ```
122
123
 
123
- ### 7. 告知用户
124
+ ### 7. Inform User
124
125
 
125
- > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
126
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
126
127
 
127
- 输出格式:
128
+ Output format:
128
129
  ```
129
- 任务 {task-id} 分析完成。
130
+ Analysis complete for task {task-id}.
130
131
 
131
- 摘要:
132
- - 分析轮次:Round {analysis-round}
133
- - 相关文件:{数量}
134
- - 风险等级:{评估}
132
+ Summary:
133
+ - Analysis round: Round {analysis-round}
134
+ - Related files: {count}
135
+ - Risk level: {assessment}
135
136
 
136
- 产出文件:
137
- - 分析报告:.agent-workspace/active/{task-id}/{analysis-artifact}
137
+ Output file:
138
+ - Analysis report: .agent-workspace/active/{task-id}/{analysis-artifact}
138
139
 
139
- 下一步 - 设计技术方案:
140
- - Claude Code / OpenCode:/plan-task {task-id}
141
- - Gemini CLI:/agent-infra:plan-task {task-id}
142
- - Codex CLI:$plan-task {task-id}
140
+ Next step - create technical plan:
141
+ - Claude Code / OpenCode: /plan-task {task-id}
142
+ - Gemini CLI: /{{project}}:plan-task {task-id}
143
+ - Codex CLI: $plan-task {task-id}
143
144
  ```
144
145
 
145
- ## 完成检查清单
146
+ ## Completion Checklist
146
147
 
147
- - [ ] 阅读并理解了任务文件和来源信息
148
- - [ ] 创建了分析文档 `.agent-workspace/active/{task-id}/{analysis-artifact}`
149
- - [ ] 更新了 task.md 中的 `current_step` requirement-analysis
150
- - [ ] 更新了 task.md 中的 `updated_at` 为当前时间
151
- - [ ] 更新了 task.md 中的 `assigned_to`
152
- - [ ] 追加了 Activity Log 条目到 task.md
153
- - [ ] 在工作流进度中标记了 requirement-analysis 为已完成
154
- - [ ] 告知了用户下一步(必须展示所有 TUI 的命令格式,不要筛选)
155
- - [ ] **没有修改任何业务代码**
148
+ - [ ] Read and understood the task file and source information
149
+ - [ ] Created analysis document `.agent-workspace/active/{task-id}/{analysis-artifact}`
150
+ - [ ] Updated `current_step` to requirement-analysis in task.md
151
+ - [ ] Updated `updated_at` to the current time in task.md
152
+ - [ ] Updated `assigned_to` in task.md
153
+ - [ ] Appended an Activity Log entry to task.md
154
+ - [ ] Marked requirement-analysis as complete in workflow progress
155
+ - [ ] Informed the user of the next step (must include all TUI command formats; do not filter)
156
+ - [ ] **Did not modify any business code**
156
157
 
157
- ## 停止
158
+ ## STOP
158
159
 
159
- 完成检查清单后,**立即停止**。等待用户审查分析结果并手动调用 `plan-task` 技能。
160
+ After completing the checklist, **stop immediately**. Wait for the user to review the analysis result and manually invoke the `plan-task` skill.
160
161
 
161
- ## 注意事项
162
+ ## Notes
162
163
 
163
- 1. **前置条件**:必须已存在任务文件 `task.md`
164
- 2. **多轮分析**:需求变化或已有分析需要修订时,使用 `analysis-r{N}.md`
165
- 3. **职责单一**:本技能只负责分析,不设计方案、不实现代码
164
+ 1. **Prerequisite**: the task file `task.md` must already exist
165
+ 2. **Multi-round analysis**: use `analysis-r{N}.md` when requirements change or an existing analysis needs revision
166
+ 3. **Single responsibility**: this skill only handles analysis, not planning or implementation
166
167
 
167
- ## 错误处理
168
+ ## Error Handling
168
169
 
169
- - 任务未找到:提示 "Task {task-id} not found, please check the task ID"
170
+ - Task not found: output "Task {task-id} not found, please check the task ID"
@@ -1,122 +1,123 @@
1
1
  ---
2
2
  name: close-codescan
3
3
  description: >
4
- 关闭 Code ScanningCodeQL)告警并提供有据可查的理由。
5
- 当用户要求关闭 Code Scanning 告警时触发。参数:告警编号。
4
+ Dismiss a Code Scanning (CodeQL) alert with a documented justification.
5
+ Triggered when the user asks to dismiss a Code Scanning alert.
6
+ Argument: alert number.
6
7
  ---
7
8
 
8
- # 关闭 Code Scanning 告警
9
+ # Dismiss Code Scanning Alert
9
10
 
10
- 关闭指定的 Code ScanningCodeQL)告警并记录合理的关闭理由。
11
+ Dismiss the specified Code Scanning (CodeQL) alert and record a justified reason.
11
12
 
12
- ## 执行流程
13
+ ## Execution Flow
13
14
 
14
- ### 1. 获取告警信息
15
+ ### 1. Retrieve Alert Information
15
16
 
16
17
  ```bash
17
18
  gh api repos/{owner}/{repo}/code-scanning/alerts/<alert-number>
18
19
  ```
19
20
 
20
- 验证告警处于 `open` 状态。如果已被关闭/修复,告知用户并退出。
21
+ Verify that the alert is in the `open` state. If it is already dismissed or fixed, inform the user and exit.
21
22
 
22
- ### 2. 展示告警详情
23
+ ### 2. Show Alert Details
23
24
 
24
25
  ```
25
- Code Scanning 告警 #{alert-number}
26
+ Code Scanning alert #{alert-number}
26
27
 
27
- 严重程度:{security_severity_level}
28
- 规则:{rule.id} - {rule.description}
29
- 扫描工具:{tool.name}
30
- 位置:{location.path}:{location.start_line}
31
- 消息:{message}
28
+ Severity: {security_severity_level}
29
+ Rule: {rule.id} - {rule.description}
30
+ Scanner: {tool.name}
31
+ Location: {location.path}:{location.start_line}
32
+ Message: {message}
32
33
  ```
33
34
 
34
- ### 3. 询问关闭理由
35
+ ### 3. Ask for the Dismissal Reason
35
36
 
36
- 提示用户选择理由:
37
+ Ask the user to choose a reason:
37
38
 
38
- 1. **误报 (False Positive)** - CodeQL 规则误判;代码不存在此安全问题
39
- 2. **不会修复 (Won't Fix)** - 已知问题但基于架构或业务原因不予修复
40
- 3. **测试代码 (Used in Tests)** - 仅在测试代码中出现,不影响生产环境安全
41
- 4. **取消** - 不关闭告警
39
+ 1. **False Positive** - the CodeQL rule misfired and the code does not contain the security issue
40
+ 2. **Won't Fix** - the issue is known but will not be fixed due to architectural or business reasons
41
+ 3. **Used in Tests** - the issue appears only in test code and does not affect production security
42
+ 4. **Cancel** - do not dismiss the alert
42
43
 
43
- ### 4. 要求详细说明
44
+ ### 4. Require a Detailed Explanation
44
45
 
45
- 如果用户选择关闭(非取消),要求提供详细说明:
46
- - 最少 20 个字符
47
- - 必须清楚说明为什么可以安全关闭该告警
48
- - 如果是误报,说明为什么代码不存在该安全问题
49
- - 如果是不修复,说明技术或业务原因
46
+ If the user chooses to dismiss the alert (not cancel), require a detailed explanation:
47
+ - at least 20 characters
48
+ - must clearly explain why the alert can be safely dismissed
49
+ - if it is a false positive, explain why the code does not contain the issue
50
+ - if it is won't fix, explain the technical or business reason
50
51
 
51
- ### 5. 最终确认
52
+ ### 5. Final Confirmation
52
53
 
53
54
  ```
54
- 即将关闭 Code Scanning 告警 #{alert-number}
55
+ About to dismiss Code Scanning alert #{alert-number}:
55
56
 
56
- 规则:{rule.id}
57
- 位置:{location.path}:{location.start_line}
58
- 原因:{选择的理由}
59
- 说明:{用户的说明}
57
+ Rule: {rule.id}
58
+ Location: {location.path}:{location.start_line}
59
+ Reason: {selected reason}
60
+ Explanation: {user explanation}
60
61
 
61
- 确认?(y/N)
62
+ Confirm? (y/N)
62
63
  ```
63
64
 
64
- ### 6. 执行关闭
65
+ ### 6. Execute the Dismissal
65
66
 
66
67
  ```bash
67
68
  gh api --method PATCH \
68
69
  repos/{owner}/{repo}/code-scanning/alerts/<alert-number> \
69
70
  -f state=dismissed \
70
71
  -f dismissed_reason="{api-reason}" \
71
- -f dismissed_comment="{用户的说明}"
72
+ -f dismissed_comment="{user explanation}"
72
73
  ```
73
74
 
74
- **API reason 映射**(按 GitHub Code Scanning API):
75
- - 误报 -> `false positive`
76
- - 不会修复 -> `won't fix`
77
- - 测试代码 -> `used in tests`
75
+ **API reason mapping** (per the GitHub Code Scanning API):
76
+ - False Positive -> `false positive`
77
+ - Won't Fix -> `won't fix`
78
+ - Used in Tests -> `used in tests`
78
79
 
79
- ### 7. 记录到任务(如存在)
80
+ ### 7. Record in the Task (If Any)
80
81
 
81
- 如果有关联任务(搜索 `codescan_alert_number: <alert-number>`):
82
- 获取当前时间:
82
+ If a related task exists (search for `codescan_alert_number: <alert-number>`):
83
+ Get the current time:
83
84
 
84
85
  ```bash
85
86
  date "+%Y-%m-%d %H:%M:%S"
86
87
  ```
87
88
 
88
- - 添加关闭记录到 task.md
89
- - **追加**到 `## Activity Log`(不要覆盖之前的记录):
89
+ - Add the dismissal record to task.md
90
+ - **Append** to `## Activity Log` (do NOT overwrite previous entries):
90
91
  ```
91
92
  - {yyyy-MM-dd HH:mm:ss} — **Alert Closed** by {agent} — Code Scanning alert #{alert-number} dismissed: {reason}
92
93
  ```
93
- - 归档任务
94
+ - Archive the task
94
95
 
95
- ### 8. 告知用户
96
+ ### 8. Inform User
96
97
 
97
98
  ```
98
- Code Scanning 告警 #{alert-number} 已关闭。
99
+ Code Scanning alert #{alert-number} dismissed.
99
100
 
100
- 规则:{rule.id}
101
- 位置:{location.path}:{location.start_line}
102
- 原因:{reason}
103
- 说明:{explanation}
101
+ Rule: {rule.id}
102
+ Location: {location.path}:{location.start_line}
103
+ Reason: {reason}
104
+ Explanation: {explanation}
104
105
 
105
- 查看:{html_url}
106
+ View: {html_url}
106
107
 
107
- 注意:如有需要,可在 GitHub 上重新打开。
108
+ Note: it can be reopened on GitHub if necessary.
108
109
  ```
109
110
 
110
- ## 注意事项
111
+ ## Notes
111
112
 
112
- 1. **谨慎处理高严重程度告警**:Critical/High 告警需要充分分析。建议先执行 import-codescan + analyze-task
113
- 2. **真实的理由**:关闭记录保存在 GitHub 中,可能会被审计。
114
- 3. **定期复查**:已关闭的告警应定期复查。
115
- 4. **优先修复**:关闭应作为最后手段。
113
+ 1. **Handle high-severity alerts carefully**: Critical/High alerts require thorough analysis. Prefer `import-codescan` + `analyze-task` first.
114
+ 2. **Use truthful reasons**: dismissal records are stored in GitHub and may be audited.
115
+ 3. **Review periodically**: dismissed alerts should be re-evaluated over time.
116
+ 4. **Fix first**: dismissal should be the last resort.
116
117
 
117
- ## 错误处理
118
+ ## Error Handling
118
119
 
119
- - 告警未找到:提示 "Code Scanning alert #{number} not found"
120
- - 已关闭:提示 "Alert #{number} is already {state}"
121
- - 权限错误:提示 "No permission to modify alerts"
122
- - 用户取消:提示 "Cancellation acknowledged"
120
+ - Alert not found: output "Code Scanning alert #{number} not found"
121
+ - Already closed: output "Alert #{number} is already {state}"
122
+ - Permission error: output "No permission to modify alerts"
123
+ - User canceled: output "Cancellation acknowledged"