@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.
- package/README.md +12 -7
- package/README.zh-CN.md +12 -7
- package/bin/cli.js +1 -1
- package/lib/version.js +2 -1
- package/package.json +1 -1
- package/templates/.agents/README.md +12 -0
- package/templates/.agents/README.zh-CN.md +12 -0
- package/templates/.agents/skills/analyze-task/SKILL.md +106 -105
- package/templates/.agents/skills/close-codescan/SKILL.md +64 -63
- package/templates/.agents/skills/close-dependabot/SKILL.md +71 -70
- package/templates/.agents/skills/create-issue/SKILL.md +55 -10
- package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +55 -10
- package/templates/.agents/skills/create-pr/SKILL.md +43 -6
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +43 -6
- package/templates/.agents/skills/create-release-note/SKILL.md +18 -11
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +18 -11
- package/templates/.agents/skills/create-task/SKILL.md +80 -78
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +7 -6
- package/templates/.agents/skills/implement-task/SKILL.md +7 -10
- package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +7 -10
- package/templates/.agents/skills/import-codescan/SKILL.md +54 -53
- package/templates/.agents/skills/import-dependabot/SKILL.md +57 -56
- package/templates/.agents/skills/import-issue/SKILL.md +58 -58
- package/templates/.agents/skills/init-labels/SKILL.md +8 -0
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +8 -0
- package/templates/.agents/skills/plan-task/SKILL.md +151 -149
- package/templates/.agents/skills/sync-issue/SKILL.md +252 -273
- package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +26 -48
- package/templates/.agents/skills/sync-pr/SKILL.md +5 -25
- package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +4 -24
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +1 -1
- package/templates/.claude/CLAUDE.md +13 -0
- package/templates/.claude/CLAUDE.zh-CN.md +13 -0
- package/templates/AGENTS.md +13 -0
- 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
|
-
|
|
126
|
+
### Updating agent-infra
|
|
127
127
|
|
|
128
128
|
```bash
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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.
|
|
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
|
-
|
|
126
|
+
### 更新 agent-infra
|
|
127
127
|
|
|
128
128
|
```bash
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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.
|
|
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
package/package.json
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
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
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
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
|
-
|
|
24
|
+
Note: `{task-id}` format is `TASK-{yyyyMMdd-HHmmss}`, for example `TASK-20260306-143022`
|
|
24
25
|
|
|
25
|
-
|
|
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
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
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
|
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
71
|
-
-
|
|
71
|
+
- **Analysis round**: Round {analysis-round}
|
|
72
|
+
- **Artifact file**: `{analysis-artifact}`
|
|
72
73
|
|
|
73
|
-
##
|
|
74
|
+
## Requirement Source
|
|
74
75
|
|
|
75
|
-
|
|
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
|
-
|
|
112
|
-
- `current_step
|
|
113
|
-
- `assigned_to
|
|
114
|
-
- `updated_at
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
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
|
-
>
|
|
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
|
-
|
|
130
|
+
Analysis complete for task {task-id}.
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
132
|
+
Summary:
|
|
133
|
+
- Analysis round: Round {analysis-round}
|
|
134
|
+
- Related files: {count}
|
|
135
|
+
- Risk level: {assessment}
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
-
|
|
137
|
+
Output file:
|
|
138
|
+
- Analysis report: .agent-workspace/active/{task-id}/{analysis-artifact}
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
- Claude Code / OpenCode
|
|
141
|
-
- Gemini CLI
|
|
142
|
-
- Codex CLI
|
|
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
|
-
- [ ]
|
|
149
|
-
- [ ]
|
|
150
|
-
- [ ]
|
|
151
|
-
- [ ]
|
|
152
|
-
- [ ]
|
|
153
|
-
- [ ]
|
|
154
|
-
- [ ]
|
|
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
|
-
|
|
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.
|
|
164
|
-
2.
|
|
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
|
-
-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
#
|
|
9
|
+
# Dismiss Code Scanning Alert
|
|
9
10
|
|
|
10
|
-
|
|
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
|
-
|
|
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
|
|
26
|
+
Code Scanning alert #{alert-number}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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.
|
|
39
|
-
2.
|
|
40
|
-
3.
|
|
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
|
-
-
|
|
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
|
-
|
|
55
|
+
About to dismiss Code Scanning alert #{alert-number}:
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
Rule: {rule.id}
|
|
58
|
+
Location: {location.path}:{location.start_line}
|
|
59
|
+
Reason: {selected reason}
|
|
60
|
+
Explanation: {user explanation}
|
|
60
61
|
|
|
61
|
-
|
|
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
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
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
|
-
|
|
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
|
-
-
|
|
89
|
-
-
|
|
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
|
|
99
|
+
Code Scanning alert #{alert-number} dismissed.
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
Rule: {rule.id}
|
|
102
|
+
Location: {location.path}:{location.start_line}
|
|
103
|
+
Reason: {reason}
|
|
104
|
+
Explanation: {explanation}
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
View: {html_url}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
Note: it can be reopened on GitHub if necessary.
|
|
108
109
|
```
|
|
109
110
|
|
|
110
|
-
##
|
|
111
|
+
## Notes
|
|
111
112
|
|
|
112
|
-
1.
|
|
113
|
-
2.
|
|
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
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
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"
|