feat: 优化周记周期与总结输出

This commit is contained in:
Benature
2026-11-21 00:52:00 +08:00
parent 81b6ff7a39
commit f177a857a5
6 changed files with 110 additions and 30 deletions

View File

@ -6,8 +6,10 @@ import pytest
from snooper_summary import summarize_messages
from snooper_weekly import (
WEEKLY_FINAL_PROMPT,
WeeklyError,
generate_weekly,
iso_week_label,
load_previous_weekly_background,
week_bounds,
)
@ -15,16 +17,18 @@ from snooper_weekly import (
def test_week_bounds_use_monday_and_sunday():
assert week_bounds(date(2024, 7, 4)) == (
date(2024, 7, 1), date(2024, 7, 7)
date(2024, 6, 30), date(2024, 7, 6)
)
assert iso_week_label(date(2024, 6, 30)) == "2024-W26"
assert "# {weekly_date} 周记" in WEEKLY_FINAL_PROMPT
def test_previous_weekly_background_uses_previous_monday(tmp_path):
output = {
"summary": str(tmp_path / "Daily" / "Msg{date}.md"),
"weekly": str(tmp_path / "Weekly" / "Week{date}.md"),
"summary": str(tmp_path / "Daily" / "MsgYYYY-MM-DD.md"),
"weekly": str(tmp_path / "Weekly" / "MsgWYYYY-WW.md"),
}
weekly = tmp_path / "Weekly" / "Week2024-07-01.md"
weekly = tmp_path / "Weekly" / "MsgW2024-26.md"
weekly.parent.mkdir(parents=True)
weekly.write_text("---\ntype: weekly\n---\n\n上周合成周记", encoding="utf-8")
@ -45,11 +49,11 @@ def test_generate_weekly_reads_previous_week_and_sanitizes_links(
(daily / f"Msg{day}.md").write_text(
f"---\nmodel: synthetic\n---\n\n# {day}\n合成进展", encoding="utf-8"
)
(weekly / "Week2024-07-01.md").write_text("上周合成周记", encoding="utf-8")
(weekly / "MsgW2024-26.md").write_text("上周合成周记", encoding="utf-8")
config = tmp_path / "config.yaml"
config.write_text(
f"output:\n summary: '{daily}/Msg{{date}}.md'\n"
f" weekly: '{weekly}/Week{{date}}.md'\n",
f"output:\n summary: '{daily}/MsgYYYY-MM-DD.md'\n"
f" weekly: '{weekly}/MsgWYYYY-WW.md'\n",
encoding="utf-8",
)
@ -76,6 +80,7 @@ def test_generate_weekly_reads_previous_week_and_sanitizes_links(
text = output.read_text(encoding="utf-8")
assert "[[审核群|指数内容部落]]" in text
assert "type: weekly" in text
assert "date:" not in text
assert "上周合成周记" in clients[0].prompts[-1]