dsh-work-summary 0.2.0 → 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/PROMPT.md +21 -2
- package/README.md +42 -49
- package/client.js +867 -27
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +136 -25
- package/index.js +986 -51
- package/package.json +4 -4
- package/scripts/collect-day.ps1 +95 -0
- package/scripts/collect-range.ps1 +388 -0
- package/scripts/push-to-board.ps1 +182 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-work-summary",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Daily work
|
|
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
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"PROMPT.md",
|
|
18
18
|
"README.md",
|
|
19
19
|
"locale/*.json",
|
|
20
|
-
"docs",
|
|
20
|
+
"docs/DETAIL.md",
|
|
21
21
|
"icon.svg",
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dsh": ">=0.2.3-alpha.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"test": "node test/route.test.mjs",
|
|
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
38
|
"check": "node --check index.js && node --check client.js"
|
|
39
39
|
},
|
|
40
40
|
"dsh": {
|
package/scripts/collect-day.ps1
CHANGED
|
@@ -49,6 +49,92 @@ function Test-SkipPath([string]$rel) {
|
|
|
49
49
|
$sb = [System.Collections.Generic.List[string]]::new()
|
|
50
50
|
function Add-Line([string]$s = '') { $sb.Add($s) }
|
|
51
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
|
+
|
|
52
138
|
Add-Line "# 工作痕迹源数据 · $Date"
|
|
53
139
|
Add-Line ''
|
|
54
140
|
Add-Line "> 采集窗口:$sinceArg ~ $untilArg(本地时区 $([DateTime]::Now.ToString('zzz')))"
|
|
@@ -266,5 +352,14 @@ foreach ($d in @('_报告源文件', '_巡检', '_日报', '_协作规范')) {
|
|
|
266
352
|
}
|
|
267
353
|
Add-Line ''
|
|
268
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
|
+
|
|
269
364
|
Set-Content -Path $outFile -Value $sb -Encoding UTF8
|
|
270
365
|
Write-Output $outFile
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
# collect-range.ps1 —— 收集一个日期区间的"工作痕迹",供周报/月报聚合引用。
|
|
2
|
+
# 用法:
|
|
3
|
+
# pwsh -NoProfile -File collect-range.ps1 -From 2026-11-18 -To 2026-11-24
|
|
4
|
+
# pwsh -NoProfile -File collect-range.ps1 -From 2026-11-01 -To 2026-11-30 -NoSessions
|
|
5
|
+
# 输出:<ReportDir>\_源数据\周期-YYYY-MM-DD_YYYY-MM-DD.md(同时打印路径)
|
|
6
|
+
# 本脚本属于 dsh-work-summary 插件仓库;扫哪里由 -Workspace 决定,产物写哪由 -ReportDir 决定。
|
|
7
|
+
# 与 collect-day.ps1 的分工:单日采集扫工作区/会话;区间采集以已有日报为主,把跨天事实摊平。
|
|
8
|
+
|
|
9
|
+
param(
|
|
10
|
+
[Parameter(Mandatory = $true)][string]$From,
|
|
11
|
+
[Parameter(Mandatory = $true)][string]$To,
|
|
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 { $fromDay = [datetime]::ParseExact($From, 'yyyy-MM-dd', $null) }
|
|
22
|
+
catch { throw "起始日期格式应为 yyyy-MM-dd,收到:$From" }
|
|
23
|
+
try { $toDay = [datetime]::ParseExact($To, 'yyyy-MM-dd', $null) }
|
|
24
|
+
catch { throw "结束日期格式应为 yyyy-MM-dd,收到:$To" }
|
|
25
|
+
if ($toDay -lt $fromDay) { throw "结束日期不能早于起始日期:$From ~ $To" }
|
|
26
|
+
|
|
27
|
+
$span = ($toDay - $fromDay).Days + 1
|
|
28
|
+
if ($span -gt 400) { throw "区间最长 400 天,当前 $span 天:$From ~ $To" }
|
|
29
|
+
|
|
30
|
+
$rangeEnd = $toDay.AddDays(1)
|
|
31
|
+
$days = @()
|
|
32
|
+
for ($d = $fromDay; $d -le $toDay; $d = $d.AddDays(1)) { $days += $d.ToString('yyyy-MM-dd') }
|
|
33
|
+
|
|
34
|
+
$outDir = Join-Path $ReportDir '_源数据'
|
|
35
|
+
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
|
36
|
+
$outFile = Join-Path $outDir ("周期-{0}_{1}.md" -f $From, $To)
|
|
37
|
+
|
|
38
|
+
$skipDirs = @('node_modules', '.pnpm-store', '.git', 'dist', 'build', '.next', 'target',
|
|
39
|
+
'temp', 'tmp', '.cache', '__pycache__', '_源数据', '.dsh-vision-router',
|
|
40
|
+
'.dsh', 'anatomy', 'shots', '备份', '_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
|
+
function Get-Section([string[]]$content, [string]$number) {
|
|
53
|
+
$start = -1
|
|
54
|
+
for ($i = 0; $i -lt $content.Count; $i++) {
|
|
55
|
+
if ($content[$i] -match ('^##\s*' + $number + '\s*[、..]')) { $start = $i + 1; break }
|
|
56
|
+
}
|
|
57
|
+
if ($start -lt 0) { return @() }
|
|
58
|
+
$out = @()
|
|
59
|
+
for ($i = $start; $i -lt $content.Count; $i++) {
|
|
60
|
+
if ($content[$i] -match '^##\s') { break }
|
|
61
|
+
$out += $content[$i]
|
|
62
|
+
}
|
|
63
|
+
return $out
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function Get-NonEmpty([string[]]$lines) {
|
|
67
|
+
$out = @()
|
|
68
|
+
foreach ($l in $lines) {
|
|
69
|
+
$t = $l.Trim()
|
|
70
|
+
if ($t -eq '' -or $t -match '^---+$') { continue }
|
|
71
|
+
$out += $t
|
|
72
|
+
}
|
|
73
|
+
return $out
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function Get-ListItems([string[]]$lines) {
|
|
77
|
+
$out = @()
|
|
78
|
+
foreach ($l in $lines) {
|
|
79
|
+
if ($l -match '^\s*(?:\d+[\.、]|[-*])\s+(.+)$') { $out += $Matches[1].Trim() }
|
|
80
|
+
}
|
|
81
|
+
return $out
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function Get-AgeDays([string]$text) {
|
|
85
|
+
if ($text -match '^(\d{4}-\d{2}-\d{2})') {
|
|
86
|
+
try {
|
|
87
|
+
$d = [datetime]::ParseExact($Matches[1], 'yyyy-MM-dd', $null)
|
|
88
|
+
$age = ((Get-Date).Date - $d.Date).Days
|
|
89
|
+
if ($age -ge 0) { return $age }
|
|
90
|
+
} catch { }
|
|
91
|
+
}
|
|
92
|
+
return -1
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function Format-Size([long]$bytes) {
|
|
96
|
+
if ($bytes -ge 1MB) { return ('{0:N1} MB' -f ($bytes / 1MB)) }
|
|
97
|
+
if ($bytes -ge 1KB) { return ('{0:N1} KB' -f ($bytes / 1KB)) }
|
|
98
|
+
return "$bytes B"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# ---------- 读取区间内的日报与源数据 ----------
|
|
102
|
+
$daily = @{}
|
|
103
|
+
$missingDaily = @()
|
|
104
|
+
$dailySizes = @{}
|
|
105
|
+
foreach ($day in $days) {
|
|
106
|
+
$p = Join-Path $ReportDir "日报-$day.md"
|
|
107
|
+
if (Test-Path $p) {
|
|
108
|
+
$daily[$day] = @(Get-Content $p -Encoding UTF8)
|
|
109
|
+
$dailySizes[$day] = (Get-Item $p).Length
|
|
110
|
+
} else {
|
|
111
|
+
$missingDaily += $day
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
$missingSource = @()
|
|
116
|
+
foreach ($day in $days) {
|
|
117
|
+
if (-not (Test-Path (Join-Path $outDir "$day.md"))) { $missingSource += $day }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# ---------- 工作区改动 ----------
|
|
121
|
+
$files = @()
|
|
122
|
+
if (Test-Path $Workspace) {
|
|
123
|
+
$files = Get-ChildItem -Path $Workspace -Recurse -File -Force -ErrorAction SilentlyContinue |
|
|
124
|
+
Where-Object {
|
|
125
|
+
$_.LastWriteTime -ge $fromDay -and $_.LastWriteTime -lt $rangeEnd -and
|
|
126
|
+
-not (Test-SkipPath $_.FullName.Substring($Workspace.Length))
|
|
127
|
+
} | Sort-Object LastWriteTime
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# ---------- Git 区间提交 ----------
|
|
131
|
+
$gitExe = (Get-Command git -ErrorAction SilentlyContinue).Source
|
|
132
|
+
$repos = @()
|
|
133
|
+
if ($gitExe -and (Test-Path $Workspace)) {
|
|
134
|
+
$repos = Get-ChildItem -Path $Workspace -Directory -Recurse -Depth 3 -Force -ErrorAction SilentlyContinue |
|
|
135
|
+
Where-Object { Test-Path (Join-Path $_.FullName '.git') } |
|
|
136
|
+
Select-Object -ExpandProperty FullName
|
|
137
|
+
}
|
|
138
|
+
$gitBlocks = @()
|
|
139
|
+
$gitCommitCount = 0
|
|
140
|
+
foreach ($repo in $repos) {
|
|
141
|
+
$rel = if ($repo -eq $Workspace) { '.' } else { $repo.Substring($Workspace.Length).TrimStart('\') }
|
|
142
|
+
$log = @(& $gitExe -C $repo log --since="$From 00:00:00" --until="$To 23:59:59" --pretty='%h %ad %s' --date=format:'%m-%d' --no-decorate 2>$null)
|
|
143
|
+
$branch = (& $gitExe -C $repo rev-parse --abbrev-ref HEAD 2>$null)
|
|
144
|
+
$dirty = @(& $gitExe -C $repo status --porcelain 2>$null).Count
|
|
145
|
+
if ($log.Count -gt 0 -or $dirty -gt 0) {
|
|
146
|
+
$gitBlocks += [pscustomobject]@{ Rel = $rel; Branch = $branch; Log = $log; Dirty = $dirty }
|
|
147
|
+
$gitCommitCount += $log.Count
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# ---------- 看板 ----------
|
|
152
|
+
$boardPath = Join-Path $ReportDir '看板.md'
|
|
153
|
+
$boardCounts = @{}
|
|
154
|
+
$openItems = @()
|
|
155
|
+
if (Test-Path $boardPath) {
|
|
156
|
+
$cur = ''
|
|
157
|
+
foreach ($line in (Get-Content $boardPath -Encoding UTF8)) {
|
|
158
|
+
if ($line -match '^##\s*(.+?)\s*$') {
|
|
159
|
+
$cur = $Matches[1]
|
|
160
|
+
if (-not $boardCounts.ContainsKey($cur)) { $boardCounts[$cur] = 0 }
|
|
161
|
+
continue
|
|
162
|
+
}
|
|
163
|
+
if ($line -match '^\s*-\s*\[ \]\s*(.+)$') {
|
|
164
|
+
if ($cur) { $boardCounts[$cur] = [int]$boardCounts[$cur] + 1 }
|
|
165
|
+
$openItems += $Matches[1].Trim()
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
$openTotal = 0
|
|
170
|
+
foreach ($v in $boardCounts.Values) { $openTotal += [int]$v }
|
|
171
|
+
|
|
172
|
+
# ---------- 输出 ----------
|
|
173
|
+
Add-Line "# 周期痕迹源数据 · $From ~ $To"
|
|
174
|
+
Add-Line ''
|
|
175
|
+
Add-Line "> 采集窗口:$From 00:00:00 ~ $To 23:59:59($span 天,本地时区 $([DateTime]::Now.ToString('zzz')))"
|
|
176
|
+
Add-Line '> 本文件由 `collect-range.ps1` 只读生成,用于周报/月报的事实依据;不要手工编辑。'
|
|
177
|
+
Add-Line ''
|
|
178
|
+
|
|
179
|
+
Add-Line '## 1. 区间概况'
|
|
180
|
+
Add-Line ''
|
|
181
|
+
Add-Line "- 区间:$From ~ $To($span 天,含首尾)"
|
|
182
|
+
Add-Line "- 日报:有 $(($days.Count - $missingDaily.Count)) 天 / 缺 $($missingDaily.Count) 天"
|
|
183
|
+
Add-Line "- 源数据:有 $(($days.Count - $missingSource.Count)) 天 / 缺 $($missingSource.Count) 天"
|
|
184
|
+
Add-Line "- 工作区改动:$($files.Count) 个文件"
|
|
185
|
+
Add-Line "- Git:$($repos.Count) 个仓库,$gitCommitCount 条提交"
|
|
186
|
+
Add-Line "- 看板:未完成 $openTotal 条"
|
|
187
|
+
Add-Line ''
|
|
188
|
+
|
|
189
|
+
Add-Line '## 2. 日报覆盖'
|
|
190
|
+
Add-Line ''
|
|
191
|
+
if ($daily.Count -eq 0) {
|
|
192
|
+
Add-Line '_区间内没有任何日报。_'
|
|
193
|
+
} else {
|
|
194
|
+
foreach ($day in $days) {
|
|
195
|
+
if ($daily.ContainsKey($day)) {
|
|
196
|
+
Add-Line ("- ``日报-$day.md``({0})" -f (Format-Size $dailySizes[$day]))
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if ($missingDaily.Count -gt 0) {
|
|
200
|
+
Add-Line ''
|
|
201
|
+
Add-Line ("缺日报 {0} 天:{1}" -f $missingDaily.Count, ($missingDaily -join '、'))
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
Add-Line ''
|
|
205
|
+
|
|
206
|
+
Add-Line '## 3. 每日概览摘录(一)'
|
|
207
|
+
Add-Line ''
|
|
208
|
+
if ($daily.Count -eq 0) {
|
|
209
|
+
Add-Line '_无日报可摘。_'
|
|
210
|
+
} else {
|
|
211
|
+
foreach ($day in $days) {
|
|
212
|
+
if (-not $daily.ContainsKey($day)) { continue }
|
|
213
|
+
Add-Line "### $day"
|
|
214
|
+
Add-Line ''
|
|
215
|
+
$lines = @(Get-NonEmpty @(Get-Section $daily[$day] '一'))
|
|
216
|
+
if ($lines.Count -eq 0) {
|
|
217
|
+
Add-Line '_该日概览为空。_'
|
|
218
|
+
} else {
|
|
219
|
+
foreach ($l in ($lines | Select-Object -First 10)) { Add-Line "- $l" }
|
|
220
|
+
}
|
|
221
|
+
Add-Line ''
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Add-Line '## 4. 产出汇总(三)'
|
|
226
|
+
Add-Line ''
|
|
227
|
+
if ($daily.Count -eq 0) {
|
|
228
|
+
Add-Line '_无日报可摘。_'
|
|
229
|
+
} else {
|
|
230
|
+
foreach ($day in $days) {
|
|
231
|
+
if (-not $daily.ContainsKey($day)) { continue }
|
|
232
|
+
Add-Line "### $day"
|
|
233
|
+
Add-Line ''
|
|
234
|
+
$lines = @(Get-NonEmpty @(Get-Section $daily[$day] '三'))
|
|
235
|
+
if ($lines.Count -eq 0) {
|
|
236
|
+
Add-Line '_该日没有产出记录。_'
|
|
237
|
+
} else {
|
|
238
|
+
foreach ($l in ($lines | Select-Object -First 40)) { Add-Line $l }
|
|
239
|
+
}
|
|
240
|
+
Add-Line ''
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
Add-Line '## 5. 问题与风险汇总(四)'
|
|
245
|
+
Add-Line ''
|
|
246
|
+
if ($daily.Count -eq 0) {
|
|
247
|
+
Add-Line '_无日报可摘。_'
|
|
248
|
+
} else {
|
|
249
|
+
foreach ($day in $days) {
|
|
250
|
+
if (-not $daily.ContainsKey($day)) { continue }
|
|
251
|
+
Add-Line "### $day"
|
|
252
|
+
Add-Line ''
|
|
253
|
+
$lines = @(Get-NonEmpty @(Get-Section $daily[$day] '四'))
|
|
254
|
+
if ($lines.Count -eq 0) {
|
|
255
|
+
Add-Line '_该日没有风险记录。_'
|
|
256
|
+
} else {
|
|
257
|
+
foreach ($l in ($lines | Select-Object -First 20)) { Add-Line $l }
|
|
258
|
+
}
|
|
259
|
+
Add-Line ''
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
Add-Line '## 6. 明日开场清单汇总(六)'
|
|
264
|
+
Add-Line ''
|
|
265
|
+
if ($daily.Count -eq 0) {
|
|
266
|
+
Add-Line '_无日报可摘。_'
|
|
267
|
+
} else {
|
|
268
|
+
foreach ($day in $days) {
|
|
269
|
+
if (-not $daily.ContainsKey($day)) { continue }
|
|
270
|
+
$items = @(Get-ListItems @(Get-Section $daily[$day] '六'))
|
|
271
|
+
if ($items.Count -eq 0) { continue }
|
|
272
|
+
Add-Line "### $day"
|
|
273
|
+
Add-Line ''
|
|
274
|
+
foreach ($it in $items) { Add-Line "- $it" }
|
|
275
|
+
Add-Line ''
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
Add-Line '## 7. 工作看板现状'
|
|
280
|
+
Add-Line ''
|
|
281
|
+
if ($boardCounts.Count -eq 0) {
|
|
282
|
+
Add-Line '_看板为空或不存在。_'
|
|
283
|
+
} else {
|
|
284
|
+
$parts = @()
|
|
285
|
+
foreach ($k in @('待办', '进行中', '已完成', '已放弃')) {
|
|
286
|
+
if ($boardCounts.ContainsKey($k)) { $parts += ("{0} {1}" -f $k, $boardCounts[$k]) }
|
|
287
|
+
}
|
|
288
|
+
foreach ($k in $boardCounts.Keys) {
|
|
289
|
+
if (@('待办', '进行中', '已完成', '已放弃') -notcontains $k) { $parts += ("{0} {1}" -f $k, $boardCounts[$k]) }
|
|
290
|
+
}
|
|
291
|
+
Add-Line ("- " + ($parts -join ' / '))
|
|
292
|
+
if ($openItems.Count -gt 0) {
|
|
293
|
+
Add-Line ''
|
|
294
|
+
Add-Line '### 未完成明细(含已挂天数)'
|
|
295
|
+
Add-Line ''
|
|
296
|
+
foreach ($it in ($openItems | Select-Object -First 30)) {
|
|
297
|
+
$age = Get-AgeDays $it
|
|
298
|
+
$tag = if ($age -ge 0) { "已挂 $age 天" } else { '未标日期' }
|
|
299
|
+
Add-Line "- ($tag)$it"
|
|
300
|
+
}
|
|
301
|
+
if ($openItems.Count -gt 30) { Add-Line "- …另有 $($openItems.Count - 30) 条" }
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
Add-Line ''
|
|
305
|
+
|
|
306
|
+
Add-Line '## 8. Git 区间提交'
|
|
307
|
+
Add-Line ''
|
|
308
|
+
if (-not $gitExe) {
|
|
309
|
+
Add-Line '_未找到 git,跳过。_'
|
|
310
|
+
} elseif ($gitBlocks.Count -eq 0) {
|
|
311
|
+
Add-Line '_区间内没有 Git 提交或未提交改动。_'
|
|
312
|
+
} else {
|
|
313
|
+
foreach ($b in $gitBlocks) {
|
|
314
|
+
Add-Line ("### ``{0}``(分支 {1},当前未提交 {2})" -f $b.Rel, $b.Branch, $b.Dirty)
|
|
315
|
+
Add-Line ''
|
|
316
|
+
if ($b.Log.Count -gt 0) {
|
|
317
|
+
foreach ($l in ($b.Log | Select-Object -First 80)) { Add-Line "- $l" }
|
|
318
|
+
} else {
|
|
319
|
+
Add-Line '_区间内无提交。_'
|
|
320
|
+
}
|
|
321
|
+
Add-Line ''
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
Add-Line ''
|
|
325
|
+
|
|
326
|
+
Add-Line '## 9. 工作区区间改动'
|
|
327
|
+
Add-Line ''
|
|
328
|
+
if ($files.Count -eq 0) {
|
|
329
|
+
Add-Line '_区间内工作区无文件改动。_'
|
|
330
|
+
} else {
|
|
331
|
+
Add-Line "共 $($files.Count) 个文件。"
|
|
332
|
+
Add-Line ''
|
|
333
|
+
Add-Line '### 按顶层目录汇总'
|
|
334
|
+
Add-Line ''
|
|
335
|
+
$files | Group-Object { ($_.FullName.Substring($Workspace.Length).TrimStart('\') -split '[\\/]')[0] } |
|
|
336
|
+
Sort-Object Count -Descending |
|
|
337
|
+
ForEach-Object { Add-Line ("- ``{0}``:{1} 个文件" -f $_.Name, $_.Count) }
|
|
338
|
+
Add-Line ''
|
|
339
|
+
Add-Line '### 最近改动的 40 个文件'
|
|
340
|
+
Add-Line ''
|
|
341
|
+
Add-Line '| 时间 | 大小 | 相对路径 |'
|
|
342
|
+
Add-Line '|------|------|----------|'
|
|
343
|
+
$recent = $files | Sort-Object LastWriteTime -Descending | Select-Object -First 40
|
|
344
|
+
foreach ($f in $recent) {
|
|
345
|
+
$rel = $f.FullName.Substring($Workspace.Length).TrimStart('\')
|
|
346
|
+
Add-Line ("| {0:MM-dd HH:mm} | {1} | {2} |" -f $f.LastWriteTime, (Format-Size $f.Length), $rel)
|
|
347
|
+
}
|
|
348
|
+
if ($files.Count -gt 40) { Add-Line ''; Add-Line "- …另有 $($files.Count - 40) 个更早的文件" }
|
|
349
|
+
}
|
|
350
|
+
Add-Line ''
|
|
351
|
+
|
|
352
|
+
Add-Line '## 10. 源数据覆盖'
|
|
353
|
+
Add-Line ''
|
|
354
|
+
if ($missingSource.Count -eq 0) {
|
|
355
|
+
Add-Line '_区间内每天的源数据都在。_'
|
|
356
|
+
} else {
|
|
357
|
+
Add-Line ("缺源数据 {0} 天:{1}" -f $missingSource.Count, ($missingSource -join '、'))
|
|
358
|
+
}
|
|
359
|
+
Add-Line ''
|
|
360
|
+
|
|
361
|
+
Add-Line '## 11. 复发候选(风险小节跨天重复)'
|
|
362
|
+
Add-Line ''
|
|
363
|
+
$riskDays = @{}
|
|
364
|
+
foreach ($day in $days) {
|
|
365
|
+
if (-not $daily.ContainsKey($day)) { continue }
|
|
366
|
+
foreach ($line in @(Get-ListItems @(Get-Section $daily[$day] '四'))) {
|
|
367
|
+
$key = ($line -replace '^\s*(?:\d+[\.、]|[-*])\s*', '' -replace '[`*]', '' -replace '([^)]*)', '').Trim()
|
|
368
|
+
# 数字与标点归一化:「第 12 天」「第 13 天」算同一件事
|
|
369
|
+
$key = $key -replace '\d+', '#'
|
|
370
|
+
$key = $key -replace '[\s,。;:、!?,.;:!?()()【】\[\]「」“”"-]', ''
|
|
371
|
+
if ($key.Length -lt 6) { continue }
|
|
372
|
+
if ($key.Length -gt 40) { $key = $key.Substring(0, 40) + '…' }
|
|
373
|
+
if (-not $riskDays.ContainsKey($key)) { $riskDays[$key] = @() }
|
|
374
|
+
if (-not ($riskDays[$key] -contains $day)) { $riskDays[$key] += $day }
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
$repeat = $riskDays.GetEnumerator() | Where-Object { $_.Value.Count -ge 2 } | Sort-Object { $_.Value.Count } -Descending
|
|
378
|
+
if (-not $repeat) {
|
|
379
|
+
Add-Line '_没有跨天重复的风险项。_'
|
|
380
|
+
} else {
|
|
381
|
+
foreach ($entry in ($repeat | Select-Object -First 10)) {
|
|
382
|
+
Add-Line ("- {0}:{1} 天({2})" -f $entry.Key, $entry.Value.Count, ($entry.Value -join '、'))
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
Add-Line ''
|
|
386
|
+
|
|
387
|
+
Set-Content -Path $outFile -Value $sb -Encoding UTF8
|
|
388
|
+
Write-Output $outFile
|