feat: generate 以 board_select 为唯一列表主人并写回 shown keys
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,7 @@ 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
|
||||
from daily.text_utils import trim_brief
|
||||
|
||||
|
||||
def skill_id(item: dict[str, Any]) -> str:
|
||||
@@ -69,7 +70,10 @@ def _slim_news_items(
|
||||
"title": item.get("title", ""),
|
||||
"source_name": item.get("source_name", ""),
|
||||
"published_fmt": item.get("published_fmt", ""),
|
||||
"summary": item.get("desc_short") or "",
|
||||
"summary": trim_brief(
|
||||
item.get("summary_plain") or item.get("desc_short") or "",
|
||||
120,
|
||||
),
|
||||
}
|
||||
)
|
||||
if len(items) >= limit:
|
||||
@@ -106,10 +110,46 @@ def build_llm_input(
|
||||
ai_news: dict[str, Any],
|
||||
cn_ai_news: dict[str, Any],
|
||||
wecom_limits: dict[str, int],
|
||||
research_items: list[dict[str, Any]] | None = None,
|
||||
research_tech_items: list[dict[str, Any]] | None = None,
|
||||
boards_for_wecom: dict[str, list[dict[str, Any]]] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""供 Cursor 编辑的精简 JSON(不含完整 markdown)。"""
|
||||
news_limit = wecom_limits.get("ai_news", 10)
|
||||
cn_news_limit = wecom_limits.get("cn_ai_news", 8)
|
||||
if research_items is not None:
|
||||
slim_research = [
|
||||
{
|
||||
"link": item.get("link", ""),
|
||||
"title": item.get("title", ""),
|
||||
"source_name": item.get("source_name", ""),
|
||||
"published_fmt": item.get("published_fmt", ""),
|
||||
"summary": trim_brief(item.get("desc_short") or "", 120),
|
||||
}
|
||||
for item in research_items[:news_limit]
|
||||
]
|
||||
ai_news_payload = slim_research
|
||||
tech_news_payload = [
|
||||
{
|
||||
"link": item.get("link", ""),
|
||||
"title": item.get("title", ""),
|
||||
"source_name": item.get("source_name", ""),
|
||||
"published_fmt": item.get("published_fmt", ""),
|
||||
"summary": trim_brief(item.get("desc_short") or "", 120),
|
||||
}
|
||||
for item in (research_tech_items or [])
|
||||
]
|
||||
cn_news_payload: list[dict[str, Any]] = []
|
||||
ai_news_mode = "research"
|
||||
else:
|
||||
ai_news_payload = _slim_news_items(ai_news, news_limit, date_str=date_str) if ai_news.get("enabled") else []
|
||||
cn_news_payload = (
|
||||
_slim_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 []
|
||||
)
|
||||
ai_news_mode = "rss"
|
||||
tech_news_payload: list[dict[str, Any]] = []
|
||||
depth = compare_depth()
|
||||
trend_cmp = trending[:depth]
|
||||
hot_cmp = hot[:depth]
|
||||
@@ -117,19 +157,26 @@ def build_llm_input(
|
||||
emerging_cmp = github_emerging[:depth]
|
||||
topic_cmp = github_topic[:depth]
|
||||
|
||||
trending_slice = group_skills_by_source(
|
||||
trending,
|
||||
limit=wecom_limits.get("trending", 10),
|
||||
pool_size=wecom_limits.get("trending_pool", _wecom_skill_pool()),
|
||||
)
|
||||
hot_slice = group_skills_by_source(
|
||||
hot,
|
||||
limit=wecom_limits.get("hot", 10),
|
||||
pool_size=wecom_limits.get("hot_pool", _wecom_skill_pool()),
|
||||
)
|
||||
github_slice = github_trending[: wecom_limits.get("github", 5)]
|
||||
emerging_slice = github_emerging[: wecom_limits.get("emerging", 3)]
|
||||
topic_slice = github_topic[: wecom_limits.get("topic", 3)]
|
||||
if boards_for_wecom:
|
||||
trending_slice = boards_for_wecom.get("skills_trending") or []
|
||||
hot_slice = boards_for_wecom.get("skills_hot") or []
|
||||
github_slice = boards_for_wecom.get("github_trending") or []
|
||||
emerging_slice = boards_for_wecom.get("github_emerging") or []
|
||||
topic_slice = boards_for_wecom.get("github_topic") or []
|
||||
else:
|
||||
trending_slice = group_skills_by_source(
|
||||
trending,
|
||||
limit=wecom_limits.get("trending", 10),
|
||||
pool_size=wecom_limits.get("trending_pool", _wecom_skill_pool()),
|
||||
)
|
||||
hot_slice = group_skills_by_source(
|
||||
hot,
|
||||
limit=wecom_limits.get("hot", 10),
|
||||
pool_size=wecom_limits.get("hot_pool", _wecom_skill_pool()),
|
||||
)
|
||||
github_slice = github_trending[: wecom_limits.get("github", 5)]
|
||||
emerging_slice = github_emerging[: wecom_limits.get("emerging", 3)]
|
||||
topic_slice = github_topic[: wecom_limits.get("topic", 3)]
|
||||
|
||||
movement = build_movement_context(
|
||||
date_str=date_str,
|
||||
@@ -163,12 +210,10 @@ 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, 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, date_str=date_str
|
||||
)
|
||||
if cn_ai_news.get("enabled")
|
||||
else [],
|
||||
"ai_news": ai_news_payload,
|
||||
"tech_ai_news": tech_news_payload,
|
||||
"cn_ai_news": cn_news_payload,
|
||||
"ai_news_mode": ai_news_mode,
|
||||
"movement": movement,
|
||||
"movement_baseline": movement_baseline,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user