dsh-repo-watch 0.1.2 → 0.1.3

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 CHANGED
@@ -42,15 +42,15 @@
42
42
  推的是**一条报数**,不是内容倾泻——在手机上两秒能看完,要不要看细节由你决定:
43
43
 
44
44
  ```
45
- 🔔 有 4 条新消息
45
+ 有 4 条新消息(来源:GitHub)
46
46
 
47
47
  · 需要你回复 4 条 — 有人回复了你提的 issue/PR、@ 了你,或请你 review
48
48
 
49
- 回复「看」查看全部,「看1」只看需要你回复的。
50
- 最近一条:awesome-dsh-plugin/awesome-dsh-plugin#15938
49
+ 回复「查看」查看全部明细;「查看 1」只看需要你回复的。
50
+ 最近一条:awesome-dsh-plugin/awesome-dsh-plugin#15938 Add: two IM channel plugins…(PR)
51
51
  ```
52
52
 
53
- 回「看」之后,会话里给出带原话的明细(同一条只在聊天里展开,不再二次推送):
53
+ 回「查看」之后,会话里给出带原话的明细(同一条只在聊天里展开,不再二次推送):
54
54
 
55
55
  ```
56
56
  共 4 条,显示 4 条:
package/index.mjs CHANGED
@@ -134,14 +134,18 @@ function shortDay(at) {
134
134
  * It is a roll-call, not a dump. Listing every thread with its excerpt felt wrong
135
135
  * in practice: a push is read on a phone in two seconds, and four paragraphs of
136
136
  * somebody else's comment is more than that moment can absorb. So the message says
137
- * how many there are, split by what they want from you, and how to ask for the
138
- * detail — which is one reply away, in the same chat.
137
+ * how many there are, where they come from, split by what they want from you, and
138
+ * how to ask for the detail — which is one reply away, in the same chat.
139
+ *
140
+ * Plain text by design: no emoji, no decoration. The wording says 查看 rather than
141
+ * 看 because a one-character prompt reads like a typo, even though short replies
142
+ * are exactly what the digest accepts.
139
143
  */
140
144
  function composeWaitingMessage(entries) {
141
145
  const buckets = { reply: [], action: [], other: [] }
142
146
  for (const entry of entries) buckets[bucketOf(entry.reason)].push(entry)
143
147
  const total = entries.length
144
- const head = total === 1 ? '🔔 有 1 条新消息' : `🔔 有 ${total} 条新消息`
148
+ const head = `有 ${total} 条新消息(来源:GitHub)`
145
149
  const lines = [head, '']
146
150
  for (const key of ['reply', 'action', 'other']) {
147
151
  const count = buckets[key].length
@@ -149,14 +153,19 @@ function composeWaitingMessage(entries) {
149
153
  lines.push(`· ${bucketText(key)} ${count} 条 — ${bucketHint(key)}`)
150
154
  }
151
155
  lines.push('')
152
- const hints = []
153
- if (buckets.reply.length) hints.push('「看1」只看需要你回复的')
154
- if (buckets.action.length) hints.push('「看2」只看需要你处理的')
155
- lines.push(`回复「看」查看全部${hints.length ? `,${hints.join(',')}` : ''}。`)
156
+ const hints = ['回复「查看」查看全部明细']
157
+ if (buckets.reply.length) hints.push('「查看 1」只看需要你回复的')
158
+ if (buckets.action.length) hints.push('「查看 2」只看需要你处理的')
159
+ lines.push(`${hints.join(';')}。`)
156
160
  const newest = entries
157
161
  .slice()
158
162
  .sort((a, b) => Number(b.lastActivityAt ?? 0) - Number(a.lastActivityAt ?? 0))[0]
159
- if (newest) lines.push(`最近一条:${newest.key}`)
163
+ if (newest) {
164
+ const kind = String(newest.thread?.kind ?? newest.kind ?? '')
165
+ const kindText = kind === 'pr' ? '(PR)' : kind === 'issue' ? '(issue)' : ''
166
+ const title = newest.title ? ` ${newest.title}` : ''
167
+ lines.push(`最近一条:${newest.key}${title}${kindText}`)
168
+ }
160
169
  return lines.join('\n')
161
170
  }
162
171
 
@@ -350,8 +359,9 @@ const digestTool = (config) => ({
350
359
  name: 'repo_watch_digest',
351
360
  description:
352
361
  'List the threads the watchtower is tracking, with who spoke last and what they said. '
353
- + 'Call this whenever the user asks to see the details after a watchtower push — a reply of '
354
- + '"看" / "详情" / "show me" means bucket "all"; "看1" means bucket "reply"; "看2" means "action". '
362
+ + 'Call this whenever the user asks to see the detail after a watchtower push: "查看", "详情", '
363
+ + '"展开", "看", "列表" all mean bucket "all"; "查看 1" / "看1" means bucket "reply"; '
364
+ + '"查看 2" / "看2" means "action". Users reply briefly, so match on the intent, not on an exact word. '
355
365
  + 'kind="waiting" (default) returns what needs the user, "quiet" returns the rest, "deep" adds '
356
366
  + 'the stored reason and last actor for each thread.',
357
367
  parameters: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-repo-watch",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "DSH repository watchtower: it watches your GitHub repos in the background and only speaks up when someone is actually waiting on you.",
6
6
  "license": "MIT",
@@ -32,6 +32,6 @@
32
32
  "node": ">=20.18.1"
33
33
  },
34
34
  "scripts": {
35
- "test": "node --test test/triage.test.mjs"
35
+ "test": "node --test test/triage.test.mjs test/message.test.mjs"
36
36
  }
37
37
  }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The push message is the whole product surface for most users, so its wording is
3
+ * pinned here: no emoji, an explicit source, a readable prompt, and the type of the
4
+ * newest thread spelled out.
5
+ */
6
+ import test from 'node:test'
7
+ import assert from 'node:assert/strict'
8
+
9
+ import { _internals } from '../index.mjs'
10
+
11
+ const { composeWaitingMessage } = _internals
12
+
13
+ const entry = (over = {}) => ({
14
+ key: 'owner/repo#1',
15
+ title: 'Some title',
16
+ thread: { kind: 'issue' },
17
+ reason: 'someone-replied-to-my-thread',
18
+ actor: 'them',
19
+ snippet: 'hello',
20
+ lastActivityAt: 1_700_000_000_000,
21
+ url: 'https://github.com/owner/repo/issues/1',
22
+ ...over,
23
+ })
24
+
25
+ test('the roll-call carries no emoji', () => {
26
+ const text = composeWaitingMessage([entry(), entry({ key: 'owner/repo#2' })])
27
+ assert.doesNotMatch(text, /\p{Extended_Pictographic}/u)
28
+ })
29
+
30
+ test('the header counts the messages and names the source', () => {
31
+ const text = composeWaitingMessage([entry(), entry({ key: 'owner/repo#2' })])
32
+ assert.match(text, /^有 2 条新消息(来源:GitHub)$/m)
33
+
34
+ const single = composeWaitingMessage([entry()])
35
+ assert.match(single, /^有 1 条新消息(来源:GitHub)$/m)
36
+ })
37
+
38
+ test('the prompt asks for 查看 while still accepting a short reply', () => {
39
+ const text = composeWaitingMessage([entry()])
40
+ assert.match(text, /回复「查看」查看全部明细/)
41
+ // 该字单独出现时不算提示,避免让人以为只能回一个字
42
+ assert.doesNotMatch(text, /回复「看」/)
43
+ })
44
+
45
+ test('bucket lines explain what each group wants', () => {
46
+ const text = composeWaitingMessage([
47
+ entry(),
48
+ entry({ key: 'owner/repo#2', reason: 'external-issue' }),
49
+ ])
50
+ assert.match(text, /需要你回复 1 条/)
51
+ assert.match(text, /需要你处理 1 条/)
52
+ assert.match(text, /「查看 1」/)
53
+ assert.match(text, /「查看 2」/)
54
+ })
55
+
56
+ test('the newest line names the thread type', () => {
57
+ const issueText = composeWaitingMessage([entry()])
58
+ assert.match(issueText, /最近一条:owner\/repo#1 Some title(issue)/)
59
+
60
+ const prText = composeWaitingMessage([entry({ thread: { kind: 'pr' } })])
61
+ assert.match(prText, /最近一条:owner\/repo#1 Some title(PR)/)
62
+ })
63
+
64
+ test('the newest line is the most recent thread', () => {
65
+ const text = composeWaitingMessage([
66
+ entry({ key: 'owner/repo#old', lastActivityAt: 1_000 }),
67
+ entry({ key: 'owner/repo#new', lastActivityAt: 9_000 }),
68
+ ])
69
+ assert.match(text, /最近一条:owner\/repo#new/)
70
+ })