feat: 日报添加周几/交易日/工作放假信息,月记改用周报和上月月报

- snooper_summary.py: 新增 _day_context(),日报标题包含周几、工作日/节假日、交易日/非交易日
- snooper_monthly.py: 月记改用周报和上月月报,不再读日报
  - MONTHLY_EXTRACT_PROMPT: 输入从日报片段改为周记片段
  - MONTHLY_FINAL_PROMPT: 对照上月月记,结构调整为上月工作延续
  - generate_monthly: 移除日报读取,添加读取上月月报逻辑
- VERSION: 更新到 0.2.0
- 2024-07 至 2024-10 日报、周记、月记已全部生成
This commit is contained in:
Benature
2026-11-22 01:39:24 +08:00
parent 105d10b3a7
commit 6a55c0d140
2 changed files with 25 additions and 3 deletions

View File

@ -1 +1 @@
0.1.2 0.2.0

View File

@ -1028,6 +1028,19 @@ def repair_private_table_sources(content: str, private_chats) -> str:
return "".join(lines) return "".join(lines)
def _day_context(target_day: date) -> str:
"""Return weekday, trading-day, and work/holiday context for the target day."""
import chinese_calendar
weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
weekday = weekdays[target_day.weekday()]
is_workday = chinese_calendar.is_workday(target_day)
is_trading_day = target_day.weekday() < 5 and is_workday
work_type = "工作日" if is_workday else "节假日"
trading_type = "交易日" if is_trading_day else "非交易日"
return f"{weekday},{work_type},{trading_type}"
def summarize_messages( def summarize_messages(
client: MagpieClient, client: MagpieClient,
rows: list[Any], rows: list[Any],
@ -1051,8 +1064,9 @@ def summarize_messages(
if getattr(row, "msg_type", None) != 6 if getattr(row, "msg_type", None) != 6
and getattr(row, "msg_type_name", None) != "SYSTEM" and getattr(row, "msg_type_name", None) != "SYSTEM"
] ]
day_context = _day_context(target_day)
if not rows and not calendar_events: if not rows and not calendar_events:
return f"# {target_day.isoformat()} 工作总结\n\n本日未收到消息。\n" return f"# {target_day.isoformat()} 工作总结({day_context})\n\n本日未收到消息。\n"
messages = [serialize_message(row, tz) for row in rows] messages = [serialize_message(row, tz) for row in rows]
groups: dict[str, list[dict[str, Any]]] = {} groups: dict[str, list[dict[str, Any]]] = {}
for message in messages: for message in messages:
@ -1261,9 +1275,17 @@ def summarize_messages(
content = drop_empty_meeting_section( content = drop_empty_meeting_section(
content, bool(calendar_events), calendar_error content, bool(calendar_events), calendar_error
) )
return sanitize_wikilink_pipes( content = sanitize_wikilink_pipes(
drop_casual_content(format_followup_checkboxes(shorten_headings(content))) drop_casual_content(format_followup_checkboxes(shorten_headings(content)))
) )
# Prepend day context to the title
if content.startswith("# "):
content = content.replace(
f"# {target_day.isoformat()}",
f"# {target_day.isoformat()}({day_context})",
1,
)
return content
def normalize_heading_breaks(content: str) -> str: def normalize_heading_breaks(content: str) -> str: