feat: 在 generate 流程中接入 Delta 模式与推送闸门

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-09 11:37:54 +08:00
parent b2dd8721d0
commit 588def8eb2
2 changed files with 99 additions and 43 deletions

View File

@@ -6,8 +6,8 @@ import json
from pathlib import Path
from typing import Any
from daily.config import OUTPUT_DIR, env_int
from daily.delta import build_movement_baseline, build_movement_context, compare_depth
from daily.config import OUTPUT_DIR, env_int, wecom_mode
from daily.delta import build_movement_baseline, build_movement_context, compare_depth, effective_wecom_mode
from daily.news.fetch import prepare_wecom_cn_news_items, prepare_wecom_news_items
from daily.skills_group import group_skills_by_source
@@ -59,9 +59,10 @@ def _slim_news_items(
limit: int,
*,
prepare=prepare_wecom_news_items,
date_str: str | None = None,
) -> list[dict[str, Any]]:
items: list[dict[str, Any]] = []
for item in prepare(ai_news):
for item in prepare(ai_news, date_str=date_str):
items.append(
{
"link": item.get("link", ""),
@@ -147,10 +148,13 @@ def build_llm_input(
github_topic=[_slim_github(x) for x in topic_cmp],
depth=depth,
)
eff_mode = effective_wecom_mode(date_str=date_str)
return {
"date": date_str,
"data_updated": updated,
"wecom_mode": wecom_mode(),
"effective_wecom_mode": eff_mode,
"skills_trending": [_slim_skill(x) for x in trending_slice],
"skills_hot": [_slim_skill(x) for x in hot_slice],
"github_trending": [_slim_github(x) for x in github_slice],
@@ -159,9 +163,9 @@ def build_llm_input(
"topic": topic_name,
"repos": [_slim_github(x) for x in topic_slice],
},
"ai_news": _slim_news_items(ai_news, news_limit) if ai_news.get("enabled") else [],
"ai_news": _slim_news_items(ai_news, news_limit, date_str=date_str) if ai_news.get("enabled") else [],
"cn_ai_news": _slim_news_items(
cn_ai_news, cn_news_limit, prepare=prepare_wecom_cn_news_items
cn_ai_news, cn_news_limit, prepare=prepare_wecom_cn_news_items, date_str=date_str
)
if cn_ai_news.get("enabled")
else [],
@@ -186,6 +190,10 @@ def editorial_json_path(date_str: str) -> Path:
return OUTPUT_DIR / f"{date_str}.editorial.json"
def featured_json_path(date_str: str) -> Path:
return OUTPUT_DIR / f"{date_str}.featured.json"
def save_json(path: Path, data: dict[str, Any]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")