A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Add an issue triage skill and an editorconfig
Fei2411d9370fd5ae3b
diff --git a/.agents/skills/issue-triage/SKILL.md b/.agents/skills/issue-triage/SKILL.mdnew file mode 100644index 00000000..46c5ab8e--- /dev/null+++ b/.agents/skills/issue-triage/SKILL.md@@ -0,0 +1,94 @@+---+name: issue-triage+description: 给 DS Bot 仓库的 Issue 和 PR 分诊:打类型、优先级、领域标签,判断该关闭、追问、转讨论还是留着做,并把结论写回 GitHub。触发词:分诊、整理 Issue、打标签、打优先级、这个该不该关、追问报告人、needs-info 到期。+---++# Issue 分诊++目标:每个 Open Issue 都有**一个类型、一个优先级**,需要时有一个领域;每个关闭的 Issue 都有**证据**。++标签的含义和流程以 [CONTRIBUTING.zh.md](../../../CONTRIBUTING.zh.md#协作方式) 为准,本文只写怎么做。++**边界**:只动 Issue、PR 的标签、评论和关闭状态。不改代码,不改 Issue 正文,不合并 PR。带 `maintainer` 的条目只分诊、不下结论。++## 1. 取快照++在仓库根目录运行(只读,不写 GitHub):++```sh+node .agents/skills/issue-triage/scripts/snapshot.mjs --out /tmp/triage+```++先读 `digest.md` 再判断,不要只看标题。digest 把每个 Issue 列成:标签、天数、评论数、正文和别人评论的摘要、`dev`/`main` 上引用它的提交、引用它的 Open PR。最上面是**待处理**:++- 没有类型或没有优先级的+- 有两个优先级的+- `needs-info` 超过 14 天、报告人没再回复的++动手之前读一遍 [references/gh-gotchas.md](references/gh-gotchas.md)。++## 2. 分类++每条落三个坐标:++| 坐标 | 取值 | 怎么判 |+|---|---|---|+| 类型 | `bug` · `enhancement` · `documentation` | 行为和设计不一致才是 `bug`。设计本来就这样、用户想要别的,是 `enhancement`。拿不准时先读 [docs/vision.zh.md](../../../docs/vision.zh.md) 和 [docs/plans/](../../../docs/plans/) |+| 优先级 | `P0`–`P3` | `P0` 崩溃、丢数据、完全不能用 · `P1` 影响日常使用、刚引入的回归 · `P2` 普通 bug 或功能 · `P3` 建议、窄场景 |+| 领域 | `area/*` 之一 | 按改动会落在哪个目录判。跨好几个领域或不属于任何领域,就不挂 |++规则:++- **已有的优先级默认保留**。那是之前的判断,不是噪声。觉得该改,在评论里说理由。+- **一个 Issue 只有一个 P 标签**。`--add-label` 不会去掉旧的,改优先级要同时 `--remove-label`。+- PR 不打类型和领域。++## 3. 判动作++按证据归组。**证据不够就留着做**,不要猜着关。++| 组 | 判据 | 动作 |+|---|---|---|+| 已修,未发版 | `dev` 上有提交或已合并的 PR 修了它 | 不关。评论写明 PR 号,等发版时 Release PR 的 `Fixes #N` 自动关 |+| 已修,已发版 | `main` 上有修复,CHANGELOG 有记录,或能指出守住它的测试 | `completed` 关,评论写具体的 PR、提交或测试名 |+| 重复 | 和另一个 Issue 是同一个原因 | 加 `duplicate`,链接那一个,`not planned` 关 |+| 上游 | 原因在 DSH 或别的插件 | 加 `upstream`,链接该去的地方。我们这边无事可做时 `not planned` 关 |+| 提问 | 怎么装、怎么用 | 在网页上 **Convert to discussion**,转到 Q&A(CLI 做不了,见 gotchas) |+| 缺信息 | 现象定位不了,没有版本、日志或复现步骤 | 加 `needs-info`,追问一次(模板见下) |+| `needs-info` 到期 | 追问后 14 天没有新信息 | `not planned` 关,评论写「没有收到补充信息,补充后会重新打开」 |+| 有 PR 在做 | 有 Open PR 引用它 | 不动 |+| 需要方向 | 涉及产品方向、已定设计、协作规则、发版、架构 | 加 `maintainer`,等维护者 |+| 留着做 | 其余 | 打好标签就行。小而清楚的可以加 `good first issue` |++## 4. 写评论和关闭++- **用 Issue 自己的语言**:正文是中文就用中文,否则用英文。+- 关闭的评论必须是「为什么可以关」的证据:PR 号、提交号、文件和测试名、重复的 Issue 号、报告人自己的更正。+- 一条命令完成关闭和评论:`gh issue close <n> --reason "completed" --comment-file <file>` 或 `--reason "not planned"`。+- 中文评论先写进 UTF-8 文件,再用 `--body-file` 或 `--comment-file` 发。++追问模板(按情况删改,写清楚**缺什么**):++```text+感谢反馈。为了找到原因,请补充:+1. DS Bot 和 DSH 的版本。+2. ……(具体缺的东西)+3. ……++14 天内没有新信息,我们会先关闭这个 Issue;补充后我们会重新打开。+```++## 5. 回读自查++写回之后再拉一次,确认:++```sh+gh issue list --state open --limit 300 --json number,labels --jq '.[] | select([.labels[].name | select(test("^P[0-3]$"))] | length != 1) | .number'+gh issue list --state open --limit 300 --json number,labels --jq '.[] | select([.labels[].name | select(. == "bug" or . == "enhancement" or . == "documentation")] | length == 0) | .number'+```++两条都没有输出才算完成。++## 6. 汇报++向提出请求的人汇报一张表:编号、标题、打了什么标签、动作、证据。关闭和追问在执行前先给对方看;对方确认后再发。diff --git a/.agents/skills/issue-triage/references/gh-gotchas.md b/.agents/skills/issue-triage/references/gh-gotchas.mdnew file mode 100644index 00000000..f0c7c969--- /dev/null+++ b/.agents/skills/issue-triage/references/gh-gotchas.md@@ -0,0 +1,29 @@+# gh 和 GitHub 的坑++分诊时踩过的,动手前读一遍。++## 标签++- `gh issue edit --add-label P2` **不会**去掉原来的 `P3`。改优先级要写成 `--add-label P2 --remove-label P3`,改完按 SKILL 第 5 步回读。+- 标签名区分大小写,`p1` 和 `P1` 是两个标签。只用已有的标签,不要临时新建。++## 关闭++- `Fixes #N` 只在 PR 合进**默认分支 `main`** 时生效。合进 `dev` 的修复不会关 Issue,这是故意的:Issue 开着表示「`dev` 已修,等发版」。发版的 PR 要在正文里列出这一批所有的 `Fixes #N`。+- 关闭原因只有两种:`completed`(修好了、答复了)和 `not planned`(重复、上游、不做、缺信息到期)。`gh issue close` 的 `--reason` 要加引号:`--reason "not planned"`。++## 转讨论++- **Convert to discussion 只能在网页上点**。REST 和 `gh` 都没有这个操作。分诊时把要转的 Issue 列出来,请有写权限的人在 Issue 页面右侧栏点。+- 转走之后,原来的 Issue 号会跳转到讨论帖,评论都会带过去。++## 中文和 Windows++- 在 PowerShell 或 cmd 里直接把中文写进 `--body`、`--comment`,可能乱码或被截断。中文先写进 UTF-8 文件,再用 `--body-file` 或 `--comment-file`。+- `gh issue list --search` 对中文标题的匹配不可靠,可能漏结果。查重复时用 `--json number,title,body` 拉全量,在本地过滤。++## 查询++- `gh issue list` 默认只返回 30 条,要加 `--limit`。+- `gh issue list --json comments` 会把全部评论拉下来,数量多时很慢;快照脚本只在需要时才这样拉。+- 在 `--jq` 里过滤标签用 `[.labels[].name]`,不要用 `.labels.name`。diff --git a/.agents/skills/issue-triage/scripts/snapshot.mjs b/.agents/skills/issue-triage/scripts/snapshot.mjsnew file mode 100644index 00000000..7f7eddb8--- /dev/null+++ b/.agents/skills/issue-triage/scripts/snapshot.mjs@@ -0,0 +1,94 @@+#!/usr/bin/env node+// Read-only: collects the open issues and pull requests and writes a digest for triage.+// Usage: node .agents/skills/issue-triage/scripts/snapshot.mjs [--out <dir>] [--repo <owner/name>]+import { execFileSync } from 'node:child_process'+import { mkdirSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join, resolve } from 'node:path'++const args = process.argv.slice(2)+const option = (name, fallback) => (args.includes(name) ? args[args.indexOf(name) + 1] : fallback)+const out = resolve(option('--out', join(tmpdir(), 'issue-triage')))+const repo = option('--repo', 'Fei2411/DeepSeek-Bot')++const run = (cmd, cmdArgs) => execFileSync(cmd, cmdArgs, { encoding: 'utf8', maxBuffer: 1 << 28 })+const gh = cmdArgs => JSON.parse(run('gh', [...cmdArgs, '--repo', repo]))++const TYPES = ['bug', 'enhancement', 'documentation']+const PRIORITY = /^P[0-3]$/+const STALE_DAYS = 14+const DAY = 86400000++const issues = gh(['issue', 'list', '--state', 'open', '--limit', '500', '--json', 'number,title,labels,author,assignees,createdAt,body,comments'])+const pulls = gh(['pr', 'list', '--state', 'open', '--limit', '200', '--json', 'number,title,body,author,baseRefName'])+const open = new Set(issues.map(issue => issue.number))++// `#123` that is not part of a color, a hash or a longer word.+const refsIn = text => [...new Set([...String(text ?? '').matchAll(/(?<![\w&])#(\d{1,5})\b/g)].map(match => Number(match[1])))].filter(n => open.has(n))+const flat = text => String(text ?? '').replace(/<!--[\s\S]*?-->/g, '').replace(/\s+/g, ' ').trim()+const days = iso => Math.floor((Date.now() - new Date(iso).getTime()) / DAY)++const pullRefs = new Map()+for (const pull of pulls) for (const n of refsIn(`${pull.title}\n${pull.body}`)) pullRefs.set(n, [...(pullRefs.get(n) ?? []), pull.number])++// Commits on dev and main that name an issue: the cheapest evidence that it is fixed.+const commitRefs = new Map()+for (const branch of ['origin/dev', 'origin/main']) {+ let log = ''+ try { log = run('git', ['log', branch, '-n', '3000', '--format=%h%x1f%s%x1f%b%x1e']) } catch { continue }+ for (const entry of log.split('\x1e')) {+ const [hash, subject = '', body = ''] = entry.trim().split('\x1f')+ if (!hash) continue+ for (const n of refsIn(`${subject}\n${body}`)) {+ const list = commitRefs.get(n) ?? []+ if (list.length < 3 && !list.some(item => item.startsWith(hash))) list.push(`${hash} (${branch.slice(7)}) ${subject.slice(0, 90)}`)+ commitRefs.set(n, list)+ }+ }+}++const rows = issues.map(issue => {+ const labels = issue.labels.map(label => label.name)+ const priorities = labels.filter(name => PRIORITY.test(name))+ const lastByReporter = issue.comments.filter(comment => comment.author.login === issue.author.login).at(-1)?.createdAt ?? issue.createdAt+ const problems = []+ if (!labels.some(name => TYPES.includes(name))) problems.push('no type')+ if (priorities.length === 0) problems.push('no priority')+ if (priorities.length > 1) problems.push(`priorities ${priorities.join('+')}`)+ if (labels.includes('needs-info') && days(lastByReporter) > STALE_DAYS) problems.push(`needs-info, reporter silent ${days(lastByReporter)}d`)+ return { number: issue.number, title: issue.title, labels, priority: priorities[0], author: issue.author.login, assignees: issue.assignees.map(a => a.login), age: days(issue.createdAt), comments: issue.comments, body: issue.body, problems, pulls: pullRefs.get(issue.number) ?? [], commits: commitRefs.get(issue.number) ?? [] }+})+const rank = row => (row.problems.length ? 0 : 1) * 10 + (row.priority ? Number(row.priority[1]) : 5)+rows.sort((a, b) => rank(a) - rank(b) || b.number - a.number)++const lines = [`# Triage snapshot ${new Date().toISOString().slice(0, 10)} · ${repo}`, '']+const todo = rows.filter(row => row.problems.length)+lines.push(`Open issues: ${rows.length} · open pull requests: ${pulls.length} · to handle: ${todo.length}`, '')+if (todo.length) {+ lines.push('## To handle', '')+ for (const row of todo) lines.push(`- #${row.number} ${row.problems.join(', ')}: ${flat(row.title).slice(0, 80)}`)+ lines.push('')+}+lines.push('## Issues', '')+for (const row of rows) {+ lines.push(`### #${row.number} [${row.labels.join(', ') || '-'}] ${row.age}d · ${row.comments.length} comments · @${row.author}${row.assignees.length ? ` → ${row.assignees.join(', ')}` : ''}`)+ lines.push(`T: ${flat(row.title)}`)+ const body = flat(row.body).slice(0, 240)+ if (body) lines.push(`B: ${body}`)+ const others = row.comments.filter(comment => comment.author.login !== row.author).slice(-2).map(comment => `@${comment.author.login}: ${flat(comment.body).slice(0, 160)}`)+ if (others.length) lines.push(`C: ${others.join(' || ')}`)+ if (row.commits.length) lines.push(`FIX: ${row.commits.join(' ;; ')}`)+ if (row.pulls.length) lines.push(`PR: ${row.pulls.map(n => `#${n}`).join(' ')}`)+ lines.push('')+}+const loose = pulls.filter(pull => refsIn(`${pull.title}\n${pull.body}`).length === 0)+if (loose.length) {+ lines.push('## Open pull requests without an open issue', '')+ for (const pull of loose) lines.push(`- #${pull.number} → ${pull.baseRefName} @${pull.author.login}: ${flat(pull.title).slice(0, 90)}`)+ lines.push('')+}++mkdirSync(out, { recursive: true })+writeFileSync(join(out, 'snapshot.json'), JSON.stringify({ generatedAt: new Date().toISOString(), repo, issues: rows.map(({ comments, ...row }) => ({ ...row, comments: comments.length })), pulls }, null, 1))+writeFileSync(join(out, 'digest.md'), `${lines.join('\n')}\n`)+console.log(`${out}: ${rows.length} issues, ${pulls.length} pull requests, ${todo.length} to handle`)diff --git a/.editorconfig b/.editorconfignew file mode 100644index 00000000..1014ba78--- /dev/null+++ b/.editorconfig@@ -0,0 +1,12 @@+root = true++[*]+charset = utf-8+end_of_line = lf+insert_final_newline = true+indent_style = space+indent_size = 2+trim_trailing_whitespace = true++[*.md]+trim_trailing_whitespace = falsediff --git a/AGENTS.md b/AGENTS.mdindex e3beb7c6..3186f33b 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -52,6 +52,7 @@ The full workflow is in [CONTRIBUTING.md](CONTRIBUTING.md#how-we-work). The part- Do not start work on an issue or pull request with the `maintainer` label; it waits for the maintainer. Do not take an issue that someone else is assigned to.- Before you change behavior, read the design for it in `docs/plans/` (and `docs/vision.md`). A change to a decided design needs the maintainer; a new large feature adds its design note to the same pull request.- Do not close an issue without evidence: the pull request or commit that fixed it, the issue it duplicates, or the reason it will not be fixed.+- To triage issues, follow [.agents/skills/issue-triage/SKILL.md](.agents/skills/issue-triage/SKILL.md).## Layoutdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 53487774..c7a0efa0 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -34,7 +34,7 @@ Anyone on the team can do any kind of work: triage, bug fixes, features, the int### Issues-1. **Triage.** Give each new issue a type, a priority and an area (see [Labels](#labels)). One priority label per issue.+1. **Triage.** Give each new issue a type, a priority and an area (see [Labels](#labels)). One priority label per issue. The steps, with a script that lists what needs triage, are in [.agents/skills/issue-triage/](.agents/skills/issue-triage/SKILL.md) (in Chinese); an AI agent can follow them as well.- A question (how to install, how to use): select **Convert to discussion** and move it to the Q&A category.- Not enough information to find the cause: add `needs-info` and ask for exactly what is missing. Say that the issue is closed after 14 days without an answer.- A cause in DSH or in another plugin: add `upstream` and link the place where it belongs.diff --git a/CONTRIBUTING.zh.md b/CONTRIBUTING.zh.mdindex 00736076..003db60b 100644--- a/CONTRIBUTING.zh.md+++ b/CONTRIBUTING.zh.md@@ -34,7 +34,7 @@### Issue-1. **分诊。** 给每个新 Issue 打类型、优先级和领域标签(见[标签](#标签))。每个 Issue 只有一个优先级标签。+1. **分诊。** 给每个新 Issue 打类型、优先级和领域标签(见[标签](#标签))。每个 Issue 只有一个优先级标签。具体步骤和列出待分诊 Issue 的脚本见 [.agents/skills/issue-triage/](.agents/skills/issue-triage/SKILL.md),AI 也可以照着做。- 是提问(怎么装、怎么用):选 **Convert to discussion**,转到 Q&A 分类。- 信息不够,找不到原因:加 `needs-info`,写清楚还缺什么。说明 14 天没有回复就关闭。- 原因在 DSH 或其他插件:加 `upstream`,并链接到应该处理它的地方。