feat: add generic gitea issue-drive skills

This commit is contained in:
zfc
2026-03-12 15:53:26 +08:00
parent b36220b33a
commit 22765a2917
15 changed files with 1681 additions and 109 deletions
+94 -33
View File
@@ -1,37 +1,73 @@
---
name: issue
description: 获取任意 Gitea 仓库的 issue 列表和单条详情,支持状态筛选、完整仓库 URL 输入和格式化输出。
description: 查看当前仓库或任意 Gitea 仓库的 issue 列表和单条详情,支持自动识别 git origin、用户指定仓库、状态筛选和格式化输出。
---
# Issue - 通用 Gitea Issue 查看
> **定位**输入完整 Gitea 仓库 URL,快速查看 issue 列表单条详情。默认只输出事实结果,不主动扩展成 roadmap、主题归纳或优先级分析
> **定位**这是只读 skill。用于查看当前仓库或指定仓库的 issue 列表单条详情和评论,不负责拆单和创建工单
>
> 如果用户要做的是“把问题拆成 issue 并实际创建工单”,不要使用本 skill,改用 `issue-drive`。
当用户调用 `/issue <repo-url>``/issue <repo-url> --state=open|closed|all --limit=<N>``/issue <repo-url> <issue-number>``$issue <repo-url>``$issue <repo-url> --state=open|closed|all --limit=<N>``$issue <repo-url> <issue-number>`,或自然语言要求“用 issue skill 查看某个 Gitea 仓库的问题”时,执行以下步骤。
当用户调用 `/issue``$issue`,或自然语言要求“查看当前仓库 issue”“看某个 Gitea 仓库的 issue”“查 issue #17”时,执行以下步骤。
## 1. 解析输入
- `repo-url` 必须是完整仓库地址,例如 `https://git.example.com/owner/repo`
- 允许尾部带 `/``.git`,先规范化后再解析
支持以下几种目标仓库写法:
- 不传仓库参数:默认使用当前项目的 `git remote get-url origin`
- 完整仓库 URL`https://git.example.com/owner/repo`
- 仓库简写:`owner/repo`
- 当前仓库 + 单条 issue`/issue 17`
- 指定仓库 + 单条 issue`/issue owner/repo 17``/issue https://git.example.com/owner/repo 17`
同时支持:
- `--state=open|closed|all`,默认 `open`
- `--limit=<N>`,默认 `50`
解析规则:
- 第二个位置参数如果是纯数字,视为 `issue-number`,进入详情模式
- `--state` 仅支持 `open``closed``all`,默认 `open`
- `--limit` 默认 `50`
- 不支持只传 issue 编号;如果缺少仓库 URL,先提示正确用法再停止
- 如果第一个位置参数是纯数字,则视为“当前仓库的 issue 编号”
- `owner/repo` 这种简写依赖 `GITEA_BASE_URL`
- 如果没有显式仓库参数,就读取当前仓库的 `origin`
规范化后,从 `repo-url` 提取
规范化仓库目标时,接受以下输入
- `origin`:例如 `https://git.example.com`
- `https://host[/prefix]/owner/repo`
- `git@host:owner/repo.git`
- `git@host:prefix/owner/repo.git`
- `ssh://git@host/owner/repo.git`
- `owner/repo`
提取结果必须包含:
- `origin`:例如 `https://git.example.com`,如果 Gitea 部署在子路径下,保留前缀,例如 `https://git.example.com/gitea`
- `owner`
- `repo`
- `repo_path`例如 `owner/repo`
- `repo_path``owner/repo`
如果 URL 不是标准仓库地址,明确提示“仓库 URL 格式无效,需为 `https://host/owner/repo`”。
如果无法从参数或当前仓库推断出目标仓库,明确提示:
```bash
❌ 无法确定目标仓库
请显式传入:
/issue https://git.example.com/owner/repo
或先配置:
export GITEA_BASE_URL=https://git.example.com
```
## 2. 检查环境变量
先读取环境变量 `GITEA_TOKEN`
先读取环境变量
如果缺失,输出:
- `GITEA_TOKEN`:必需,读取 issue 时使用
- `GITEA_BASE_URL`:可选;当仓库参数是 `owner/repo`,或当前仓库 `origin` 是 SSH 地址时推荐配置
如果缺少 `GITEA_TOKEN`,输出:
```bash
❌ 缺少 GITEA_TOKEN
@@ -42,11 +78,29 @@ export GITEA_TOKEN=your_gitea_token
然后停止,不继续请求 API。
## 3. 调用 Gitea API
## 3. 解析当前仓库 origin
不要调用仓库元信息接口,避免依赖 `read:repository` scope。仓库标题直接使用 `repo_path`
当没有显式传仓库参数时,执行:
### 3.1 列表模式
```bash
git remote get-url origin
```
处理规则:
- 如果是 `https://host[/prefix]/owner/repo(.git)`,直接使用
- 如果是 `git@host:owner/repo(.git)``ssh://git@host/owner/repo(.git)`
- 优先用 `GITEA_BASE_URL` 作为 API/Web 基地址
- 否则退回 `https://host`
- 如果当前目录不是 git 仓库,或没有 `origin`,停止并提示用户显式传仓库
不要为了查 issue 再向用户追问仓库 URL;只有在当前项目和参数都无法推断时才提示。
## 4. 调用 Gitea API
不要调用仓库元信息接口,避免依赖额外 scope。仓库标题直接使用 `repo_path`
### 4.1 列表模式
请求:
@@ -56,7 +110,7 @@ curl -sS -o /tmp/gitea_issues.json -w "%{http_code}" \
"${origin}/api/v1/repos/${owner}/${repo}/issues?state=${state}&limit=${limit}"
```
### 3.2 详情模式
### 4.2 详情模式
先请求 issue 详情:
@@ -74,22 +128,22 @@ curl -sS -o /tmp/gitea_issue_comments.json -w "%{http_code}" \
"${origin}/api/v1/repos/${owner}/${repo}/issues/${issue_number}/comments"
```
### 3.3 错误处理
### 4.3 错误处理
根据 HTTP 状态码给出简短、直接的提示:
- `401``GITEA_TOKEN` 无效或未生效
- `403`token scope 不足,或当前用户无权访问该仓库/issue
- `403`token scope 不足,或当前用户无权访问该仓库 / issue
- `404`:仓库不存在,或该 issue 编号不存在
- 其他非 `2xx`:输出状态码和响应中的 `message`
如果列表接口返回项里存在 `pull_request` 且非空,排除这些项,只保留 issue。
## 4. 格式化输出
## 5. 格式化输出
优先使用 `jq` 解析 JSON;如果环境没有 `jq`,再退回模型手工整理,但输出结构保持一致。
### 4.1 列表模式
### 5.1 列表模式
输出结构固定为:
@@ -112,7 +166,7 @@ curl -sS -o /tmp/gitea_issue_comments.json -w "%{http_code}" \
如果过滤后没有任何 issue,明确输出“无符合条件的 issue”。
### 4.2 详情模式
### 5.2 详情模式
输出结构固定为:
@@ -139,23 +193,30 @@ curl -sS -o /tmp/gitea_issue_comments.json -w "%{http_code}" \
- 正文为空时写“无正文”
- 评论按时间顺序输出
- 每条评论只保留 1-2 句摘要;不要整段照抄超长评论
- 每条评论只保留 12 句摘要;不要整段照抄超长评论
- 没有评论时明确写“无评论”
## 5. 行为边界
## 6. 行为边界
- 默认只做列表和单条详情,不主动做主题归纳、epic 合并、优先级建议
- 用户后续如果要求摘要、优先级排序、相似 issue 合并,再基于已拉取的数据继续分析
- 不要求 `GITEA_BASE_URL`
- 不要求用户额外配置固定仓库 URL;优先从当前项目推断
- 当前仓库 origin 与 Web 域名不一致时,再使用 `GITEA_BASE_URL`
## 6. 用法示例
## 7. 用法示例
```bash
/issue https://git.internal.intelligrow.cn/intelligrow/feishu_gitea_bridge
/issue https://git.internal.intelligrow.cn/intelligrow/feishu_gitea_bridge --state=all --limit=20
/issue https://git.internal.intelligrow.cn/intelligrow/feishu_gitea_bridge 17
/issue
/issue 17
/issue owner/repo
/issue owner/repo --state=all --limit=20
/issue https://git.example.com/owner/repo
/issue https://git.example.com/owner/repo 17
$issue https://git.internal.intelligrow.cn/intelligrow/feishu_gitea_bridge
$issue https://git.internal.intelligrow.cn/intelligrow/feishu_gitea_bridge --state=all --limit=20
$issue https://git.internal.intelligrow.cn/intelligrow/feishu_gitea_bridge 17
$issue
$issue 17
$issue owner/repo
$issue owner/repo --state=all --limit=20
$issue https://git.example.com/owner/repo
$issue https://git.example.com/owner/repo 17
```