fix: 周记按周一至周日生成
This commit is contained in:
@ -110,7 +110,7 @@ VIDEO 消息不设每日数量上限:下载到 `~/.larkx/videos`,每个视
|
||||
|
||||
日报在读取本地消息后、媒体和模型分析前,会通过飞书 `joinTimesSec` 校验当前用户的实际入群时间,排除当时尚未入群的群聊历史;私聊不受影响。入群时间缓存到 `~/.larkx/chat-join-times.json`,无法确认入群时间的群默认排除,避免把可见历史误当作当时已参与。
|
||||
|
||||
周记在每周日总结刚结束的上一段周日至周六,文件名按统计周最后一天(周六)使用 `%U` 年周序号(如 `MsgW2024-26.md`),标题使用实际写作日(周日),frontmatter 不设置 `date` 属性;周记使用统计周日报和上周周记生成;下一周日报会读取上周周记作为背景,下一篇周记同样读取上周周记做延续性对照。缺少上周周记时添加 `no_previous_weekly` 标签,不编造历史。批量补日志按“本周日报 → 本周周记 → 下周日报”的顺序执行,未结束的跨月周不提前生成周记。
|
||||
周记在每周日总结当天结束的周一至周日,文件名按统计周最后一天(周日)使用 `%U` 年周序号(如 `MsgW2024-27.md`),标题为 `周记(开始日期 至 结束日期)`,周记前不添加写作日期;frontmatter 不设置 `date` 属性;周记使用统计周日报和上周周记生成;下一周日报会读取上周周记作为背景,下一篇周记同样读取上周周记做延续性对照。缺少上周周记时添加 `no_previous_weekly` 标签,不编造历史。批量补日志按“本周日报 → 本周周记 → 下周日报”的顺序执行,未结束的跨月周不提前生成周记。
|
||||
|
||||
```bash
|
||||
# 生成指定日期所在自然周的周记
|
||||
@ -219,7 +219,7 @@ chats:
|
||||
|
||||
## 版本号
|
||||
|
||||
日报 frontmatter 包含 `version`。版本由 tracked `VERSION`、当前 commit 和工作区状态组成:干净时为 `0.1.0+g<commit>`,有未提交改动时为 `0.1.0.dev0+g<commit>`。不会自动执行 `git clean -fd`。
|
||||
日报 frontmatter 包含 `version`。版本由 tracked `VERSION`、当前 commit 和工作区状态组成:干净时仅显示 `VERSION`(如 `0.2.1`),有未提交改动时为 `0.2.1.dev0+g<commit>`。不会自动执行 `git clean -fd`。
|
||||
|
||||
每次 commit 前递增 patch 版本,并将 `VERSION` 一并提交:
|
||||
|
||||
|
||||
@ -10,8 +10,8 @@ VERSION_FILE = PROJECT_ROOT / "VERSION"
|
||||
|
||||
|
||||
def format_version(base_version: str, commit: str, dirty: bool) -> str:
|
||||
base = f"{base_version.strip()}.dev0" if dirty else base_version.strip()
|
||||
return f"{base}+g{commit}"
|
||||
base = base_version.strip()
|
||||
return f"{base}.dev0+g{commit}" if dirty else base
|
||||
|
||||
|
||||
def get_version(root: Path | None = None) -> str:
|
||||
|
||||
@ -43,8 +43,8 @@ WEEKLY_FINAL_PROMPT = """请根据 {week_start} 至 {week_end} 的日报提取
|
||||
3. 对照上周周记,区分本周继续推进和本周未见延续;上周周记为空时明确写无法判断,不得编造。
|
||||
4. 下周跟进建议只保留当前用户明确负责或需要回复、决策、协作推进的事项,每项使用 - [ ] checkbox。
|
||||
5. 运维信息统一放在全文最后,不在前文重复。
|
||||
6. 使用以下结构:
|
||||
# {weekly_date} 周记({week_start} 至 {week_end})
|
||||
6. 使用以下结构,标题中的“周记”前不得添加日期:
|
||||
# 周记({week_start} 至 {week_end})
|
||||
## 一、本周工作概览
|
||||
## 二、关键进展与结论
|
||||
## 三、上周工作延续
|
||||
@ -66,8 +66,8 @@ class WeeklyError(RuntimeError):
|
||||
|
||||
|
||||
def week_bounds(day: date) -> tuple[date, date]:
|
||||
"""Return the Sunday–Saturday reporting week containing day."""
|
||||
start = day - timedelta(days=(day.weekday() + 1) % 7)
|
||||
"""Return the Monday–Sunday reporting week containing day."""
|
||||
start = day - timedelta(days=day.weekday())
|
||||
return start, start + timedelta(days=6)
|
||||
|
||||
|
||||
@ -196,7 +196,7 @@ def generate_weekly(
|
||||
WEEKLY_FINAL_PROMPT.format(
|
||||
week_start=week_start.isoformat(),
|
||||
week_end=week_end.isoformat(),
|
||||
weekly_date=(week_end + timedelta(days=1)).isoformat(),
|
||||
weekly_date=week_end.isoformat(),
|
||||
weekly_parts=json.dumps(weekly_parts, ensure_ascii=False, indent=2),
|
||||
previous_weekly=previous_weekly or "<上周周记不存在>",
|
||||
)
|
||||
|
||||
@ -2,7 +2,7 @@ from snooper_version import bump_patch, format_version
|
||||
|
||||
|
||||
def test_version_marks_dirty_worktree_as_dev():
|
||||
assert format_version("0.1.0", "abc1234", False) == "0.1.0+gabc1234"
|
||||
assert format_version("0.1.0", "abc1234", False) == "0.1.0"
|
||||
assert format_version("0.1.0", "abc1234", True) == "0.1.0.dev0+gabc1234"
|
||||
|
||||
|
||||
|
||||
@ -17,10 +17,11 @@ from snooper_weekly import (
|
||||
|
||||
def test_week_bounds_use_monday_and_sunday():
|
||||
assert week_bounds(date(2024, 7, 4)) == (
|
||||
date(2024, 6, 30), date(2024, 7, 6)
|
||||
date(2024, 7, 1), date(2024, 7, 7)
|
||||
)
|
||||
assert iso_week_label(date(2024, 6, 30)) == "2024-W26"
|
||||
assert "# {weekly_date} 周记" in WEEKLY_FINAL_PROMPT
|
||||
assert iso_week_label(date(2024, 7, 1)) == "2024-W27"
|
||||
assert "# 周记({week_start} 至 {week_end})" in WEEKLY_FINAL_PROMPT
|
||||
assert "# {weekly_date} 周记" not in WEEKLY_FINAL_PROMPT
|
||||
|
||||
|
||||
def test_previous_weekly_background_uses_previous_monday(tmp_path):
|
||||
@ -28,7 +29,7 @@ def test_previous_weekly_background_uses_previous_monday(tmp_path):
|
||||
"summary": str(tmp_path / "Daily" / "MsgYYYY-MM-DD.md"),
|
||||
"weekly": str(tmp_path / "Weekly" / "MsgWYYYY-WW.md"),
|
||||
}
|
||||
weekly = tmp_path / "Weekly" / "MsgW2024-26.md"
|
||||
weekly = tmp_path / "Weekly" / "MsgW2024-27.md"
|
||||
weekly.parent.mkdir(parents=True)
|
||||
weekly.write_text("---\ntype: weekly\n---\n\n上周合成周记", encoding="utf-8")
|
||||
|
||||
@ -49,7 +50,7 @@ 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 / "MsgW2024-26.md").write_text("上周合成周记", encoding="utf-8")
|
||||
(weekly / "MsgW2024-27.md").write_text("上周合成周记", encoding="utf-8")
|
||||
config = tmp_path / "config.yaml"
|
||||
config.write_text(
|
||||
f"output:\n summary: '{daily}/MsgYYYY-MM-DD.md'\n"
|
||||
|
||||
Reference in New Issue
Block a user