dsh-repo-watch 0.3.0 → 0.3.1
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/index.mjs +1 -1
- package/lib/insight.mjs +10 -3
- package/package.json +1 -1
- package/test/insight.test.mjs +13 -0
package/index.mjs
CHANGED
|
@@ -466,7 +466,7 @@ const digestTool = (config) => ({
|
|
|
466
466
|
}
|
|
467
467
|
if (thread.url) lines.push(` ${thread.url}`)
|
|
468
468
|
if (wanted === 'deep') {
|
|
469
|
-
const classification = classify({ title: thread.title })
|
|
469
|
+
const classification = classify({ title: thread.title, kind: thread.kind })
|
|
470
470
|
const ageDays = thread.lastActivityAt ? (Date.now() - Number(thread.lastActivityAt)) / 86_400_000 : 0
|
|
471
471
|
const priority = priorityOf({
|
|
472
472
|
classification, title: thread.title, reason: thread.reason,
|
package/lib/insight.mjs
CHANGED
|
@@ -13,7 +13,10 @@ const KIND_RULES = [
|
|
|
13
13
|
kind: 'bug',
|
|
14
14
|
label: '缺陷',
|
|
15
15
|
labels: /^(bug|crash|regression|broken)/i,
|
|
16
|
-
|
|
16
|
+
// `bug` must be here as well as in the labels: maintainers write "[Bug] …" in the
|
|
17
|
+
// title far more often than they add the label, and the first version only
|
|
18
|
+
// matched labels, so every such report fell through to "其他".
|
|
19
|
+
text: /(报错|崩溃|异常|无法|失败|不工作|挂了|闪退|\bbug\b|\berror\b|exception|crash|fail|broken|regression)/i,
|
|
17
20
|
},
|
|
18
21
|
{
|
|
19
22
|
kind: 'feature',
|
|
@@ -37,10 +40,10 @@ const KIND_RULES = [
|
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* What kind of report this is.
|
|
40
|
-
* @param {{ title?: string, labels?: string[] }} input
|
|
43
|
+
* @param {{ title?: string, labels?: string[], kind?: 'issue' | 'pr' }} input
|
|
41
44
|
* @returns {{ kind: string, label: string, signals: string[] }}
|
|
42
45
|
*/
|
|
43
|
-
export function classify({ title = '', labels = [] } = {}) {
|
|
46
|
+
export function classify({ title = '', labels = [], kind = 'issue' } = {}) {
|
|
44
47
|
const text = String(title ?? '')
|
|
45
48
|
const signals = []
|
|
46
49
|
for (const rule of KIND_RULES) {
|
|
@@ -50,6 +53,9 @@ export function classify({ title = '', labels = [] } = {}) {
|
|
|
50
53
|
if (hitText) signals.push('标题措辞')
|
|
51
54
|
if (hitLabel || hitText) return { kind: rule.kind, label: rule.label, signals }
|
|
52
55
|
}
|
|
56
|
+
// A pull request is a different animal from an unclassified report: it is a
|
|
57
|
+
// contribution to review or merge, not a report that may be missing details.
|
|
58
|
+
if (kind === 'pr') return { kind: 'pr', label: '变更/PR', signals: ['类型为 PR'] }
|
|
53
59
|
return { kind: 'other', label: '其他', signals: [] }
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -87,6 +93,7 @@ export function priorityOf({ classification, title = '', reason = '', ageDays =
|
|
|
87
93
|
if (reason === 'mentioned') add(2, '对方 @ 了你')
|
|
88
94
|
if (reason === 'someone-replied-to-my-thread') add(2, '你提的 thread 有人回复')
|
|
89
95
|
if (String(classification?.kind) === 'question' || String(classification?.kind) === 'docs') add(-1, '提问或文档类,通常不急')
|
|
96
|
+
if (String(classification?.kind) === 'pr') add(0, '是一条 PR,等你审阅或合并')
|
|
90
97
|
if (String(classification?.kind) === 'other') add(-1, '无法归类,信息可能不足')
|
|
91
98
|
if (!text.trim()) add(-2, '只有编号没有标题')
|
|
92
99
|
if (Number(notifyCount) >= 3) add(2, `已提醒 ${notifyCount} 次仍挂着`)
|
package/package.json
CHANGED
package/test/insight.test.mjs
CHANGED
|
@@ -22,6 +22,19 @@ test('the four kinds are recognised from wording alone', () => {
|
|
|
22
22
|
assert.equal(classify({ title: 'dsh-repo-watch#42' }).kind, 'other')
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
+
test('[Bug] in the title is enough, without a label', () => {
|
|
26
|
+
// 维护者更常把 [Bug] 写在标题里,而不是加标签;首版只匹配标签,整类都掉进"其他"
|
|
27
|
+
assert.equal(classify({ title: '[Bug] 非 Anthropic 模型经桥接时推理文本混入正文' }).kind, 'bug')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('a pull request is its own kind, not an unclassified report', () => {
|
|
31
|
+
const pr = classify({ title: 'Add: two IM channel plugins', kind: 'pr' })
|
|
32
|
+
assert.equal(pr.kind, 'pr')
|
|
33
|
+
assert.equal(pr.label, '变更/PR')
|
|
34
|
+
// 但 PR 标题里出现崩溃,仍然按缺陷处理——那说明这条 PR 在修 bug
|
|
35
|
+
assert.equal(classify({ title: 'Fix: 启动崩溃', kind: 'pr' }).kind, 'bug')
|
|
36
|
+
})
|
|
37
|
+
|
|
25
38
|
test('classification names the signal it used', () => {
|
|
26
39
|
const byLabel = classify({ title: 'x', labels: ['regression'] })
|
|
27
40
|
assert.equal(byLabel.kind, 'bug')
|