dsh-work-summary 0.0.0-stage → 0.3.0

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/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Daily work report",
4
+ "description": "Collects the day's work traces, validates and writes the daily report, and pushes the next-day checklist onto the board.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "每日工作日报",
4
+ "description": "采集当天工作痕迹,校验并写日报,把「明日开场清单」推进看板;可托管每日计划任务。",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "dsh-work-summary",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Daily, weekly and monthly work reports for DeepSeek Harness: collect traces, write and validate reports, push next actions onto the board.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./client": "./client.js",
9
+ "./locale/*.json": "./locale/*.json",
10
+ "./icon": "./icon.svg"
11
+ },
12
+ "files": [
13
+ "index.js",
14
+ "client.js",
15
+ "cordis.patch.yml",
16
+ "scripts",
17
+ "PROMPT.md",
18
+ "README.md",
19
+ "locale/*.json",
20
+ "docs/DETAIL.md",
21
+ "icon.svg",
22
+ "LICENSE"
23
+ ],
24
+ "keywords": [
25
+ "dsh",
26
+ "dsh-plugin",
27
+ "deepseek-harness",
28
+ "daily-report",
29
+ "work-summary",
30
+ "journal",
31
+ "productivity"
32
+ ],
33
+ "engines": {
34
+ "dsh": ">=0.2.3-alpha.2"
35
+ },
36
+ "scripts": {
37
+ "test": "node test/stats.test.mjs && node test/board-start.test.mjs && node test/route.test.mjs && node test/period.test.mjs && node test/quality.test.mjs && node test/archive.test.mjs",
38
+ "check": "node --check index.js && node --check client.js"
39
+ },
40
+ "dsh": {
41
+ "bundle": {
42
+ "patch": "./cordis.patch.yml"
43
+ },
44
+ "client": {
45
+ "platform": "web",
46
+ "immediately": true,
47
+ "inject": [
48
+ "@deepseek-ai/dsh-client-ui-layout",
49
+ "@deepseek-ai/dsh-client-ui-sidebar"
50
+ ]
51
+ }
52
+ },
53
+ "publishConfig": {
54
+ "registry": "https://registry.npmjs.org/",
55
+ "access": "public"
56
+ },
57
+ "license": "MIT"
58
+ }
@@ -0,0 +1,365 @@
1
+ # collect-day.ps1 —— 收集某一天的"工作痕迹",输出一份源数据 Markdown,供日报总结引用。
2
+ # 用法:
3
+ # pwsh -NoProfile -File collect-day.ps1 # 今天
4
+ # pwsh -NoProfile -File collect-day.ps1 -Date 2026-10-28
5
+ # pwsh -NoProfile -File collect-day.ps1 -NoSessions # 跳过会话解析(更快)
6
+ # 输出:<ReportDir>\_源数据\YYYY-MM-DD.md(同时打印路径)
7
+ # 本脚本属于 dsh-work-summary 插件仓库;扫哪里由 -Workspace 决定,产物写哪由 -ReportDir 决定。
8
+ # 默认数据根是 ~/.dsh/dsh-work-summary(插件激活时创建),插件调用时会把两个参数都显式传进来。
9
+
10
+ param(
11
+ [string]$Date = (Get-Date -Format 'yyyy-MM-dd'),
12
+ [string]$DshHome = (Join-Path $HOME '.dsh'),
13
+ [string]$Workspace = (Join-Path $DshHome 'dsh-work-summary'),
14
+ [string]$ReportDir = (Join-Path $DshHome 'dsh-work-summary'),
15
+ [switch]$NoSessions
16
+ )
17
+
18
+ $ErrorActionPreference = 'Stop'
19
+ $ProgressPreference = 'SilentlyContinue'
20
+
21
+ try { $day = [datetime]::ParseExact($Date, 'yyyy-MM-dd', $null) }
22
+ catch { throw "日期格式应为 yyyy-MM-dd,收到:$Date" }
23
+
24
+ $dayStart = $day
25
+ $dayEnd = $day.AddDays(1)
26
+ $startMs = [DateTimeOffset]::new($dayStart).ToUnixTimeMilliseconds()
27
+ $endMs = [DateTimeOffset]::new($dayEnd).ToUnixTimeMilliseconds()
28
+ $sinceArg = $dayStart.ToString('yyyy-MM-dd HH:mm:ss')
29
+ $untilArg = $dayEnd.ToString('yyyy-MM-dd HH:mm:ss')
30
+
31
+ $outDir = Join-Path $ReportDir '_源数据'
32
+ New-Item -ItemType Directory -Force -Path $outDir | Out-Null
33
+ $outFile = Join-Path $outDir "$Date.md"
34
+
35
+ $skipDirs = @('node_modules', '.pnpm-store', '.git', 'dist', 'build', '.next', 'target',
36
+ 'temp', 'tmp', '.cache', '__pycache__', '_源数据', '.dsh-vision-router',
37
+ # 第三方资产/工具目录:装技能、跑示例产生的海量文件不该进日报
38
+ '.dsh', 'anatomy', 'shots', '备份',
39
+ # 临时/调试文件专区:一次性脚本与中间产物不算工作产出
40
+ '_scratch')
41
+
42
+ function Test-SkipPath([string]$rel) {
43
+ foreach ($seg in ($rel -split '[\\/]')) {
44
+ if ($skipDirs -contains $seg) { return $true }
45
+ }
46
+ return $false
47
+ }
48
+
49
+ $sb = [System.Collections.Generic.List[string]]::new()
50
+ function Add-Line([string]$s = '') { $sb.Add($s) }
51
+
52
+ # ---------- 源数据归档 ----------
53
+ # `_源数据` 只保留最近 60 个 Markdown;更旧的按数据日期分季度压进 `_归档\YYYY-QN.zip`。
54
+ # 只归档不是今天的文件;打包成功并校验条目后才删除原文件,失败只记一行,不影响采集。
55
+ $archiveKeep = 60
56
+ $archiveDir = Join-Path $ReportDir '_归档'
57
+
58
+ function Get-SourceDay([string]$filePath) {
59
+ $name = [IO.Path]::GetFileNameWithoutExtension($filePath)
60
+ if ($name -match '^(\d{4})-(\d{2})-(\d{2})$') { return $name }
61
+ if ($name -match '^周期-(\d{4})-(\d{2})-(\d{2})_') {
62
+ return '{0}-{1}-{2}' -f $Matches[1], $Matches[2], $Matches[3]
63
+ }
64
+ return (Get-Item -LiteralPath $filePath).LastWriteTime.ToString('yyyy-MM-dd')
65
+ }
66
+
67
+ function Get-QuarterName([string]$day) {
68
+ $year = [int]$day.Substring(0, 4)
69
+ $month = [int]$day.Substring(5, 2)
70
+ return '{0}-Q{1}' -f $year, ([math]::Floor(($month - 1) / 3) + 1)
71
+ }
72
+
73
+ function Add-ArchiveIndex([string]$quarter, [int]$added, [string]$first, [string]$last, [string]$zipName) {
74
+ $index = Join-Path $archiveDir '索引.md'
75
+ if (-not (Test-Path -LiteralPath $index)) {
76
+ Set-Content -LiteralPath $index -Encoding UTF8 -Value @(
77
+ '# 源数据归档索引'
78
+ ''
79
+ '| 归档时间 | 季度 | 新增 | 区间 | 包 |'
80
+ '|---|---|---:|---|---|'
81
+ )
82
+ }
83
+ $row = '| {0} | {1} | +{2} | {3} ~ {4} | `{5}` |' -f (Get-Date -Format 'yyyy-MM-dd HH:mm'), $quarter, $added, $first, $last, $zipName
84
+ Add-Content -LiteralPath $index -Encoding UTF8 -Value $row
85
+ }
86
+
87
+ function Invoke-SourceArchive {
88
+ $notes = [System.Collections.Generic.List[string]]::new()
89
+ try {
90
+ if (-not (Test-Path -LiteralPath $outDir)) { return @() }
91
+ $all = @(Get-ChildItem -LiteralPath $outDir -File -Filter '*.md' -Force -ErrorAction Stop)
92
+ $todayName = [IO.Path]::GetFileName($outFile)
93
+ $old = @($all | Where-Object { $_.Name -ne $todayName })
94
+ # 今天这次采集即将写入的文件也算一个名额,所以总数是旧文件 + 1。
95
+ $total = $old.Count + 1
96
+ if ($total -le $archiveKeep) { return @() }
97
+
98
+ $excess = $total - $archiveKeep
99
+ $candidates = @($old | ForEach-Object {
100
+ [pscustomobject]@{ File = $_; Day = (Get-SourceDay $_.FullName) }
101
+ } | Sort-Object Day, @{ Expression = { $_.File.Name } })
102
+ $take = @($candidates | Select-Object -First $excess)
103
+
104
+ foreach ($group in ($take | Group-Object { Get-QuarterName $_.Day })) {
105
+ $zipName = '{0}.zip' -f $group.Name
106
+ $zipPath = Join-Path $archiveDir $zipName
107
+ $paths = @($group.Group | ForEach-Object { $_.File.FullName })
108
+ $days = @($group.Group | ForEach-Object { $_.Day } | Sort-Object)
109
+ $added = $paths.Count
110
+ try {
111
+ New-Item -ItemType Directory -Force -Path $archiveDir | Out-Null
112
+ if (Test-Path -LiteralPath $zipPath) {
113
+ Compress-Archive -LiteralPath $paths -DestinationPath $zipPath -Update -CompressionLevel Optimal -ErrorAction Stop
114
+ } else {
115
+ Compress-Archive -LiteralPath $paths -DestinationPath $zipPath -CompressionLevel Optimal -ErrorAction Stop
116
+ }
117
+
118
+ # 先确认压缩包里确实有这些条目,再删源文件;避免删了却没进包。
119
+ $zip = [System.IO.Compression.ZipFile]::OpenRead($zipPath)
120
+ try { $entryNames = @($zip.Entries | ForEach-Object { $_.FullName }) }
121
+ finally { $zip.Dispose() }
122
+ $missing = @($paths | Where-Object { $entryNames -notcontains [IO.Path]::GetFileName($_) })
123
+ if ($missing.Count -gt 0) { throw "压缩包缺少 $($missing.Count) 个文件" }
124
+
125
+ foreach ($path in $paths) { Remove-Item -LiteralPath $path -Force -ErrorAction Stop }
126
+ Add-ArchiveIndex $group.Name $added $days[0] $days[$days.Count - 1] $zipName
127
+ $notes.Add("> 归档:$added 个源数据 → ``_归档\$zipName``($($days[0]) ~ $($days[$days.Count - 1]))")
128
+ } catch {
129
+ $notes.Add("> 归档失败:$($_.Exception.Message)")
130
+ }
131
+ }
132
+ } catch {
133
+ $notes.Add("> 归档失败:$($_.Exception.Message)")
134
+ }
135
+ return $notes.ToArray()
136
+ }
137
+
138
+ Add-Line "# 工作痕迹源数据 · $Date"
139
+ Add-Line ''
140
+ Add-Line "> 采集窗口:$sinceArg ~ $untilArg(本地时区 $([DateTime]::Now.ToString('zzz')))"
141
+ Add-Line '> 本文件由 `collect-day.ps1` 只读生成,用于日报的事实依据;不要手工编辑。'
142
+ Add-Line ''
143
+
144
+ # ---------- 1. 工作区文件改动 ----------
145
+ Add-Line '## 1. 工作区当日改动文件'
146
+ Add-Line ''
147
+ $files = @()
148
+ if (Test-Path $Workspace) {
149
+ $files = Get-ChildItem -Path $Workspace -Recurse -File -Force -ErrorAction SilentlyContinue |
150
+ Where-Object {
151
+ $_.LastWriteTime -ge $dayStart -and $_.LastWriteTime -lt $dayEnd -and
152
+ -not (Test-SkipPath $_.FullName.Substring($Workspace.Length))
153
+ } | Sort-Object LastWriteTime
154
+ }
155
+
156
+ if ($files.Count -eq 0) {
157
+ Add-Line '_当日无文件改动。_'
158
+ } else {
159
+ Add-Line "共 $($files.Count) 个文件:"
160
+ Add-Line ''
161
+ Add-Line '| 时间 | 大小 | 相对路径 |'
162
+ Add-Line '|------|------|----------|'
163
+ foreach ($f in $files) {
164
+ $rel = $f.FullName.Substring($Workspace.Length).TrimStart('\')
165
+ $size = if ($f.Length -ge 1MB) { '{0:N1} MB' -f ($f.Length / 1MB) }
166
+ elseif ($f.Length -ge 1KB) { '{0:N1} KB' -f ($f.Length / 1KB) }
167
+ else { "$($f.Length) B" }
168
+ Add-Line ("| {0:HH:mm} | {1} | {2} |" -f $f.LastWriteTime, $size, $rel)
169
+ }
170
+
171
+ Add-Line ''
172
+ Add-Line '### 按顶层目录汇总'
173
+ Add-Line ''
174
+ $files | Group-Object { ($_.FullName.Substring($Workspace.Length).TrimStart('\') -split '[\\/]')[0] } |
175
+ Sort-Object Count -Descending |
176
+ ForEach-Object { Add-Line ("- ``{0}``:{1} 个文件" -f $_.Name, $_.Count) }
177
+ }
178
+ Add-Line ''
179
+
180
+ # ---------- 2. Git 仓库提交 ----------
181
+ Add-Line '## 2. Git 仓库当日提交'
182
+ Add-Line ''
183
+ $gitExe = (Get-Command git -ErrorAction SilentlyContinue).Source
184
+ $repos = @()
185
+ if ($gitExe -and (Test-Path $Workspace)) {
186
+ $repos = Get-ChildItem -Path $Workspace -Directory -Recurse -Depth 3 -Force -ErrorAction SilentlyContinue |
187
+ Where-Object { Test-Path (Join-Path $_.FullName '.git') } |
188
+ Select-Object -ExpandProperty FullName
189
+ }
190
+
191
+ if (-not $gitExe) {
192
+ Add-Line '_未找到 git,跳过。_'
193
+ } elseif ($repos.Count -eq 0) {
194
+ Add-Line '_工作区内未发现 Git 仓库。_'
195
+ } else {
196
+ $anyCommit = $false
197
+ foreach ($repo in $repos) {
198
+ $rel = if ($repo -eq $Workspace) { '.' } else { $repo.Substring($Workspace.Length).TrimStart('\') }
199
+ $log = & $gitExe -C $repo log --since="$sinceArg" --until="$untilArg" --pretty='%h %ad %s' --date=format:'%H:%M' --no-decorate 2>$null
200
+ $branch = (& $gitExe -C $repo rev-parse --abbrev-ref HEAD 2>$null)
201
+ $dirty = @(& $gitExe -C $repo status --porcelain 2>$null).Count
202
+ if ($log) {
203
+ $anyCommit = $true
204
+ Add-Line "### ``$rel`` (分支 $branch)"
205
+ Add-Line ''
206
+ foreach ($l in $log) { Add-Line "- $l" }
207
+ Add-Line ''
208
+ if ($dirty -gt 0) { Add-Line "- 另有 $dirty 个未提交改动" ; Add-Line '' }
209
+ } elseif ($dirty -gt 0) {
210
+ Add-Line "- ``$rel``:当日无提交,但有 $dirty 个未提交改动(分支 $branch)"
211
+ }
212
+ }
213
+ if (-not $anyCommit) { Add-Line '' }
214
+ }
215
+ Add-Line ''
216
+
217
+ # ---------- 3. DSH 会话 ----------
218
+ Add-Line '## 3. DSH 会话(当日有活动的会话)'
219
+ Add-Line ''
220
+ if ($NoSessions) {
221
+ Add-Line '_(-NoSessions 跳过)_'
222
+ } else {
223
+ $sessRoot = Join-Path $DshHome 'sessions'
224
+ $zstd = (Get-Command zstd -ErrorAction SilentlyContinue).Source
225
+ if (-not $zstd) { $zstd = 'C:\Program Files\poppler\Library\bin\zstd.exe' }
226
+
227
+ $sessFiles = @()
228
+ if (Test-Path $sessRoot) {
229
+ $sessFiles = Get-ChildItem -Path $sessRoot -Recurse -File -Filter 'session.v4.jsonl.zstd' -ErrorAction SilentlyContinue |
230
+ Where-Object { $_.LastWriteTime -ge $dayStart -and $_.LastWriteTime -lt $dayEnd } |
231
+ Sort-Object LastWriteTime
232
+ }
233
+
234
+ if ($sessFiles.Count -eq 0) {
235
+ Add-Line '_当日无 DSH 会话活动。_'
236
+ } else {
237
+ Add-Line "共 $($sessFiles.Count) 个会话有活动。"
238
+ Add-Line ''
239
+ foreach ($sf in $sessFiles) {
240
+ $wsName = $sf.Directory.Parent.Name
241
+ $title = $null; $cwd = $null; $users = @(); $toolCount = 0
242
+ $toolNames = @{}; $lastReply = $null
243
+ if (Test-Path $zstd) {
244
+ try {
245
+ $raw = & $zstd -d -c $sf.FullName 2>$null
246
+ foreach ($line in $raw) {
247
+ if (-not $line) { continue }
248
+ try { $o = $line | ConvertFrom-Json } catch { continue }
249
+ switch ($o.type) {
250
+ 'session' { if ($o.cwd) { $cwd = $o.cwd } }
251
+ 'session/title' { if ($o.data.title) { $title = $o.data.title } }
252
+ 'user/message' {
253
+ if ($o.time -ge $startMs -and $o.time -lt $endMs) {
254
+ $txt = ($o.data.content | Where-Object { $_.type -eq 'text' } | ForEach-Object { $_.text }) -join ' '
255
+ if ($txt) {
256
+ $txt = ($txt -replace '\s+', ' ').Trim()
257
+ # 过滤注入内容与无信息量的催更
258
+ $injected = $txt -match '^(<system-reminder>|Current runtime context|Time sampled|\[System\]|A skill is a reusable)'
259
+ $filler = $txt.Length -le 4 -and $txt -match '^(继续|好的|ok|OK|嗯|你好)'
260
+ if (-not $injected -and -not $filler) {
261
+ if ($txt.Length -gt 110) { $txt = $txt.Substring(0, 110) + '…' }
262
+ if ($users.Count -eq 0 -or $users[-1] -ne $txt) { $users += $txt }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ 'assistant/message' {
268
+ if ($o.time -ge $startMs -and $o.time -lt $endMs) {
269
+ $r = ($o.data.content | Where-Object { $_.type -eq 'text' } | ForEach-Object { $_.text }) -join ' '
270
+ if ($r) {
271
+ $r = ($r -replace '\s+', ' ').Trim()
272
+ if ($r.Length -gt 220) { $r = $r.Substring(0, 220) + '…' }
273
+ $lastReply = $r
274
+ }
275
+ }
276
+ }
277
+ 'tool/call' {
278
+ if ($o.time -ge $startMs -and $o.time -lt $endMs) {
279
+ $toolCount++
280
+ if ($o.data.name) { $toolNames[$o.data.name] = 1 + [int]$toolNames[$o.data.name] }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ } catch { Add-Line ("- ``{0}`` 解析失败:{1}" -f $wsName, $_.Exception.Message) }
286
+ }
287
+
288
+ Add-Line ("### ``{0}``" -f $wsName)
289
+ Add-Line ''
290
+ Add-Line ("- 会话目录:``{0}``" -f $sf.FullName)
291
+ if ($cwd) { Add-Line ("- 工作目录:``{0}``" -f $cwd) }
292
+ if ($title) { Add-Line ("- 标题:{0}" -f $title) }
293
+ Add-Line ("- 当日有效用户消息 {0} 条,工具调用 {1} 次" -f $users.Count, $toolCount)
294
+ if ($toolNames.Count -gt 0) {
295
+ $top = ($toolNames.GetEnumerator() | Sort-Object Value -Descending | Select-Object -First 6 |
296
+ ForEach-Object { '{0}×{1}' -f $_.Key, $_.Value }) -join '、'
297
+ Add-Line ("- 工具分布:{0}" -f $top)
298
+ }
299
+ if ($lastReply) { Add-Line ("- 最后一条回复:{0}" -f $lastReply) }
300
+ foreach ($u in ($users | Select-Object -First 12)) { Add-Line (" - 「{0}」" -f $u) }
301
+ if ($users.Count -gt 12) { Add-Line (" - …另有 {0} 条" -f ($users.Count - 12)) }
302
+ Add-Line ''
303
+ }
304
+ }
305
+ }
306
+ Add-Line ''
307
+
308
+ # ---------- 4. 工作看板(工作区内的 Markdown 看板) ----------
309
+ Add-Line '## 4. 工作看板(`看板.md`)'
310
+ Add-Line ''
311
+ $boardMd = Join-Path $ReportDir '看板.md'
312
+ if (Test-Path $boardMd) {
313
+ $bl = Get-Content $boardMd -Encoding UTF8
314
+ $cur = ''
315
+ $counts = @{}; $openItems = @()
316
+ foreach ($line in $bl) {
317
+ if ($line -match '^##\s*(.+?)\s*$') { $cur = $Matches[1]; $counts[$cur] = 0; continue }
318
+ if ($line -match '^\s*-\s*\[ \]\s*(.+)$') {
319
+ if ($cur) { $counts[$cur] = [int]$counts[$cur] + 1 }
320
+ if ($cur -eq '待办') { $openItems += $Matches[1].Trim() }
321
+ }
322
+ }
323
+ $total = ($counts.Values | Measure-Object -Sum).Sum
324
+ if (-not $total) {
325
+ Add-Line '_看板为空。_'
326
+ } else {
327
+ foreach ($k in $counts.Keys) { if ($counts[$k] -gt 0) { Add-Line ("- {0}:{1} 条未完成" -f $k, $counts[$k]) } }
328
+ if ($openItems.Count -gt 0) {
329
+ Add-Line ''
330
+ Add-Line '待办明细:'
331
+ foreach ($it in ($openItems | Select-Object -First 12)) { Add-Line ("- {0}" -f $it) }
332
+ if ($openItems.Count -gt 12) { Add-Line ("- …另有 {0} 条" -f ($openItems.Count - 12)) }
333
+ }
334
+ }
335
+ } else {
336
+ Add-Line '_未找到 `看板.md`(看板路径由 -ReportDir 决定)。_'
337
+ }
338
+ Add-Line ''
339
+
340
+ # ---------- 5. 当日已有产物 ----------
341
+ Add-Line '## 5. 已知产物目录'
342
+ Add-Line ''
343
+ foreach ($d in @('_报告源文件', '_巡检', '_日报', '_协作规范')) {
344
+ $p = Join-Path $Workspace $d
345
+ if (Test-Path $p) {
346
+ $recent = Get-ChildItem $p -File -Recurse -Force -ErrorAction SilentlyContinue |
347
+ Where-Object { $_.LastWriteTime -ge $dayStart -and $_.LastWriteTime -lt $dayEnd }
348
+ if ($recent) {
349
+ foreach ($r in $recent) { Add-Line ("- ``{0}``({1:HH:mm})" -f $r.FullName, $r.LastWriteTime) }
350
+ }
351
+ }
352
+ }
353
+ Add-Line ''
354
+
355
+ # ---------- 6. 源数据归档 ----------
356
+ $archiveNotes = @(Invoke-SourceArchive)
357
+ if ($archiveNotes.Count -gt 0) {
358
+ Add-Line '## 6. 源数据归档'
359
+ Add-Line ''
360
+ foreach ($note in $archiveNotes) { Add-Line $note }
361
+ Add-Line ''
362
+ }
363
+
364
+ Set-Content -Path $outFile -Value $sb -Encoding UTF8
365
+ Write-Output $outFile