From cdca237c4210de1607baf895fe0aa45930b2d14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=BE=99?= <76432572+nankingjing@users.noreply.github.com> Date: Sat, 11 Jul 2026 18:45:50 +0800 Subject: [PATCH 1/4] fix(prompts): localize web report item labels for English mode --- src/prompts.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/prompts.ts b/src/prompts.ts index a5e303a..f6222ac 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -590,20 +590,34 @@ export function buildWebReportPrompt( ? `首次全量抓取(sitemap 共 ${totalDiscovered} 条 URL,以下为最新 ${newItems.length} 篇正文内容)` : `今日增量更新,共 ${newItems.length} 篇新内容`; - if (newItems.length === 0) return `## ${siteName}\n\n(${mode},暂无可供分析的内容。)`; + if (newItems.length === 0) { + const emptyMsg = + lang === "en" + ? `(${mode}, no content available for analysis.)` + : `(${mode},暂无可供分析的内容。)`; + return `## ${siteName}\n\n${emptyMsg}`; + } const unableToExtract = lang === "en" ? "(Unable to extract text content)" : "(无法提取文本内容)"; + const itemLabels = + lang === "en" + ? { category: "Category", published: "Published/Updated", unknown: "Unknown", excerpt: "Excerpt" } + : { category: "分类", published: "发布/更新", unknown: "未知", excerpt: "内容节选" }; const itemsText = newItems .map((item) => [ `### [${item.title || item.url}](${item.url})`, - `- 分类: ${item.category} | 发布/更新: ${item.lastmod.slice(0, 10) || "未知"}`, - `- 内容节选: ${item.content || unableToExtract}`, + `- ${itemLabels.category}: ${item.category} | ${itemLabels.published}: ${item.lastmod.slice(0, 10) || itemLabels.unknown}`, + `- ${itemLabels.excerpt}: ${item.content || unableToExtract}`, ].join("\n"), ) .join("\n\n"); - return `## ${siteName}(${mode})\n\n${itemsText}`; + const sectionParen = + lang === "en" + ? `(${mode})` + : `(${mode})`; + return `## ${siteName} ${sectionParen}\n\n${itemsText}`; }) .join("\n\n---\n\n"); From 4d67fd27e4fb1c38f55e89a62f2eec1223dcd206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=BE=99?= <76432572+nankingjing@users.noreply.github.com> Date: Tue, 14 Jul 2026 09:27:57 +0800 Subject: [PATCH 2/4] fix(prompts): avoid extra space before Chinese section parentheses --- src/prompts.ts | 1750 ++++++++++++++++++++++++------------------------ 1 file changed, 868 insertions(+), 882 deletions(-) diff --git a/src/prompts.ts b/src/prompts.ts index f6222ac..7cb8de8 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -1,882 +1,868 @@ -/** - * LLM prompt builders and item formatting. - */ - -import type { RepoConfig, GitHubItem, GitHubRelease } from "./github.ts"; -import type { WebFetchResult } from "./web.ts"; -import type { TrendingData } from "./trending.ts"; -import type { HnData } from "./hn.ts"; - -// --------------------------------------------------------------------------- -// Types -// --------------------------------------------------------------------------- - -export interface RepoDigest { - config: RepoConfig; - issues: GitHubItem[]; - prs: GitHubItem[]; - releases: GitHubRelease[]; - summary: string; -} - -// --------------------------------------------------------------------------- -// Formatting -// --------------------------------------------------------------------------- - -export function formatItem(item: GitHubItem, lang: "zh" | "en" = "zh"): string { - const labels = item.labels.map((l) => l.name).join(", "); - const labelStr = labels ? ` [${labels}]` : ""; - const body = (item.body ?? "").replace(/\n/g, " ").trim().slice(0, 300); - const ellipsis = (item.body ?? "").length > 300 ? "..." : ""; - const t = - lang === "en" - ? { - author: "Author", - created: "Created", - updated: "Updated", - comments: "Comments", - url: "URL", - summary: "Summary", - } - : { author: "作者", created: "创建", updated: "更新", comments: "评论", url: "链接", summary: "摘要" }; - return [ - `#${item.number} [${item.state.toUpperCase()}]${labelStr} ${item.title}`, - ` ${t.author}: @${item.user.login} | ${t.created}: ${item.created_at.slice(0, 10)} | ${t.updated}: ${item.updated_at.slice(0, 10)} | ${t.comments}: ${item.comments} | 👍: ${item.reactions?.["+1"] ?? 0}`, - ` ${t.url}: ${item.html_url}`, - ` ${t.summary}: ${body}${ellipsis}`, - ].join("\n"); -} - -// --------------------------------------------------------------------------- -// Sampling helpers (shared) -// --------------------------------------------------------------------------- - -const CLI_ISSUE_LIMIT = 30; -const CLI_PR_LIMIT = 20; - -/** Sort by comment count desc, take top N. */ -function topN(items: GitHubItem[], n: number): GitHubItem[] { - return [...items].sort((a, b) => b.comments - a.comments).slice(0, n); -} - -function sampleNote(total: number, sampled: number, lang: "zh" | "en" = "zh"): string { - if (lang === "en") { - return total > sampled - ? `(Total: ${total} items; showing top ${sampled} by comment count)` - : `(Total: ${total} items)`; - } - return total > sampled ? `(共 ${total} 条,以下展示评论数最多的 ${sampled} 条)` : `(共 ${total} 条)`; -} - -// --------------------------------------------------------------------------- -// Prompts -// --------------------------------------------------------------------------- - -export function buildCliPrompt( - cfg: RepoConfig, - issues: GitHubItem[], - prs: GitHubItem[], - releases: GitHubRelease[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const sampledIssues = topN(issues, CLI_ISSUE_LIMIT); - const sampledPrs = topN(prs, CLI_PR_LIMIT); - - const issuesText = - sampledIssues.map((i) => formatItem(i, lang)).join("\n") || (lang === "en" ? "None" : "无"); - const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || (lang === "en" ? "None" : "无"); - const releasesText = releases.length - ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") - : lang === "en" - ? "None" - : "无"; - - const issueNote = sampleNote(issues.length, sampledIssues.length, lang); - const prNote = sampleNote(prs.length, sampledPrs.length, lang); - - if (lang === "en") { - return `You are a technical analyst focused on AI developer tools. Based on the following GitHub data, generate the ${cfg.name} community digest for ${dateStr}. - -# Data source: github.com/${cfg.repo} - -## Latest Releases (last 24h) -${releasesText} - -## Latest Issues (updated in last 24h)${issueNote} -${issuesText} - -## Latest Pull Requests (updated in last 24h)${prNote} -${prsText} - ---- - -Generate a structured English digest with the following sections: - -1. **Today's Highlights** - 2-3 sentences summarizing the most important updates -2. **Releases** - If new versions exist, summarize changes; omit if none -3. **Hot Issues** - Pick 10 noteworthy Issues, explain why they matter and community reaction -4. **Key PR Progress** - Pick 10 important PRs, describe features or fixes -5. **Feature Request Trends** - Distill the most-requested feature directions from all Issues -6. **Developer Pain Points** - Summarize recurring developer frustrations or high-frequency requests - -Style: concise and professional, suited for technical developers. Include GitHub links for each item. -`; - } - - return `你是一位专注于 AI 开发工具的技术分析师。请根据以下 GitHub 数据,生成 ${dateStr} 的 ${cfg.name} 社区动态日报。 - -# 数据来源: github.com/${cfg.repo} - -## 最新 Releases(过去24小时) -${releasesText} - -## 最新 Issues(过去24小时内更新)${issueNote} -${issuesText} - -## 最新 Pull Requests(过去24小时内更新)${prNote} -${prsText} - ---- - -请生成一份结构清晰的中文日报,包含以下部分: - -1. **今日速览** - 用2-3句话概括今天最重要的动态 -2. **版本发布** - 如有新版本,总结更新内容;无则省略 -3. **社区热点 Issues** - 挑选 10 个最值得关注的 Issue,说明为什么重要、社区反应如何 -4. **重要 PR 进展** - 挑选 10 个重要的 PR,说明功能或修复内容 -5. **功能需求趋势** - 从所有 Issues 中提炼出社区最关注的功能方向(如 IDE 集成、性能、新模型支持等) -6. **开发者关注点** - 总结开发者反馈中的痛点或高频需求 - -语言要求:简洁专业,适合技术开发者阅读。每个条目附上 GitHub 链接。 -`; -} - -const PEER_ISSUE_LIMIT = 30; -const PEER_PR_LIMIT = 20; - -export function buildPeerPrompt( - cfg: RepoConfig, - issues: GitHubItem[], - prs: GitHubItem[], - releases: GitHubRelease[], - dateStr: string, - issueLimit = PEER_ISSUE_LIMIT, - prLimit = PEER_PR_LIMIT, - lang: "zh" | "en" = "zh", -): string { - const totalIssues = issues.length; - const totalPrs = prs.length; - - const sampledIssues = topN(issues, issueLimit); - const sampledPrs = topN(prs, prLimit); - - const noneStr = lang === "en" ? "None" : "无"; - const issuesText = sampledIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; - const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; - const releasesText = releases.length - ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") - : noneStr; - - const openIssues = issues.filter((i) => i.state === "open").length; - const closedIssues = issues.filter((i) => i.state === "closed").length; - const openPrs = prs.filter((p) => p.state === "open").length; - const mergedPrs = prs.filter((p) => p.state === "closed").length; - - const issueSampleNote = sampleNote(totalIssues, sampledIssues.length, lang); - const prSampleNote = sampleNote(totalPrs, sampledPrs.length, lang); - - if (lang === "en") { - return `You are an analyst of AI agent and personal AI assistant open-source projects. Based on the following GitHub data from ${cfg.name} (github.com/${cfg.repo}), generate a project digest for ${dateStr}. - -# Data Overview -- Issues updated in last 24h: ${totalIssues} (open/active: ${openIssues}, closed: ${closedIssues}) -- PRs updated in last 24h: ${totalPrs} (open: ${openPrs}, merged/closed: ${mergedPrs}) -- New releases: ${releases.length} - -## Latest Releases -${releasesText} - -## Latest Issues ${issueSampleNote} -${issuesText} - -## Latest Pull Requests ${prSampleNote} -${prsText} - ---- - -Generate a structured English ${cfg.name} project digest with the following sections: - -1. **Today's Overview** - 3-5 sentences summarizing project status, including activity assessment -2. **Releases** - If new versions exist, detail changes, breaking changes, migration notes; omit if none -3. **Project Progress** - Merged/closed PRs today, what features advanced or were fixed -4. **Community Hot Topics** - Most active Issues/PRs with most comments/reactions (with links), analyze underlying needs -5. **Bugs & Stability** - Bugs, crashes, regressions reported today, ranked by severity, note if fix PRs exist -6. **Feature Requests & Roadmap Signals** - User-requested features, predict which might be in next version -7. **User Feedback Summary** - Real user pain points, use cases, satisfaction/dissatisfaction -8. **Backlog Watch** - Long-unanswered important Issues or PRs needing maintainer attention - -Style: objective, data-driven, highlighting project health. Include GitHub links for each item. -`; - } - - return `你是一位 AI 智能体与个人 AI 助手领域开源项目分析师。请根据以下来自 ${cfg.name} (github.com/${cfg.repo}) 的 GitHub 数据,生成 ${dateStr} 的项目动态日报。 - -# 数据概览 -- 过去24小时 Issues 更新:${totalIssues} 条(新开/活跃: ${openIssues},已关闭: ${closedIssues}) -- 过去24小时 PR 更新:${totalPrs} 条(待合并: ${openPrs},已合并/关闭: ${mergedPrs}) -- 新版本发布:${releases.length} 个 - -## 最新 Releases -${releasesText} - -## 最新 Issues ${issueSampleNote} -${issuesText} - -## 最新 Pull Requests ${prSampleNote} -${prsText} - ---- - -请生成一份结构清晰的 ${cfg.name} 项目日报,包含以下部分: - -1. **今日速览** - 用3-5句话概括项目今日整体状态,包括活跃度评估 -2. **版本发布** - 如有新版本,详细说明更新内容、破坏性变更、迁移注意事项;无则省略 -3. **项目进展** - 今日合并/关闭的重要 PR,说明推进了哪些功能或修复,项目整体向前迈进了多少 -4. **社区热点** - 今日讨论最活跃、评论最多、反应最多的 Issues/PRs(附链接),分析背后的诉求 -5. **Bug 与稳定性** - 今日报告的 Bug、崩溃、回归问题,按严重程度排列,标注是否已有 fix PR -6. **功能请求与路线图信号** - 用户提出的新功能需求,结合已有 PR 判断哪些可能被纳入下一版本 -7. **用户反馈摘要** - 从 Issues 评论中提炼真实用户痛点、使用场景、满意/不满意的地方 -8. **待处理积压** - 长期未响应的重要 Issue 或 PR,提醒维护者关注 - -语言要求:客观专业,数据驱动,突出项目健康度。每个条目附上 GitHub 链接。 -`; -} - -export function buildPeersComparisonPrompt( - openclawDigest: RepoDigest, - peerDigests: RepoDigest[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; - - const openclawSection = - lang === "en" - ? `## OpenClaw (core reference, github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}` - : `## OpenClaw(核心参照,github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}`; - - const peerSections = peerDigests - .map((d) => { - const hasData = d.issues.length || d.prs.length || d.releases.length; - if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; - return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; - }) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a senior analyst of the AI agent and personal AI assistant open-source ecosystem. The following are ${dateStr} community digest summaries for each project. - -${openclawSection} - ---- - -${peerSections} - ---- - -Generate a cross-project comparison report in English with these sections: - -1. **Ecosystem Overview** - 3-5 sentences on the overall personal AI assistant / agent open-source landscape -2. **Activity Comparison** - Table comparing Issues count, PR count, Release status, and health score for each project -3. **OpenClaw's Position** - Advantages vs peers, technical approach differences, community size comparison -4. **Shared Technical Focus Areas** - Requirements emerging across multiple projects (note which projects, specific needs) -5. **Differentiation Analysis** - Key differences in feature focus, target users, technical architecture -6. **Community Momentum & Maturity** - Activity tiers, which are rapidly iterating, which are stabilizing -7. **Trend Signals** - Industry trends extracted from community feedback, value for AI agent developers - -Style: concise and professional, data-backed, suited for technical decision-makers and developers. -`; - } - - return `你是一位专注于 AI 智能体与个人 AI 助手开源生态的资深技术分析师。以下是 ${dateStr} 各开源项目的社区动态摘要。 - -${openclawSection} - ---- - -${peerSections} - ---- - -请基于上述各项目的动态,生成一份横向对比分析报告,包含以下部分: - -1. **生态全景** - 用3-5句话概括个人 AI 助手/自主智能体开源生态整体态势 -2. **各项目活跃度对比** - 以表格形式汇总各项目今日的 Issues 数、PR 数、Release 情况及健康度评估 -3. **OpenClaw 在生态中的定位** - 与同类相比的优势、技术路线差异、社区规模对比 -4. **共同关注的技术方向** - 多项目共同涌现的需求(注明涉及哪些项目、具体诉求) -5. **差异化定位分析** - 功能侧重、目标用户、技术架构的关键差异 -6. **社区热度与成熟度** - 活跃度分层,哪些处于快速迭代阶段,哪些在质量巩固阶段 -7. **值得关注的趋势信号** - 从社区反馈中提炼行业趋势,对 AI 智能体开发者的参考价值 - -语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 -`; -} - -export function buildSkillsPrompt( - prs: GitHubItem[], - issues: GitHubItem[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const topPrs = topN(prs, 20); - const topIssues = topN(issues, 15); - - const noneStr = lang === "en" ? "None" : "无"; - const prsText = topPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; - const issuesText = topIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; - - if (lang === "en") { - return `You are a technical analyst focused on the Claude Code ecosystem. The following data is from github.com/anthropics/skills (official Claude Code Skills repository). Analyze the community's most-watched Skills activity (data as of ${dateStr}). - -## Repository Context -anthropics/skills is the official Claude Code Skills collection. Each PR typically represents a new or improved Skill. The community proposes new Skills and reports issues via Issues; PRs represent actual Skill submissions. - -## Popular Pull Requests (sorted by comments, ${prs.length} total, showing top ${topPrs.length}) -${prsText} - -## Community Issues (sorted by comments, ${issues.length} total, showing top ${topIssues.length}) -${issuesText} - ---- - -Generate a Claude Code Skills community highlights report in English with these sections: - -1. **Top Skills Ranking** - List the 5-8 most-discussed Skills (PRs) by comments/attention, describe each Skill's functionality, discussion highlights, and current status (open/merged/draft) -2. **Community Demand Trends** - From Issues, distill the most-anticipated new Skill directions (e.g. workflow automation, code review, test generation, documentation) -3. **High-Potential Pending Skills** - Active-comment PRs not yet merged; these Skills may land soon -4. **Skills Ecosystem Insight** - One-sentence summary: what is the community's most concentrated demand at the Skills level? - -Style: concise and professional, include GitHub links for each item. -`; - } - - return `你是一位专注于 Claude Code 生态的技术分析师。以下是来自 github.com/anthropics/skills(Claude Code Skills 官方仓库)的数据,请分析社区最关注的 Skills 动态(数据截止 ${dateStr})。 - -## 仓库说明 -anthropics/skills 是 Claude Code 官方 Skills 集合仓库,每个 PR 通常对应一个新增或改进的 Skill。社区通过 Issues 提出新 Skill 需求或反馈问题,PR 则代表实际提交的 Skill。 - -## 热门 Pull Requests(按评论数排序,共 ${prs.length} 条,展示前 ${topPrs.length} 条) -${prsText} - -## 社区 Issues(按评论数排序,共 ${issues.length} 条,展示前 ${topIssues.length} 条) -${issuesText} - ---- - -请生成一份 Claude Code Skills 社区热点报告,包含以下部分: - -1. **热门 Skills 排行** - 列出评论/关注度最高的 5~8 个 Skills(PR),说明每个 Skill 的功能、社区讨论热点及当前状态(open/merged/draft) -2. **社区需求趋势** - 从 Issues 中提炼社区最期待的新 Skill 方向(如工作流自动化、代码审查、测试生成、文档等) -3. **高潜力待合并 Skills** - 评论活跃但尚未合并的 PR,这些 Skills 可能近期落地 -4. **Skills 生态洞察** - 一句话总结:当前社区在 Skills 层面最集中的诉求是什么 - -语言要求:简洁专业,每个条目附上 GitHub 链接。 -`; -} - -export function buildComparisonPrompt( - digests: RepoDigest[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; - - const sections = digests - .map((d) => { - const hasData = d.issues.length || d.prs.length || d.releases.length; - if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; - return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; - }) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a senior technical analyst of the AI developer tools ecosystem. The following are ${dateStr} community digest summaries for each major AI CLI tool: - -${sections} - ---- - -Generate a cross-tool comparison report in English with these sections: - -1. **Ecosystem Overview** - 3-5 sentences on the overall AI CLI tools development landscape -2. **Activity Comparison** - Table comparing Issues count, PR count, Release status for each tool today -3. **Shared Feature Directions** - Requirements appearing across multiple tool communities (note which tools, specific needs) -4. **Differentiation Analysis** - Differences in feature focus, target users, and technical approach -5. **Community Momentum & Maturity** - Which tools have more active communities, which are rapidly iterating -6. **Trend Signals** - Industry trends from community feedback, reference value for developers - -Style: concise and professional, data-backed, suited for technical decision-makers and developers. -`; - } - - return `你是一位专注于 AI 开发工具生态的资深技术分析师。以下是 ${dateStr} 各主流 AI CLI 工具的社区动态摘要: - -${sections} - ---- - -请基于上述各工具的动态,生成一份横向对比分析报告,包含以下部分: - -1. **生态全景** - 用3-5句话概括当前 AI CLI 工具整体发展态势 -2. **各工具活跃度对比** - 以表格形式汇总各工具今日的 Issues 数、PR 数、Release 情况 -3. **共同关注的功能方向** - 多个工具社区都在关注的需求(说明哪些工具、具体诉求) -4. **差异化定位分析** - 各工具在功能侧重、目标用户、技术路线上的差异 -5. **社区热度与成熟度** - 哪些工具社区更活跃,哪些处于快速迭代阶段 -6. **值得关注的趋势信号** - 从社区反馈中提炼出的行业趋势,对开发者有何参考价值 - -语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 -`; -} - -export function buildTrendingPrompt(data: TrendingData, dateStr: string, lang: "zh" | "en" = "zh"): string { - const trendingSection = - data.trendingFetchSuccess && data.trendingRepos.length > 0 - ? data.trendingRepos - .map( - (r) => - `- [${r.fullName}](${r.url})` + - (r.language ? ` [${r.language}]` : "") + - ` ⭐${r.totalStars.toLocaleString()}` + - (r.todayStars > 0 ? ` (+${r.todayStars} today)` : "") + - (r.forks > 0 ? ` 🍴${r.forks.toLocaleString()}` : "") + - (r.description ? `\n ${r.description}` : ""), - ) - .join("\n") - : lang === "en" - ? "(Unable to fetch today's GitHub Trending list)" - : "(未能抓取今日 GitHub Trending 榜单)"; - - const searchSection = - data.searchRepos.length > 0 - ? data.searchRepos - .map( - (r) => - `- [${r.fullName}](${r.url})` + - (r.language ? ` [${r.language}]` : "") + - ` ⭐${r.stargazersCount.toLocaleString()}` + - ` [topic:${r.searchQuery}]` + - (r.description ? `\n ${r.description}` : ""), - ) - .join("\n") - : lang === "en" - ? "(No search results)" - : "(无搜索结果)"; - - if (lang === "en") { - return `You are a technical analyst focused on the AI open-source ecosystem. The following is ${dateStr} GitHub AI-related trending repository data. Please filter for AI relevance, categorize, and analyze trends. - -## Data Sources -- **Trending List** (github.com/trending, today's stars most reliable): Real-time hot list with today's new stars -- **Topic Search** (GitHub Search API, topic tags): AI-related projects active in last 7 days, grouped by topic - ---- - -## GitHub Today's Trending (${data.trendingRepos.length} repositories) -${trendingSection} - ---- - -## AI Topic Search Results (${data.searchRepos.length} repositories, deduplicated) -${searchSection} - ---- - -Generate a structured AI Open Source Trends Report in English: - -**Step 1 (Filter)**: From the above data, select projects clearly related to AI/ML (exclude unrelated general tools, frontend frameworks, games, etc.). Skip non-AI trending repos. - -**Step 2 (Categorize)**: Group filtered projects into these categories (a project can belong to multiple; pick the primary one): -- 🔧 AI Infrastructure (frameworks, SDKs, inference engines, dev tools, CLI) -- 🤖 AI Agents / Workflows (agent frameworks, automation, multi-agent systems) -- 📦 AI Applications (specific apps, vertical solutions) -- 🧠 LLMs / Training (model weights, training frameworks, fine-tuning tools) -- 🔍 RAG / Knowledge (vector databases, retrieval-augmented generation, knowledge management) - -**Step 3 (Output Report)** with these sections: - -1. **Today's Highlights** — 3-5 sentences on the most noteworthy AI open-source developments today - -2. **Top Projects by Category** — For each category, list 3-8 representative projects, each with: - - Project name (with link) - - Stars data (total + today's new, if available) - - One sentence: what it is and why it's worth attention today - -3. **Trend Signal Analysis** — 200-300 words, distill from today's hot list: - - Which type of AI tool is getting explosive community attention? - - Any new tech stacks or directions appearing for the first time? - - Connection to recent LLM releases / industry events - -4. **Community Hot Spots** — Bullet list of 3-5 specific projects or directions worth developer focus, with brief reasoning - -Style: English, professional and concise, must include GitHub links for every project. -`; - } - - return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${dateStr} 的 GitHub AI 相关热门仓库数据,请进行 AI 相关性筛选、分类和趋势分析。 - -## 数据说明 -- **Trending 榜单**(github.com/trending,今日 stars 数最可信):今日实时热榜,含今日新增 stars -- **主题搜索**(GitHub Search API,topic 标签):7天内活跃的 AI 相关项目,按主题分类 - ---- - -## GitHub 今日 Trending 榜单(共 ${data.trendingRepos.length} 个仓库) -${trendingSection} - ---- - -## AI 主题搜索结果(共 ${data.searchRepos.length} 个仓库,已去重) -${searchSection} - ---- - -请生成一份结构清晰的《AI 开源趋势日报》,要求: - -**第一步(过滤)**:从以上数据中筛选出与 AI/ML 明确相关的项目(排除与 AI 无关的通用工具、前端框架、游戏等),对于 Trending 榜单中的非 AI 项目直接略去。 - -**第二步(分类)**:将筛选后的项目按以下维度分类(一个项目可归入多类,优先归入最主要类别): -- 🔧 AI 基础工具(框架、SDK、推理引擎、开发工具、CLI) -- 🤖 AI 智能体/工作流(Agent 框架、自动化、多智能体) -- 📦 AI 应用(具体应用产品、垂直场景解决方案) -- 🧠 大模型/训练(模型权重、训练框架、微调工具) -- 🔍 RAG/知识库(向量数据库、检索增强、知识管理) - -**第三步(输出报告)**,包含以下部分: - -1. **今日速览** — 3~5 句话概括今日 AI 开源领域最值得关注的动向 - -2. **各维度热门项目** — 每个维度列出 3~8 个代表项目,每项包含: - - 项目名(附链接) - - stars 数据(总量 + 今日新增,如有) - - 一句话说明:这个项目是什么,为什么今天值得关注 - -3. **趋势信号分析** — 200~300 字,从今日热榜中提炼: - - 哪类 AI 工具正在获得社区爆发性关注? - - 有无新兴技术栈或方向首次登榜? - - 与近期大模型发布/行业事件的关联 - -4. **社区关注热点** — 以 bullet 形式列出 3~5 个值得开发者重点关注的具体项目或方向,给出简短理由 - -语言要求:中文,专业简洁,每个项目必须附 GitHub 链接。 -`; -} - -export function buildWebReportPrompt( - results: WebFetchResult[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const isAnyFirstRun = results.some((r) => r.isFirstRun); - - const siteSections = results - .map(({ siteName, isFirstRun, newItems, totalDiscovered }) => { - const mode = - lang === "en" - ? isFirstRun - ? `First full crawl (sitemap total ${totalDiscovered} URLs, showing latest ${newItems.length} articles)` - : `Incremental update, ${newItems.length} new articles today` - : isFirstRun - ? `首次全量抓取(sitemap 共 ${totalDiscovered} 条 URL,以下为最新 ${newItems.length} 篇正文内容)` - : `今日增量更新,共 ${newItems.length} 篇新内容`; - - if (newItems.length === 0) { - const emptyMsg = - lang === "en" - ? `(${mode}, no content available for analysis.)` - : `(${mode},暂无可供分析的内容。)`; - return `## ${siteName}\n\n${emptyMsg}`; - } - - const unableToExtract = lang === "en" ? "(Unable to extract text content)" : "(无法提取文本内容)"; - const itemLabels = - lang === "en" - ? { category: "Category", published: "Published/Updated", unknown: "Unknown", excerpt: "Excerpt" } - : { category: "分类", published: "发布/更新", unknown: "未知", excerpt: "内容节选" }; - const itemsText = newItems - .map((item) => - [ - `### [${item.title || item.url}](${item.url})`, - `- ${itemLabels.category}: ${item.category} | ${itemLabels.published}: ${item.lastmod.slice(0, 10) || itemLabels.unknown}`, - `- ${itemLabels.excerpt}: ${item.content || unableToExtract}`, - ].join("\n"), - ) - .join("\n\n"); - - const sectionParen = - lang === "en" - ? `(${mode})` - : `(${mode})`; - return `## ${siteName} ${sectionParen}\n\n${itemsText}`; - }) - .join("\n\n---\n\n"); - - const firstRunNote = - lang === "en" - ? isAnyFirstRun - ? "This is the first full crawl. Please focus on the overall content landscape, historical context, and core themes of each site, rather than individual articles." - : "This is an incremental update. Please focus on today's new content and assess its strategic significance in context." - : isAnyFirstRun - ? "本次为首次全量抓取,请重点梳理各站点的内容格局、历史脉络与核心主题,而非仅关注单篇文章。" - : "本次为增量更新,请聚焦今日新增内容,并结合上下文判断其战略意义。"; - - if (lang === "en") { - return `You are a deep content analyst focused on AI, skilled at extracting strategic signals from official announcements, technical blogs, research papers, and product documentation. - -The following content was crawled on ${dateStr} from Anthropic (claude.com / anthropic.com) and OpenAI (openai.com). ${firstRunNote} - -${siteSections} - ---- - -Generate a detailed AI Official Content Tracking Report in English with these sections: - -1. **Today's Highlights** — 3-5 sentences on the most important new releases or developments, calling out key highlights - -2. **Anthropic / Claude Content Highlights** — Organize important content by category (news / research / engineering / learn, etc.): - - For each piece, 2-4 sentences extracting core insights, technical details, or business significance - - Note publication date and original link - - If first full crawl, trace important milestones chronologically - -3. **OpenAI Content Highlights** — Same structure, organized by research / release / company / safety categories - -4. **Strategic Signal Analysis** — Based on both companies' release cadence and content focus, analyze: - - Each company's recent technical priorities (model capabilities / safety / productization / ecosystem) - - Competitive dynamics: who is setting the agenda, who is following - - Potential impact on developers and enterprise users - -5. **Notable Details** — Extract hidden signals from titles, phrasing, and timing, e.g.: - - New terms or topics appearing for the first time - - Dense releases in a category (may signal a product milestone) - - Policy, compliance, and safety developments - -${isAnyFirstRun ? "6. **Content Landscape Overview** — First full crawl only: summarize the content category distribution for both companies and describe their content strategy style (academic-oriented vs product-oriented vs user stories, etc.)\n\n" : ""}Style: English, professional and detailed, suited for AI researchers, product managers, and technical decision-makers. Every item must include official links. -`; - } - - return `你是一位专注于 AI 领域的深度内容分析师,擅长从官方公告、技术博客、研究论文和产品文档中提炼战略信号。 - -以下是 ${dateStr} 从 Anthropic(claude.com / anthropic.com)和 OpenAI(openai.com)官网抓取的内容,${firstRunNote} - -${siteSections} - ---- - -请生成一份详实的《AI 官方内容追踪报告》,包含以下部分: - -1. **今日速览** — 3~5 句话概括最重要的新发布或动向,点出核心亮点 - -2. **Anthropic / Claude 内容精选** — 按分类(news / research / engineering / learn 等)逐条整理重要内容: - - 每篇用 2~4 句话提炼核心观点、技术细节或业务意义 - - 标注发布日期和原文链接 - - 如首次全量,按时间线梳理重要里程碑 - -3. **OpenAI 内容精选** — 同上,按 research / release / company / safety 等分类整理 - -4. **战略信号解读** — 基于两家公司的发布节奏和内容重点,分析: - - 各自近期的技术优先级(模型能力 / 安全 / 产品化 / 生态) - - 竞争态势:谁在引领议题,谁在跟进 - - 对开发者和企业用户的潜在影响 - -5. **值得关注的细节** — 从标题、措辞、发布时机中提取隐含信号,例如: - - 新兴词汇或话题的首次出现 - - 某类主题的密集发布(可能预示产品节点) - - 政策、合规、安全方面的动向 - -${isAnyFirstRun ? "6. **内容格局总览** — 首次全量独有:汇总两家公司各内容类别的数量分布,并说明各自的内容运营风格(学术导向 vs 产品导向 vs 用户故事等)\n\n" : ""}语言要求:中文,专业深入,内容详实,适合 AI 领域研究者、产品经理和技术决策者阅读。每个条目必须附上 GitHub/官网链接。 -`; -} - -export function buildWeeklyPrompt( - dailyDigests: Record, - weekStr: string, - lang: "zh" | "en" = "zh", -): string { - const digestEntries = Object.entries(dailyDigests) - .map(([date, content]) => `## ${date}\n\n${content}`) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a technical analyst focused on the AI open-source ecosystem. The following are daily digest summaries from the past 7 days (${weekStr}) of AI tool community activity. Generate a comprehensive weekly recap. - -${digestEntries} - ---- - -Generate an AI Tools Ecosystem Weekly Report with these sections: - -1. **Week's Top Stories** - 5-8 most important events, releases, and community developments this week, each with date -2. **CLI Tools Progress** - Overall activity and key changes for each AI CLI tool (Claude Code, Codex, Gemini CLI, etc.) -3. **AI Agent Ecosystem** - Key developments from OpenClaw and peer projects this week -4. **Open Source Trends** - Most notable technical directions from GitHub Trending and AI community this week -5. **HN Community Highlights** - Core AI discussion topics and community sentiment on Hacker News this week -6. **Official Announcements** - Important content published by Anthropic and OpenAI this week (if any) -7. **Next Week's Signals** - Based on this week's data, predict trends and upcoming events worth watching - -Style: English, concise and professional, helping technical developers quickly grasp the week's developments. -`; - } - - return `你是一位专注于 AI 开源生态的技术分析师。以下是过去 7 天(${weekStr})的 AI 工具社区每日动态摘要,请生成本周综合回顾报告。 - -${digestEntries} - ---- - -请生成《AI 工具生态周报》,包含以下部分: - -1. **本周要闻** - 5-8 条本周最重要的事件、版本发布、社区动向,每条附日期 -2. **CLI 工具进展** - 各 AI CLI 工具(Claude Code、Codex、Gemini CLI 等)本周整体动态与关键变化 -3. **AI Agent 生态** - OpenClaw 及同赛道项目的本周重要进展 -4. **开源趋势** - 本周 GitHub Trending 和 AI 社区最关注的技术方向 -5. **HN 社区热议** - 本周 Hacker News AI 讨论的核心话题与社区情绪 -6. **官方动态** - Anthropic 和 OpenAI 本周发布的重要内容(若有) -7. **下周信号** - 基于本周数据,预判值得关注的趋势或即将到来的事件 - -语言要求:中文,简洁专业,适合技术开发者快速掌握一周动态。 -`; -} - -export function buildMonthlyPrompt( - sourceDigests: Record, - monthStr: string, - lang: "zh" | "en" = "zh", -): string { - const digestEntries = Object.entries(sourceDigests) - .map(([key, content]) => `## ${key}\n\n${content}`) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a technical analyst focused on the AI open-source ecosystem. The following are ${monthStr} AI tool community digest summaries (${Object.keys(sourceDigests).length} reports total). Generate a comprehensive monthly review. - -${digestEntries} - ---- - -Generate an AI Tools Ecosystem Monthly Report with these sections: - -1. **Month's Top Stories** - 5-10 most important events and milestones this month, in chronological order -2. **CLI Tools Monthly Progress** - Overall development trajectory, major releases, and community growth for each key AI CLI tool -3. **AI Agent Ecosystem Monthly Review** - Ecosystem landscape shifts, emerging projects, notable signals this month -4. **Technical Trend Summary** - Most significant technical directions and paradigm shifts in AI open-source this month -5. **Community Health Assessment** - Monthly activity comparison across major projects, developer engagement evaluation -6. **Official Announcements Review** - Strategic analysis of Anthropic and OpenAI content published this month -7. **Next Month's Outlook** - Based on this month's trends, predict key directions and potential events to watch - -Style: English, in-depth analysis, data-driven, suited for monthly retrospectives and strategic decision-making. -`; - } - - return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${monthStr} 月的 AI 工具社区动态汇总(共 ${Object.keys(sourceDigests).length} 份报告),请生成本月综合回顾报告。 - -${digestEntries} - ---- - -请生成《AI 工具生态月报》,包含以下部分: - -1. **月度要闻** - 本月最重要的 5-10 条事件和里程碑,按时间排列 -2. **CLI 工具月度进展** - 各主要 AI CLI 工具本月整体发展轨迹、重要版本、社区规模变化 -3. **AI Agent 生态月报** - 本月生态格局变化、新兴项目、值得关注的信号 -4. **技术趋势总结** - 本月 AI 开源领域最显著的技术方向与范式变化 -5. **社区生态健康度** - 各主要项目月度活跃度对比、开发者参与度评估 -6. **官方动态回顾** - Anthropic 和 OpenAI 本月发布内容的战略意义分析 -7. **下月展望** - 基于本月趋势,预判值得重点关注的方向和潜在事件 - -语言要求:中文,深度分析,数据驱动,适合月度复盘和战略决策参考。 -`; -} - -export function buildHnPrompt(data: HnData, dateStr: string, lang: "zh" | "en" = "zh"): string { - const storiesText = data.stories - .map((s, i) => - lang === "en" - ? `${i + 1}. **${s.title}**\n` + - ` Link: ${s.url}\n` + - ` Discussion: ${s.hnUrl}\n` + - ` Score: ${s.points} | Comments: ${s.comments} | Author: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}` - : `${i + 1}. **${s.title}**\n` + - ` 链接: ${s.url}\n` + - ` 讨论: ${s.hnUrl}\n` + - ` 分数: ${s.points} | 评论: ${s.comments} | 作者: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}`, - ) - .join("\n\n"); - - if (lang === "en") { - return `You are an AI industry news analyst. The following are AI-related top posts from Hacker News in the past 24 hours as of ${dateStr} (sorted by score, ${data.stories.length} total): - ---- - -${storiesText} - ---- - -Generate a structured Hacker News AI Community Digest in English: - -1. **Today's Highlights** — 3-5 sentences on the hottest AI discussion topics and community sentiment on HN today - -2. **Top News & Discussions** — Organized by category, select the 2-5 most representative items per category, each with: - - Title (with original link) + HN discussion link - - Score and comment count - - One sentence: why this matters, what the community's typical reaction is - - Categories: - - 🔬 Models & Research (new model releases, papers, benchmarks) - - 🛠️ Tools & Engineering (open-source projects, frameworks, engineering practices) - - 🏢 Industry News (company news, funding, product launches) - - 💬 Opinions & Debates (notable Ask HN, Show HN, or hot discussion threads) - -3. **Community Sentiment Signal** — 100-200 words analyzing today's HN AI discussion mood and focus: - - Which topics are most active (high score + high comments)? - - Any clear points of controversy or consensus? - - Compared to last cycle, any notable shift in focus? - -4. **Worth Deep Reading** — List 2-3 pieces most worth developers/researchers reading in depth, with brief reasoning - -Style: English, concise and professional, preserve all original links. -`; - } - - return `你是 AI 行业资讯分析师。以下是 ${dateStr} 从 Hacker News 抓取的过去 24 小时内 AI 相关热门帖子(按分数降序,共 ${data.stories.length} 条): - ---- - -${storiesText} - ---- - -请生成一份结构清晰的《Hacker News AI 社区动态日报》,要求: - -1. **今日速览** — 3~5 句话,概括今日 HN 社区围绕 AI 最热门的讨论方向和情绪 - -2. **热门新闻与讨论** — 按以下分类整理,每类选取最具代表性的 2~5 条,每条包含: - - 标题(附原文链接)+ HN 讨论链接 - - 分数和评论数 - - 一句话说明:这条内容为什么值得关注,社区有何典型反应 - - 分类: - - 🔬 模型与研究(新模型发布、论文、基准测试) - - 🛠️ 工具与工程(开源项目、框架、工程实践) - - 🏢 产业动态(公司新闻、融资、产品发布) - - 💬 观点与争议(值得关注的 Ask HN、Show HN 或热议帖子) - -3. **社区情绪信号** — 100~200 字,分析今日 HN AI 讨论的整体情绪和关注重点: - - 社区对哪类话题最活跃(高分 + 高评论)? - - 有无明显的争议点或共识? - - 与上周期相比,关注方向有无明显变化? - -4. **值得深读** — 列出 2~3 条今日最值得开发者/研究者深入阅读的内容,简述理由 - -语言要求:中文,简洁专业,保留所有原文链接。 -`; -} +/** + * LLM prompt builders and item formatting. + */ + +import type { RepoConfig, GitHubItem, GitHubRelease } from "./github.ts"; +import type { WebFetchResult } from "./web.ts"; +import type { TrendingData } from "./trending.ts"; +import type { HnData } from "./hn.ts"; + +// --------------------------------------------------------------------------- +// Types +// --------------------------------------------------------------------------- + +export interface RepoDigest { + config: RepoConfig; + issues: GitHubItem[]; + prs: GitHubItem[]; + releases: GitHubRelease[]; + summary: string; +} + +// --------------------------------------------------------------------------- +// Formatting +// --------------------------------------------------------------------------- + +export function formatItem(item: GitHubItem, lang: "zh" | "en" = "zh"): string { + const labels = item.labels.map((l) => l.name).join(", "); + const labelStr = labels ? ` [${labels}]` : ""; + const body = (item.body ?? "").replace(/\n/g, " ").trim().slice(0, 300); + const ellipsis = (item.body ?? "").length > 300 ? "..." : ""; + const t = + lang === "en" + ? { + author: "Author", + created: "Created", + updated: "Updated", + comments: "Comments", + url: "URL", + summary: "Summary", + } + : { author: "作者", created: "创建", updated: "更新", comments: "评论", url: "链接", summary: "摘要" }; + return [ + `#${item.number} [${item.state.toUpperCase()}]${labelStr} ${item.title}`, + ` ${t.author}: @${item.user.login} | ${t.created}: ${item.created_at.slice(0, 10)} | ${t.updated}: ${item.updated_at.slice(0, 10)} | ${t.comments}: ${item.comments} | 👍: ${item.reactions?.["+1"] ?? 0}`, + ` ${t.url}: ${item.html_url}`, + ` ${t.summary}: ${body}${ellipsis}`, + ].join("\n"); +} + +// --------------------------------------------------------------------------- +// Sampling helpers (shared) +// --------------------------------------------------------------------------- + +const CLI_ISSUE_LIMIT = 30; +const CLI_PR_LIMIT = 20; + +/** Sort by comment count desc, take top N. */ +function topN(items: GitHubItem[], n: number): GitHubItem[] { + return [...items].sort((a, b) => b.comments - a.comments).slice(0, n); +} + +function sampleNote(total: number, sampled: number, lang: "zh" | "en" = "zh"): string { + if (lang === "en") { + return total > sampled + ? `(Total: ${total} items; showing top ${sampled} by comment count)` + : `(Total: ${total} items)`; + } + return total > sampled ? `(共 ${total} 条,以下展示评论数最多的 ${sampled} 条)` : `(共 ${total} 条)`; +} + +// --------------------------------------------------------------------------- +// Prompts +// --------------------------------------------------------------------------- + +export function buildCliPrompt( + cfg: RepoConfig, + issues: GitHubItem[], + prs: GitHubItem[], + releases: GitHubRelease[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const sampledIssues = topN(issues, CLI_ISSUE_LIMIT); + const sampledPrs = topN(prs, CLI_PR_LIMIT); + + const issuesText = + sampledIssues.map((i) => formatItem(i, lang)).join("\n") || (lang === "en" ? "None" : "无"); + const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || (lang === "en" ? "None" : "无"); + const releasesText = releases.length + ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") + : lang === "en" + ? "None" + : "无"; + + const issueNote = sampleNote(issues.length, sampledIssues.length, lang); + const prNote = sampleNote(prs.length, sampledPrs.length, lang); + + if (lang === "en") { + return `You are a technical analyst focused on AI developer tools. Based on the following GitHub data, generate the ${cfg.name} community digest for ${dateStr}. + +# Data source: github.com/${cfg.repo} + +## Latest Releases (last 24h) +${releasesText} + +## Latest Issues (updated in last 24h)${issueNote} +${issuesText} + +## Latest Pull Requests (updated in last 24h)${prNote} +${prsText} + +--- + +Generate a structured English digest with the following sections: + +1. **Today's Highlights** - 2-3 sentences summarizing the most important updates +2. **Releases** - If new versions exist, summarize changes; omit if none +3. **Hot Issues** - Pick 10 noteworthy Issues, explain why they matter and community reaction +4. **Key PR Progress** - Pick 10 important PRs, describe features or fixes +5. **Feature Request Trends** - Distill the most-requested feature directions from all Issues +6. **Developer Pain Points** - Summarize recurring developer frustrations or high-frequency requests + +Style: concise and professional, suited for technical developers. Include GitHub links for each item. +`; + } + + return `你是一位专注于 AI 开发工具的技术分析师。请根据以下 GitHub 数据,生成 ${dateStr} 的 ${cfg.name} 社区动态日报。 + +# 数据来源: github.com/${cfg.repo} + +## 最新 Releases(过去24小时) +${releasesText} + +## 最新 Issues(过去24小时内更新)${issueNote} +${issuesText} + +## 最新 Pull Requests(过去24小时内更新)${prNote} +${prsText} + +--- + +请生成一份结构清晰的中文日报,包含以下部分: + +1. **今日速览** - 用2-3句话概括今天最重要的动态 +2. **版本发布** - 如有新版本,总结更新内容;无则省略 +3. **社区热点 Issues** - 挑选 10 个最值得关注的 Issue,说明为什么重要、社区反应如何 +4. **重要 PR 进展** - 挑选 10 个重要的 PR,说明功能或修复内容 +5. **功能需求趋势** - 从所有 Issues 中提炼出社区最关注的功能方向(如 IDE 集成、性能、新模型支持等) +6. **开发者关注点** - 总结开发者反馈中的痛点或高频需求 + +语言要求:简洁专业,适合技术开发者阅读。每个条目附上 GitHub 链接。 +`; +} + +const PEER_ISSUE_LIMIT = 30; +const PEER_PR_LIMIT = 20; + +export function buildPeerPrompt( + cfg: RepoConfig, + issues: GitHubItem[], + prs: GitHubItem[], + releases: GitHubRelease[], + dateStr: string, + issueLimit = PEER_ISSUE_LIMIT, + prLimit = PEER_PR_LIMIT, + lang: "zh" | "en" = "zh", +): string { + const totalIssues = issues.length; + const totalPrs = prs.length; + + const sampledIssues = topN(issues, issueLimit); + const sampledPrs = topN(prs, prLimit); + + const noneStr = lang === "en" ? "None" : "无"; + const issuesText = sampledIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; + const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; + const releasesText = releases.length + ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") + : noneStr; + + const openIssues = issues.filter((i) => i.state === "open").length; + const closedIssues = issues.filter((i) => i.state === "closed").length; + const openPrs = prs.filter((p) => p.state === "open").length; + const mergedPrs = prs.filter((p) => p.state === "closed").length; + + const issueSampleNote = sampleNote(totalIssues, sampledIssues.length, lang); + const prSampleNote = sampleNote(totalPrs, sampledPrs.length, lang); + + if (lang === "en") { + return `You are an analyst of AI agent and personal AI assistant open-source projects. Based on the following GitHub data from ${cfg.name} (github.com/${cfg.repo}), generate a project digest for ${dateStr}. + +# Data Overview +- Issues updated in last 24h: ${totalIssues} (open/active: ${openIssues}, closed: ${closedIssues}) +- PRs updated in last 24h: ${totalPrs} (open: ${openPrs}, merged/closed: ${mergedPrs}) +- New releases: ${releases.length} + +## Latest Releases +${releasesText} + +## Latest Issues ${issueSampleNote} +${issuesText} + +## Latest Pull Requests ${prSampleNote} +${prsText} + +--- + +Generate a structured English ${cfg.name} project digest with the following sections: + +1. **Today's Overview** - 3-5 sentences summarizing project status, including activity assessment +2. **Releases** - If new versions exist, detail changes, breaking changes, migration notes; omit if none +3. **Project Progress** - Merged/closed PRs today, what features advanced or were fixed +4. **Community Hot Topics** - Most active Issues/PRs with most comments/reactions (with links), analyze underlying needs +5. **Bugs & Stability** - Bugs, crashes, regressions reported today, ranked by severity, note if fix PRs exist +6. **Feature Requests & Roadmap Signals** - User-requested features, predict which might be in next version +7. **User Feedback Summary** - Real user pain points, use cases, satisfaction/dissatisfaction +8. **Backlog Watch** - Long-unanswered important Issues or PRs needing maintainer attention + +Style: objective, data-driven, highlighting project health. Include GitHub links for each item. +`; + } + + return `你是一位 AI 智能体与个人 AI 助手领域开源项目分析师。请根据以下来自 ${cfg.name} (github.com/${cfg.repo}) 的 GitHub 数据,生成 ${dateStr} 的项目动态日报。 + +# 数据概览 +- 过去24小时 Issues 更新:${totalIssues} 条(新开/活跃: ${openIssues},已关闭: ${closedIssues}) +- 过去24小时 PR 更新:${totalPrs} 条(待合并: ${openPrs},已合并/关闭: ${mergedPrs}) +- 新版本发布:${releases.length} 个 + +## 最新 Releases +${releasesText} + +## 最新 Issues ${issueSampleNote} +${issuesText} + +## 最新 Pull Requests ${prSampleNote} +${prsText} + +--- + +请生成一份结构清晰的 ${cfg.name} 项目日报,包含以下部分: + +1. **今日速览** - 用3-5句话概括项目今日整体状态,包括活跃度评估 +2. **版本发布** - 如有新版本,详细说明更新内容、破坏性变更、迁移注意事项;无则省略 +3. **项目进展** - 今日合并/关闭的重要 PR,说明推进了哪些功能或修复,项目整体向前迈进了多少 +4. **社区热点** - 今日讨论最活跃、评论最多、反应最多的 Issues/PRs(附链接),分析背后的诉求 +5. **Bug 与稳定性** - 今日报告的 Bug、崩溃、回归问题,按严重程度排列,标注是否已有 fix PR +6. **功能请求与路线图信号** - 用户提出的新功能需求,结合已有 PR 判断哪些可能被纳入下一版本 +7. **用户反馈摘要** - 从 Issues 评论中提炼真实用户痛点、使用场景、满意/不满意的地方 +8. **待处理积压** - 长期未响应的重要 Issue 或 PR,提醒维护者关注 + +语言要求:客观专业,数据驱动,突出项目健康度。每个条目附上 GitHub 链接。 +`; +} + +export function buildPeersComparisonPrompt( + openclawDigest: RepoDigest, + peerDigests: RepoDigest[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; + + const openclawSection = + lang === "en" + ? `## OpenClaw (core reference, github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}` + : `## OpenClaw(核心参照,github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}`; + + const peerSections = peerDigests + .map((d) => { + const hasData = d.issues.length || d.prs.length || d.releases.length; + if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; + return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; + }) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a senior analyst of the AI agent and personal AI assistant open-source ecosystem. The following are ${dateStr} community digest summaries for each project. + +${openclawSection} + +--- + +${peerSections} + +--- + +Generate a cross-project comparison report in English with these sections: + +1. **Ecosystem Overview** - 3-5 sentences on the overall personal AI assistant / agent open-source landscape +2. **Activity Comparison** - Table comparing Issues count, PR count, Release status, and health score for each project +3. **OpenClaw's Position** - Advantages vs peers, technical approach differences, community size comparison +4. **Shared Technical Focus Areas** - Requirements emerging across multiple projects (note which projects, specific needs) +5. **Differentiation Analysis** - Key differences in feature focus, target users, technical architecture +6. **Community Momentum & Maturity** - Activity tiers, which are rapidly iterating, which are stabilizing +7. **Trend Signals** - Industry trends extracted from community feedback, value for AI agent developers + +Style: concise and professional, data-backed, suited for technical decision-makers and developers. +`; + } + + return `你是一位专注于 AI 智能体与个人 AI 助手开源生态的资深技术分析师。以下是 ${dateStr} 各开源项目的社区动态摘要。 + +${openclawSection} + +--- + +${peerSections} + +--- + +请基于上述各项目的动态,生成一份横向对比分析报告,包含以下部分: + +1. **生态全景** - 用3-5句话概括个人 AI 助手/自主智能体开源生态整体态势 +2. **各项目活跃度对比** - 以表格形式汇总各项目今日的 Issues 数、PR 数、Release 情况及健康度评估 +3. **OpenClaw 在生态中的定位** - 与同类相比的优势、技术路线差异、社区规模对比 +4. **共同关注的技术方向** - 多项目共同涌现的需求(注明涉及哪些项目、具体诉求) +5. **差异化定位分析** - 功能侧重、目标用户、技术架构的关键差异 +6. **社区热度与成熟度** - 活跃度分层,哪些处于快速迭代阶段,哪些在质量巩固阶段 +7. **值得关注的趋势信号** - 从社区反馈中提炼行业趋势,对 AI 智能体开发者的参考价值 + +语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 +`; +} + +export function buildSkillsPrompt( + prs: GitHubItem[], + issues: GitHubItem[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const topPrs = topN(prs, 20); + const topIssues = topN(issues, 15); + + const noneStr = lang === "en" ? "None" : "无"; + const prsText = topPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; + const issuesText = topIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; + + if (lang === "en") { + return `You are a technical analyst focused on the Claude Code ecosystem. The following data is from github.com/anthropics/skills (official Claude Code Skills repository). Analyze the community's most-watched Skills activity (data as of ${dateStr}). + +## Repository Context +anthropics/skills is the official Claude Code Skills collection. Each PR typically represents a new or improved Skill. The community proposes new Skills and reports issues via Issues; PRs represent actual Skill submissions. + +## Popular Pull Requests (sorted by comments, ${prs.length} total, showing top ${topPrs.length}) +${prsText} + +## Community Issues (sorted by comments, ${issues.length} total, showing top ${topIssues.length}) +${issuesText} + +--- + +Generate a Claude Code Skills community highlights report in English with these sections: + +1. **Top Skills Ranking** - List the 5-8 most-discussed Skills (PRs) by comments/attention, describe each Skill's functionality, discussion highlights, and current status (open/merged/draft) +2. **Community Demand Trends** - From Issues, distill the most-anticipated new Skill directions (e.g. workflow automation, code review, test generation, documentation) +3. **High-Potential Pending Skills** - Active-comment PRs not yet merged; these Skills may land soon +4. **Skills Ecosystem Insight** - One-sentence summary: what is the community's most concentrated demand at the Skills level? + +Style: concise and professional, include GitHub links for each item. +`; + } + + return `你是一位专注于 Claude Code 生态的技术分析师。以下是来自 github.com/anthropics/skills(Claude Code Skills 官方仓库)的数据,请分析社区最关注的 Skills 动态(数据截止 ${dateStr})。 + +## 仓库说明 +anthropics/skills 是 Claude Code 官方 Skills 集合仓库,每个 PR 通常对应一个新增或改进的 Skill。社区通过 Issues 提出新 Skill 需求或反馈问题,PR 则代表实际提交的 Skill。 + +## 热门 Pull Requests(按评论数排序,共 ${prs.length} 条,展示前 ${topPrs.length} 条) +${prsText} + +## 社区 Issues(按评论数排序,共 ${issues.length} 条,展示前 ${topIssues.length} 条) +${issuesText} + +--- + +请生成一份 Claude Code Skills 社区热点报告,包含以下部分: + +1. **热门 Skills 排行** - 列出评论/关注度最高的 5~8 个 Skills(PR),说明每个 Skill 的功能、社区讨论热点及当前状态(open/merged/draft) +2. **社区需求趋势** - 从 Issues 中提炼社区最期待的新 Skill 方向(如工作流自动化、代码审查、测试生成、文档等) +3. **高潜力待合并 Skills** - 评论活跃但尚未合并的 PR,这些 Skills 可能近期落地 +4. **Skills 生态洞察** - 一句话总结:当前社区在 Skills 层面最集中的诉求是什么 + +语言要求:简洁专业,每个条目附上 GitHub 链接。 +`; +} + +export function buildComparisonPrompt( + digests: RepoDigest[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; + + const sections = digests + .map((d) => { + const hasData = d.issues.length || d.prs.length || d.releases.length; + if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; + return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; + }) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a senior technical analyst of the AI developer tools ecosystem. The following are ${dateStr} community digest summaries for each major AI CLI tool: + +${sections} + +--- + +Generate a cross-tool comparison report in English with these sections: + +1. **Ecosystem Overview** - 3-5 sentences on the overall AI CLI tools development landscape +2. **Activity Comparison** - Table comparing Issues count, PR count, Release status for each tool today +3. **Shared Feature Directions** - Requirements appearing across multiple tool communities (note which tools, specific needs) +4. **Differentiation Analysis** - Differences in feature focus, target users, and technical approach +5. **Community Momentum & Maturity** - Which tools have more active communities, which are rapidly iterating +6. **Trend Signals** - Industry trends from community feedback, reference value for developers + +Style: concise and professional, data-backed, suited for technical decision-makers and developers. +`; + } + + return `你是一位专注于 AI 开发工具生态的资深技术分析师。以下是 ${dateStr} 各主流 AI CLI 工具的社区动态摘要: + +${sections} + +--- + +请基于上述各工具的动态,生成一份横向对比分析报告,包含以下部分: + +1. **生态全景** - 用3-5句话概括当前 AI CLI 工具整体发展态势 +2. **各工具活跃度对比** - 以表格形式汇总各工具今日的 Issues 数、PR 数、Release 情况 +3. **共同关注的功能方向** - 多个工具社区都在关注的需求(说明哪些工具、具体诉求) +4. **差异化定位分析** - 各工具在功能侧重、目标用户、技术路线上的差异 +5. **社区热度与成熟度** - 哪些工具社区更活跃,哪些处于快速迭代阶段 +6. **值得关注的趋势信号** - 从社区反馈中提炼出的行业趋势,对开发者有何参考价值 + +语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 +`; +} + +export function buildTrendingPrompt(data: TrendingData, dateStr: string, lang: "zh" | "en" = "zh"): string { + const trendingSection = + data.trendingFetchSuccess && data.trendingRepos.length > 0 + ? data.trendingRepos + .map( + (r) => + `- [${r.fullName}](${r.url})` + + (r.language ? ` [${r.language}]` : "") + + ` ⭐${r.totalStars.toLocaleString()}` + + (r.todayStars > 0 ? ` (+${r.todayStars} today)` : "") + + (r.forks > 0 ? ` 🍴${r.forks.toLocaleString()}` : "") + + (r.description ? `\n ${r.description}` : ""), + ) + .join("\n") + : lang === "en" + ? "(Unable to fetch today's GitHub Trending list)" + : "(未能抓取今日 GitHub Trending 榜单)"; + + const searchSection = + data.searchRepos.length > 0 + ? data.searchRepos + .map( + (r) => + `- [${r.fullName}](${r.url})` + + (r.language ? ` [${r.language}]` : "") + + ` ⭐${r.stargazersCount.toLocaleString()}` + + ` [topic:${r.searchQuery}]` + + (r.description ? `\n ${r.description}` : ""), + ) + .join("\n") + : lang === "en" + ? "(No search results)" + : "(无搜索结果)"; + + if (lang === "en") { + return `You are a technical analyst focused on the AI open-source ecosystem. The following is ${dateStr} GitHub AI-related trending repository data. Please filter for AI relevance, categorize, and analyze trends. + +## Data Sources +- **Trending List** (github.com/trending, today's stars most reliable): Real-time hot list with today's new stars +- **Topic Search** (GitHub Search API, topic tags): AI-related projects active in last 7 days, grouped by topic + +--- + +## GitHub Today's Trending (${data.trendingRepos.length} repositories) +${trendingSection} + +--- + +## AI Topic Search Results (${data.searchRepos.length} repositories, deduplicated) +${searchSection} + +--- + +Generate a structured AI Open Source Trends Report in English: + +**Step 1 (Filter)**: From the above data, select projects clearly related to AI/ML (exclude unrelated general tools, frontend frameworks, games, etc.). Skip non-AI trending repos. + +**Step 2 (Categorize)**: Group filtered projects into these categories (a project can belong to multiple; pick the primary one): +- 🔧 AI Infrastructure (frameworks, SDKs, inference engines, dev tools, CLI) +- 🤖 AI Agents / Workflows (agent frameworks, automation, multi-agent systems) +- 📦 AI Applications (specific apps, vertical solutions) +- 🧠 LLMs / Training (model weights, training frameworks, fine-tuning tools) +- 🔍 RAG / Knowledge (vector databases, retrieval-augmented generation, knowledge management) + +**Step 3 (Output Report)** with these sections: + +1. **Today's Highlights** — 3-5 sentences on the most noteworthy AI open-source developments today + +2. **Top Projects by Category** — For each category, list 3-8 representative projects, each with: + - Project name (with link) + - Stars data (total + today's new, if available) + - One sentence: what it is and why it's worth attention today + +3. **Trend Signal Analysis** — 200-300 words, distill from today's hot list: + - Which type of AI tool is getting explosive community attention? + - Any new tech stacks or directions appearing for the first time? + - Connection to recent LLM releases / industry events + +4. **Community Hot Spots** — Bullet list of 3-5 specific projects or directions worth developer focus, with brief reasoning + +Style: English, professional and concise, must include GitHub links for every project. +`; + } + + return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${dateStr} 的 GitHub AI 相关热门仓库数据,请进行 AI 相关性筛选、分类和趋势分析。 + +## 数据说明 +- **Trending 榜单**(github.com/trending,今日 stars 数最可信):今日实时热榜,含今日新增 stars +- **主题搜索**(GitHub Search API,topic 标签):7天内活跃的 AI 相关项目,按主题分类 + +--- + +## GitHub 今日 Trending 榜单(共 ${data.trendingRepos.length} 个仓库) +${trendingSection} + +--- + +## AI 主题搜索结果(共 ${data.searchRepos.length} 个仓库,已去重) +${searchSection} + +--- + +请生成一份结构清晰的《AI 开源趋势日报》,要求: + +**第一步(过滤)**:从以上数据中筛选出与 AI/ML 明确相关的项目(排除与 AI 无关的通用工具、前端框架、游戏等),对于 Trending 榜单中的非 AI 项目直接略去。 + +**第二步(分类)**:将筛选后的项目按以下维度分类(一个项目可归入多类,优先归入最主要类别): +- 🔧 AI 基础工具(框架、SDK、推理引擎、开发工具、CLI) +- 🤖 AI 智能体/工作流(Agent 框架、自动化、多智能体) +- 📦 AI 应用(具体应用产品、垂直场景解决方案) +- 🧠 大模型/训练(模型权重、训练框架、微调工具) +- 🔍 RAG/知识库(向量数据库、检索增强、知识管理) + +**第三步(输出报告)**,包含以下部分: + +1. **今日速览** — 3~5 句话概括今日 AI 开源领域最值得关注的动向 + +2. **各维度热门项目** — 每个维度列出 3~8 个代表项目,每项包含: + - 项目名(附链接) + - stars 数据(总量 + 今日新增,如有) + - 一句话说明:这个项目是什么,为什么今天值得关注 + +3. **趋势信号分析** — 200~300 字,从今日热榜中提炼: + - 哪类 AI 工具正在获得社区爆发性关注? + - 有无新兴技术栈或方向首次登榜? + - 与近期大模型发布/行业事件的关联 + +4. **社区关注热点** — 以 bullet 形式列出 3~5 个值得开发者重点关注的具体项目或方向,给出简短理由 + +语言要求:中文,专业简洁,每个项目必须附 GitHub 链接。 +`; +} + +export function buildWebReportPrompt( + results: WebFetchResult[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const isAnyFirstRun = results.some((r) => r.isFirstRun); + + const siteSections = results + .map(({ siteName, isFirstRun, newItems, totalDiscovered }) => { + const mode = + lang === "en" + ? isFirstRun + ? `First full crawl (sitemap total ${totalDiscovered} URLs, showing latest ${newItems.length} articles)` + : `Incremental update, ${newItems.length} new articles today` + : isFirstRun + ? `首次全量抓取(sitemap 共 ${totalDiscovered} 条 URL,以下为最新 ${newItems.length} 篇正文内容)` + : `今日增量更新,共 ${newItems.length} 篇新内容`; + + if (newItems.length === 0) return `## ${siteName}\n\n(${mode},暂无可供分析的内容。)`; + + const unableToExtract = lang === "en" ? "(Unable to extract text content)" : "(无法提取文本内容)"; + const itemsText = newItems + .map((item) => + [ + `### [${item.title || item.url}](${item.url})`, + `- 分类: ${item.category} | 发布/更新: ${item.lastmod.slice(0, 10) || "未知"}`, + `- 内容节选: ${item.content || unableToExtract}`, + ].join("\n"), + ) + .join("\n\n"); + + return `## ${siteName}(${mode})\n\n${itemsText}`; + }) + .join("\n\n---\n\n"); + + const firstRunNote = + lang === "en" + ? isAnyFirstRun + ? "This is the first full crawl. Please focus on the overall content landscape, historical context, and core themes of each site, rather than individual articles." + : "This is an incremental update. Please focus on today's new content and assess its strategic significance in context." + : isAnyFirstRun + ? "本次为首次全量抓取,请重点梳理各站点的内容格局、历史脉络与核心主题,而非仅关注单篇文章。" + : "本次为增量更新,请聚焦今日新增内容,并结合上下文判断其战略意义。"; + + if (lang === "en") { + return `You are a deep content analyst focused on AI, skilled at extracting strategic signals from official announcements, technical blogs, research papers, and product documentation. + +The following content was crawled on ${dateStr} from Anthropic (claude.com / anthropic.com) and OpenAI (openai.com). ${firstRunNote} + +${siteSections} + +--- + +Generate a detailed AI Official Content Tracking Report in English with these sections: + +1. **Today's Highlights** — 3-5 sentences on the most important new releases or developments, calling out key highlights + +2. **Anthropic / Claude Content Highlights** — Organize important content by category (news / research / engineering / learn, etc.): + - For each piece, 2-4 sentences extracting core insights, technical details, or business significance + - Note publication date and original link + - If first full crawl, trace important milestones chronologically + +3. **OpenAI Content Highlights** — Same structure, organized by research / release / company / safety categories + +4. **Strategic Signal Analysis** — Based on both companies' release cadence and content focus, analyze: + - Each company's recent technical priorities (model capabilities / safety / productization / ecosystem) + - Competitive dynamics: who is setting the agenda, who is following + - Potential impact on developers and enterprise users + +5. **Notable Details** — Extract hidden signals from titles, phrasing, and timing, e.g.: + - New terms or topics appearing for the first time + - Dense releases in a category (may signal a product milestone) + - Policy, compliance, and safety developments + +${isAnyFirstRun ? "6. **Content Landscape Overview** — First full crawl only: summarize the content category distribution for both companies and describe their content strategy style (academic-oriented vs product-oriented vs user stories, etc.)\n\n" : ""}Style: English, professional and detailed, suited for AI researchers, product managers, and technical decision-makers. Every item must include official links. +`; + } + + return `你是一位专注于 AI 领域的深度内容分析师,擅长从官方公告、技术博客、研究论文和产品文档中提炼战略信号。 + +以下是 ${dateStr} 从 Anthropic(claude.com / anthropic.com)和 OpenAI(openai.com)官网抓取的内容,${firstRunNote} + +${siteSections} + +--- + +请生成一份详实的《AI 官方内容追踪报告》,包含以下部分: + +1. **今日速览** — 3~5 句话概括最重要的新发布或动向,点出核心亮点 + +2. **Anthropic / Claude 内容精选** — 按分类(news / research / engineering / learn 等)逐条整理重要内容: + - 每篇用 2~4 句话提炼核心观点、技术细节或业务意义 + - 标注发布日期和原文链接 + - 如首次全量,按时间线梳理重要里程碑 + +3. **OpenAI 内容精选** — 同上,按 research / release / company / safety 等分类整理 + +4. **战略信号解读** — 基于两家公司的发布节奏和内容重点,分析: + - 各自近期的技术优先级(模型能力 / 安全 / 产品化 / 生态) + - 竞争态势:谁在引领议题,谁在跟进 + - 对开发者和企业用户的潜在影响 + +5. **值得关注的细节** — 从标题、措辞、发布时机中提取隐含信号,例如: + - 新兴词汇或话题的首次出现 + - 某类主题的密集发布(可能预示产品节点) + - 政策、合规、安全方面的动向 + +${isAnyFirstRun ? "6. **内容格局总览** — 首次全量独有:汇总两家公司各内容类别的数量分布,并说明各自的内容运营风格(学术导向 vs 产品导向 vs 用户故事等)\n\n" : ""}语言要求:中文,专业深入,内容详实,适合 AI 领域研究者、产品经理和技术决策者阅读。每个条目必须附上 GitHub/官网链接。 +`; +} + +export function buildWeeklyPrompt( + dailyDigests: Record, + weekStr: string, + lang: "zh" | "en" = "zh", +): string { + const digestEntries = Object.entries(dailyDigests) + .map(([date, content]) => `## ${date}\n\n${content}`) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a technical analyst focused on the AI open-source ecosystem. The following are daily digest summaries from the past 7 days (${weekStr}) of AI tool community activity. Generate a comprehensive weekly recap. + +${digestEntries} + +--- + +Generate an AI Tools Ecosystem Weekly Report with these sections: + +1. **Week's Top Stories** - 5-8 most important events, releases, and community developments this week, each with date +2. **CLI Tools Progress** - Overall activity and key changes for each AI CLI tool (Claude Code, Codex, Gemini CLI, etc.) +3. **AI Agent Ecosystem** - Key developments from OpenClaw and peer projects this week +4. **Open Source Trends** - Most notable technical directions from GitHub Trending and AI community this week +5. **HN Community Highlights** - Core AI discussion topics and community sentiment on Hacker News this week +6. **Official Announcements** - Important content published by Anthropic and OpenAI this week (if any) +7. **Next Week's Signals** - Based on this week's data, predict trends and upcoming events worth watching + +Style: English, concise and professional, helping technical developers quickly grasp the week's developments. +`; + } + + return `你是一位专注于 AI 开源生态的技术分析师。以下是过去 7 天(${weekStr})的 AI 工具社区每日动态摘要,请生成本周综合回顾报告。 + +${digestEntries} + +--- + +请生成《AI 工具生态周报》,包含以下部分: + +1. **本周要闻** - 5-8 条本周最重要的事件、版本发布、社区动向,每条附日期 +2. **CLI 工具进展** - 各 AI CLI 工具(Claude Code、Codex、Gemini CLI 等)本周整体动态与关键变化 +3. **AI Agent 生态** - OpenClaw 及同赛道项目的本周重要进展 +4. **开源趋势** - 本周 GitHub Trending 和 AI 社区最关注的技术方向 +5. **HN 社区热议** - 本周 Hacker News AI 讨论的核心话题与社区情绪 +6. **官方动态** - Anthropic 和 OpenAI 本周发布的重要内容(若有) +7. **下周信号** - 基于本周数据,预判值得关注的趋势或即将到来的事件 + +语言要求:中文,简洁专业,适合技术开发者快速掌握一周动态。 +`; +} + +export function buildMonthlyPrompt( + sourceDigests: Record, + monthStr: string, + lang: "zh" | "en" = "zh", +): string { + const digestEntries = Object.entries(sourceDigests) + .map(([key, content]) => `## ${key}\n\n${content}`) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a technical analyst focused on the AI open-source ecosystem. The following are ${monthStr} AI tool community digest summaries (${Object.keys(sourceDigests).length} reports total). Generate a comprehensive monthly review. + +${digestEntries} + +--- + +Generate an AI Tools Ecosystem Monthly Report with these sections: + +1. **Month's Top Stories** - 5-10 most important events and milestones this month, in chronological order +2. **CLI Tools Monthly Progress** - Overall development trajectory, major releases, and community growth for each key AI CLI tool +3. **AI Agent Ecosystem Monthly Review** - Ecosystem landscape shifts, emerging projects, notable signals this month +4. **Technical Trend Summary** - Most significant technical directions and paradigm shifts in AI open-source this month +5. **Community Health Assessment** - Monthly activity comparison across major projects, developer engagement evaluation +6. **Official Announcements Review** - Strategic analysis of Anthropic and OpenAI content published this month +7. **Next Month's Outlook** - Based on this month's trends, predict key directions and potential events to watch + +Style: English, in-depth analysis, data-driven, suited for monthly retrospectives and strategic decision-making. +`; + } + + return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${monthStr} 月的 AI 工具社区动态汇总(共 ${Object.keys(sourceDigests).length} 份报告),请生成本月综合回顾报告。 + +${digestEntries} + +--- + +请生成《AI 工具生态月报》,包含以下部分: + +1. **月度要闻** - 本月最重要的 5-10 条事件和里程碑,按时间排列 +2. **CLI 工具月度进展** - 各主要 AI CLI 工具本月整体发展轨迹、重要版本、社区规模变化 +3. **AI Agent 生态月报** - 本月生态格局变化、新兴项目、值得关注的信号 +4. **技术趋势总结** - 本月 AI 开源领域最显著的技术方向与范式变化 +5. **社区生态健康度** - 各主要项目月度活跃度对比、开发者参与度评估 +6. **官方动态回顾** - Anthropic 和 OpenAI 本月发布内容的战略意义分析 +7. **下月展望** - 基于本月趋势,预判值得重点关注的方向和潜在事件 + +语言要求:中文,深度分析,数据驱动,适合月度复盘和战略决策参考。 +`; +} + +export function buildHnPrompt(data: HnData, dateStr: string, lang: "zh" | "en" = "zh"): string { + const storiesText = data.stories + .map((s, i) => + lang === "en" + ? `${i + 1}. **${s.title}**\n` + + ` Link: ${s.url}\n` + + ` Discussion: ${s.hnUrl}\n` + + ` Score: ${s.points} | Comments: ${s.comments} | Author: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}` + : `${i + 1}. **${s.title}**\n` + + ` 链接: ${s.url}\n` + + ` 讨论: ${s.hnUrl}\n` + + ` 分数: ${s.points} | 评论: ${s.comments} | 作者: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}`, + ) + .join("\n\n"); + + if (lang === "en") { + return `You are an AI industry news analyst. The following are AI-related top posts from Hacker News in the past 24 hours as of ${dateStr} (sorted by score, ${data.stories.length} total): + +--- + +${storiesText} + +--- + +Generate a structured Hacker News AI Community Digest in English: + +1. **Today's Highlights** — 3-5 sentences on the hottest AI discussion topics and community sentiment on HN today + +2. **Top News & Discussions** — Organized by category, select the 2-5 most representative items per category, each with: + - Title (with original link) + HN discussion link + - Score and comment count + - One sentence: why this matters, what the community's typical reaction is + + Categories: + - 🔬 Models & Research (new model releases, papers, benchmarks) + - 🛠️ Tools & Engineering (open-source projects, frameworks, engineering practices) + - 🏢 Industry News (company news, funding, product launches) + - 💬 Opinions & Debates (notable Ask HN, Show HN, or hot discussion threads) + +3. **Community Sentiment Signal** — 100-200 words analyzing today's HN AI discussion mood and focus: + - Which topics are most active (high score + high comments)? + - Any clear points of controversy or consensus? + - Compared to last cycle, any notable shift in focus? + +4. **Worth Deep Reading** — List 2-3 pieces most worth developers/researchers reading in depth, with brief reasoning + +Style: English, concise and professional, preserve all original links. +`; + } + + return `你是 AI 行业资讯分析师。以下是 ${dateStr} 从 Hacker News 抓取的过去 24 小时内 AI 相关热门帖子(按分数降序,共 ${data.stories.length} 条): + +--- + +${storiesText} + +--- + +请生成一份结构清晰的《Hacker News AI 社区动态日报》,要求: + +1. **今日速览** — 3~5 句话,概括今日 HN 社区围绕 AI 最热门的讨论方向和情绪 + +2. **热门新闻与讨论** — 按以下分类整理,每类选取最具代表性的 2~5 条,每条包含: + - 标题(附原文链接)+ HN 讨论链接 + - 分数和评论数 + - 一句话说明:这条内容为什么值得关注,社区有何典型反应 + + 分类: + - 🔬 模型与研究(新模型发布、论文、基准测试) + - 🛠️ 工具与工程(开源项目、框架、工程实践) + - 🏢 产业动态(公司新闻、融资、产品发布) + - 💬 观点与争议(值得关注的 Ask HN、Show HN 或热议帖子) + +3. **社区情绪信号** — 100~200 字,分析今日 HN AI 讨论的整体情绪和关注重点: + - 社区对哪类话题最活跃(高分 + 高评论)? + - 有无明显的争议点或共识? + - 与上周期相比,关注方向有无明显变化? + +4. **值得深读** — 列出 2~3 条今日最值得开发者/研究者深入阅读的内容,简述理由 + +语言要求:中文,简洁专业,保留所有原文链接。 +`; +} From e9e5f67eb72583e4e9c7cb8e3ee2f71454cb6f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=BE=99?= <76432572+nankingjing@users.noreply.github.com> Date: Tue, 14 Jul 2026 09:30:03 +0800 Subject: [PATCH 3/4] fix(prompts): avoid extra space before Chinese section parentheses --- src/prompts.ts | 1736 ++++++++++++++++++++++++------------------------ 1 file changed, 868 insertions(+), 868 deletions(-) diff --git a/src/prompts.ts b/src/prompts.ts index 7cb8de8..a5e303a 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -1,868 +1,868 @@ -/** - * LLM prompt builders and item formatting. - */ - -import type { RepoConfig, GitHubItem, GitHubRelease } from "./github.ts"; -import type { WebFetchResult } from "./web.ts"; -import type { TrendingData } from "./trending.ts"; -import type { HnData } from "./hn.ts"; - -// --------------------------------------------------------------------------- -// Types -// --------------------------------------------------------------------------- - -export interface RepoDigest { - config: RepoConfig; - issues: GitHubItem[]; - prs: GitHubItem[]; - releases: GitHubRelease[]; - summary: string; -} - -// --------------------------------------------------------------------------- -// Formatting -// --------------------------------------------------------------------------- - -export function formatItem(item: GitHubItem, lang: "zh" | "en" = "zh"): string { - const labels = item.labels.map((l) => l.name).join(", "); - const labelStr = labels ? ` [${labels}]` : ""; - const body = (item.body ?? "").replace(/\n/g, " ").trim().slice(0, 300); - const ellipsis = (item.body ?? "").length > 300 ? "..." : ""; - const t = - lang === "en" - ? { - author: "Author", - created: "Created", - updated: "Updated", - comments: "Comments", - url: "URL", - summary: "Summary", - } - : { author: "作者", created: "创建", updated: "更新", comments: "评论", url: "链接", summary: "摘要" }; - return [ - `#${item.number} [${item.state.toUpperCase()}]${labelStr} ${item.title}`, - ` ${t.author}: @${item.user.login} | ${t.created}: ${item.created_at.slice(0, 10)} | ${t.updated}: ${item.updated_at.slice(0, 10)} | ${t.comments}: ${item.comments} | 👍: ${item.reactions?.["+1"] ?? 0}`, - ` ${t.url}: ${item.html_url}`, - ` ${t.summary}: ${body}${ellipsis}`, - ].join("\n"); -} - -// --------------------------------------------------------------------------- -// Sampling helpers (shared) -// --------------------------------------------------------------------------- - -const CLI_ISSUE_LIMIT = 30; -const CLI_PR_LIMIT = 20; - -/** Sort by comment count desc, take top N. */ -function topN(items: GitHubItem[], n: number): GitHubItem[] { - return [...items].sort((a, b) => b.comments - a.comments).slice(0, n); -} - -function sampleNote(total: number, sampled: number, lang: "zh" | "en" = "zh"): string { - if (lang === "en") { - return total > sampled - ? `(Total: ${total} items; showing top ${sampled} by comment count)` - : `(Total: ${total} items)`; - } - return total > sampled ? `(共 ${total} 条,以下展示评论数最多的 ${sampled} 条)` : `(共 ${total} 条)`; -} - -// --------------------------------------------------------------------------- -// Prompts -// --------------------------------------------------------------------------- - -export function buildCliPrompt( - cfg: RepoConfig, - issues: GitHubItem[], - prs: GitHubItem[], - releases: GitHubRelease[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const sampledIssues = topN(issues, CLI_ISSUE_LIMIT); - const sampledPrs = topN(prs, CLI_PR_LIMIT); - - const issuesText = - sampledIssues.map((i) => formatItem(i, lang)).join("\n") || (lang === "en" ? "None" : "无"); - const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || (lang === "en" ? "None" : "无"); - const releasesText = releases.length - ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") - : lang === "en" - ? "None" - : "无"; - - const issueNote = sampleNote(issues.length, sampledIssues.length, lang); - const prNote = sampleNote(prs.length, sampledPrs.length, lang); - - if (lang === "en") { - return `You are a technical analyst focused on AI developer tools. Based on the following GitHub data, generate the ${cfg.name} community digest for ${dateStr}. - -# Data source: github.com/${cfg.repo} - -## Latest Releases (last 24h) -${releasesText} - -## Latest Issues (updated in last 24h)${issueNote} -${issuesText} - -## Latest Pull Requests (updated in last 24h)${prNote} -${prsText} - ---- - -Generate a structured English digest with the following sections: - -1. **Today's Highlights** - 2-3 sentences summarizing the most important updates -2. **Releases** - If new versions exist, summarize changes; omit if none -3. **Hot Issues** - Pick 10 noteworthy Issues, explain why they matter and community reaction -4. **Key PR Progress** - Pick 10 important PRs, describe features or fixes -5. **Feature Request Trends** - Distill the most-requested feature directions from all Issues -6. **Developer Pain Points** - Summarize recurring developer frustrations or high-frequency requests - -Style: concise and professional, suited for technical developers. Include GitHub links for each item. -`; - } - - return `你是一位专注于 AI 开发工具的技术分析师。请根据以下 GitHub 数据,生成 ${dateStr} 的 ${cfg.name} 社区动态日报。 - -# 数据来源: github.com/${cfg.repo} - -## 最新 Releases(过去24小时) -${releasesText} - -## 最新 Issues(过去24小时内更新)${issueNote} -${issuesText} - -## 最新 Pull Requests(过去24小时内更新)${prNote} -${prsText} - ---- - -请生成一份结构清晰的中文日报,包含以下部分: - -1. **今日速览** - 用2-3句话概括今天最重要的动态 -2. **版本发布** - 如有新版本,总结更新内容;无则省略 -3. **社区热点 Issues** - 挑选 10 个最值得关注的 Issue,说明为什么重要、社区反应如何 -4. **重要 PR 进展** - 挑选 10 个重要的 PR,说明功能或修复内容 -5. **功能需求趋势** - 从所有 Issues 中提炼出社区最关注的功能方向(如 IDE 集成、性能、新模型支持等) -6. **开发者关注点** - 总结开发者反馈中的痛点或高频需求 - -语言要求:简洁专业,适合技术开发者阅读。每个条目附上 GitHub 链接。 -`; -} - -const PEER_ISSUE_LIMIT = 30; -const PEER_PR_LIMIT = 20; - -export function buildPeerPrompt( - cfg: RepoConfig, - issues: GitHubItem[], - prs: GitHubItem[], - releases: GitHubRelease[], - dateStr: string, - issueLimit = PEER_ISSUE_LIMIT, - prLimit = PEER_PR_LIMIT, - lang: "zh" | "en" = "zh", -): string { - const totalIssues = issues.length; - const totalPrs = prs.length; - - const sampledIssues = topN(issues, issueLimit); - const sampledPrs = topN(prs, prLimit); - - const noneStr = lang === "en" ? "None" : "无"; - const issuesText = sampledIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; - const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; - const releasesText = releases.length - ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") - : noneStr; - - const openIssues = issues.filter((i) => i.state === "open").length; - const closedIssues = issues.filter((i) => i.state === "closed").length; - const openPrs = prs.filter((p) => p.state === "open").length; - const mergedPrs = prs.filter((p) => p.state === "closed").length; - - const issueSampleNote = sampleNote(totalIssues, sampledIssues.length, lang); - const prSampleNote = sampleNote(totalPrs, sampledPrs.length, lang); - - if (lang === "en") { - return `You are an analyst of AI agent and personal AI assistant open-source projects. Based on the following GitHub data from ${cfg.name} (github.com/${cfg.repo}), generate a project digest for ${dateStr}. - -# Data Overview -- Issues updated in last 24h: ${totalIssues} (open/active: ${openIssues}, closed: ${closedIssues}) -- PRs updated in last 24h: ${totalPrs} (open: ${openPrs}, merged/closed: ${mergedPrs}) -- New releases: ${releases.length} - -## Latest Releases -${releasesText} - -## Latest Issues ${issueSampleNote} -${issuesText} - -## Latest Pull Requests ${prSampleNote} -${prsText} - ---- - -Generate a structured English ${cfg.name} project digest with the following sections: - -1. **Today's Overview** - 3-5 sentences summarizing project status, including activity assessment -2. **Releases** - If new versions exist, detail changes, breaking changes, migration notes; omit if none -3. **Project Progress** - Merged/closed PRs today, what features advanced or were fixed -4. **Community Hot Topics** - Most active Issues/PRs with most comments/reactions (with links), analyze underlying needs -5. **Bugs & Stability** - Bugs, crashes, regressions reported today, ranked by severity, note if fix PRs exist -6. **Feature Requests & Roadmap Signals** - User-requested features, predict which might be in next version -7. **User Feedback Summary** - Real user pain points, use cases, satisfaction/dissatisfaction -8. **Backlog Watch** - Long-unanswered important Issues or PRs needing maintainer attention - -Style: objective, data-driven, highlighting project health. Include GitHub links for each item. -`; - } - - return `你是一位 AI 智能体与个人 AI 助手领域开源项目分析师。请根据以下来自 ${cfg.name} (github.com/${cfg.repo}) 的 GitHub 数据,生成 ${dateStr} 的项目动态日报。 - -# 数据概览 -- 过去24小时 Issues 更新:${totalIssues} 条(新开/活跃: ${openIssues},已关闭: ${closedIssues}) -- 过去24小时 PR 更新:${totalPrs} 条(待合并: ${openPrs},已合并/关闭: ${mergedPrs}) -- 新版本发布:${releases.length} 个 - -## 最新 Releases -${releasesText} - -## 最新 Issues ${issueSampleNote} -${issuesText} - -## 最新 Pull Requests ${prSampleNote} -${prsText} - ---- - -请生成一份结构清晰的 ${cfg.name} 项目日报,包含以下部分: - -1. **今日速览** - 用3-5句话概括项目今日整体状态,包括活跃度评估 -2. **版本发布** - 如有新版本,详细说明更新内容、破坏性变更、迁移注意事项;无则省略 -3. **项目进展** - 今日合并/关闭的重要 PR,说明推进了哪些功能或修复,项目整体向前迈进了多少 -4. **社区热点** - 今日讨论最活跃、评论最多、反应最多的 Issues/PRs(附链接),分析背后的诉求 -5. **Bug 与稳定性** - 今日报告的 Bug、崩溃、回归问题,按严重程度排列,标注是否已有 fix PR -6. **功能请求与路线图信号** - 用户提出的新功能需求,结合已有 PR 判断哪些可能被纳入下一版本 -7. **用户反馈摘要** - 从 Issues 评论中提炼真实用户痛点、使用场景、满意/不满意的地方 -8. **待处理积压** - 长期未响应的重要 Issue 或 PR,提醒维护者关注 - -语言要求:客观专业,数据驱动,突出项目健康度。每个条目附上 GitHub 链接。 -`; -} - -export function buildPeersComparisonPrompt( - openclawDigest: RepoDigest, - peerDigests: RepoDigest[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; - - const openclawSection = - lang === "en" - ? `## OpenClaw (core reference, github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}` - : `## OpenClaw(核心参照,github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}`; - - const peerSections = peerDigests - .map((d) => { - const hasData = d.issues.length || d.prs.length || d.releases.length; - if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; - return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; - }) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a senior analyst of the AI agent and personal AI assistant open-source ecosystem. The following are ${dateStr} community digest summaries for each project. - -${openclawSection} - ---- - -${peerSections} - ---- - -Generate a cross-project comparison report in English with these sections: - -1. **Ecosystem Overview** - 3-5 sentences on the overall personal AI assistant / agent open-source landscape -2. **Activity Comparison** - Table comparing Issues count, PR count, Release status, and health score for each project -3. **OpenClaw's Position** - Advantages vs peers, technical approach differences, community size comparison -4. **Shared Technical Focus Areas** - Requirements emerging across multiple projects (note which projects, specific needs) -5. **Differentiation Analysis** - Key differences in feature focus, target users, technical architecture -6. **Community Momentum & Maturity** - Activity tiers, which are rapidly iterating, which are stabilizing -7. **Trend Signals** - Industry trends extracted from community feedback, value for AI agent developers - -Style: concise and professional, data-backed, suited for technical decision-makers and developers. -`; - } - - return `你是一位专注于 AI 智能体与个人 AI 助手开源生态的资深技术分析师。以下是 ${dateStr} 各开源项目的社区动态摘要。 - -${openclawSection} - ---- - -${peerSections} - ---- - -请基于上述各项目的动态,生成一份横向对比分析报告,包含以下部分: - -1. **生态全景** - 用3-5句话概括个人 AI 助手/自主智能体开源生态整体态势 -2. **各项目活跃度对比** - 以表格形式汇总各项目今日的 Issues 数、PR 数、Release 情况及健康度评估 -3. **OpenClaw 在生态中的定位** - 与同类相比的优势、技术路线差异、社区规模对比 -4. **共同关注的技术方向** - 多项目共同涌现的需求(注明涉及哪些项目、具体诉求) -5. **差异化定位分析** - 功能侧重、目标用户、技术架构的关键差异 -6. **社区热度与成熟度** - 活跃度分层,哪些处于快速迭代阶段,哪些在质量巩固阶段 -7. **值得关注的趋势信号** - 从社区反馈中提炼行业趋势,对 AI 智能体开发者的参考价值 - -语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 -`; -} - -export function buildSkillsPrompt( - prs: GitHubItem[], - issues: GitHubItem[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const topPrs = topN(prs, 20); - const topIssues = topN(issues, 15); - - const noneStr = lang === "en" ? "None" : "无"; - const prsText = topPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; - const issuesText = topIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; - - if (lang === "en") { - return `You are a technical analyst focused on the Claude Code ecosystem. The following data is from github.com/anthropics/skills (official Claude Code Skills repository). Analyze the community's most-watched Skills activity (data as of ${dateStr}). - -## Repository Context -anthropics/skills is the official Claude Code Skills collection. Each PR typically represents a new or improved Skill. The community proposes new Skills and reports issues via Issues; PRs represent actual Skill submissions. - -## Popular Pull Requests (sorted by comments, ${prs.length} total, showing top ${topPrs.length}) -${prsText} - -## Community Issues (sorted by comments, ${issues.length} total, showing top ${topIssues.length}) -${issuesText} - ---- - -Generate a Claude Code Skills community highlights report in English with these sections: - -1. **Top Skills Ranking** - List the 5-8 most-discussed Skills (PRs) by comments/attention, describe each Skill's functionality, discussion highlights, and current status (open/merged/draft) -2. **Community Demand Trends** - From Issues, distill the most-anticipated new Skill directions (e.g. workflow automation, code review, test generation, documentation) -3. **High-Potential Pending Skills** - Active-comment PRs not yet merged; these Skills may land soon -4. **Skills Ecosystem Insight** - One-sentence summary: what is the community's most concentrated demand at the Skills level? - -Style: concise and professional, include GitHub links for each item. -`; - } - - return `你是一位专注于 Claude Code 生态的技术分析师。以下是来自 github.com/anthropics/skills(Claude Code Skills 官方仓库)的数据,请分析社区最关注的 Skills 动态(数据截止 ${dateStr})。 - -## 仓库说明 -anthropics/skills 是 Claude Code 官方 Skills 集合仓库,每个 PR 通常对应一个新增或改进的 Skill。社区通过 Issues 提出新 Skill 需求或反馈问题,PR 则代表实际提交的 Skill。 - -## 热门 Pull Requests(按评论数排序,共 ${prs.length} 条,展示前 ${topPrs.length} 条) -${prsText} - -## 社区 Issues(按评论数排序,共 ${issues.length} 条,展示前 ${topIssues.length} 条) -${issuesText} - ---- - -请生成一份 Claude Code Skills 社区热点报告,包含以下部分: - -1. **热门 Skills 排行** - 列出评论/关注度最高的 5~8 个 Skills(PR),说明每个 Skill 的功能、社区讨论热点及当前状态(open/merged/draft) -2. **社区需求趋势** - 从 Issues 中提炼社区最期待的新 Skill 方向(如工作流自动化、代码审查、测试生成、文档等) -3. **高潜力待合并 Skills** - 评论活跃但尚未合并的 PR,这些 Skills 可能近期落地 -4. **Skills 生态洞察** - 一句话总结:当前社区在 Skills 层面最集中的诉求是什么 - -语言要求:简洁专业,每个条目附上 GitHub 链接。 -`; -} - -export function buildComparisonPrompt( - digests: RepoDigest[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; - - const sections = digests - .map((d) => { - const hasData = d.issues.length || d.prs.length || d.releases.length; - if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; - return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; - }) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a senior technical analyst of the AI developer tools ecosystem. The following are ${dateStr} community digest summaries for each major AI CLI tool: - -${sections} - ---- - -Generate a cross-tool comparison report in English with these sections: - -1. **Ecosystem Overview** - 3-5 sentences on the overall AI CLI tools development landscape -2. **Activity Comparison** - Table comparing Issues count, PR count, Release status for each tool today -3. **Shared Feature Directions** - Requirements appearing across multiple tool communities (note which tools, specific needs) -4. **Differentiation Analysis** - Differences in feature focus, target users, and technical approach -5. **Community Momentum & Maturity** - Which tools have more active communities, which are rapidly iterating -6. **Trend Signals** - Industry trends from community feedback, reference value for developers - -Style: concise and professional, data-backed, suited for technical decision-makers and developers. -`; - } - - return `你是一位专注于 AI 开发工具生态的资深技术分析师。以下是 ${dateStr} 各主流 AI CLI 工具的社区动态摘要: - -${sections} - ---- - -请基于上述各工具的动态,生成一份横向对比分析报告,包含以下部分: - -1. **生态全景** - 用3-5句话概括当前 AI CLI 工具整体发展态势 -2. **各工具活跃度对比** - 以表格形式汇总各工具今日的 Issues 数、PR 数、Release 情况 -3. **共同关注的功能方向** - 多个工具社区都在关注的需求(说明哪些工具、具体诉求) -4. **差异化定位分析** - 各工具在功能侧重、目标用户、技术路线上的差异 -5. **社区热度与成熟度** - 哪些工具社区更活跃,哪些处于快速迭代阶段 -6. **值得关注的趋势信号** - 从社区反馈中提炼出的行业趋势,对开发者有何参考价值 - -语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 -`; -} - -export function buildTrendingPrompt(data: TrendingData, dateStr: string, lang: "zh" | "en" = "zh"): string { - const trendingSection = - data.trendingFetchSuccess && data.trendingRepos.length > 0 - ? data.trendingRepos - .map( - (r) => - `- [${r.fullName}](${r.url})` + - (r.language ? ` [${r.language}]` : "") + - ` ⭐${r.totalStars.toLocaleString()}` + - (r.todayStars > 0 ? ` (+${r.todayStars} today)` : "") + - (r.forks > 0 ? ` 🍴${r.forks.toLocaleString()}` : "") + - (r.description ? `\n ${r.description}` : ""), - ) - .join("\n") - : lang === "en" - ? "(Unable to fetch today's GitHub Trending list)" - : "(未能抓取今日 GitHub Trending 榜单)"; - - const searchSection = - data.searchRepos.length > 0 - ? data.searchRepos - .map( - (r) => - `- [${r.fullName}](${r.url})` + - (r.language ? ` [${r.language}]` : "") + - ` ⭐${r.stargazersCount.toLocaleString()}` + - ` [topic:${r.searchQuery}]` + - (r.description ? `\n ${r.description}` : ""), - ) - .join("\n") - : lang === "en" - ? "(No search results)" - : "(无搜索结果)"; - - if (lang === "en") { - return `You are a technical analyst focused on the AI open-source ecosystem. The following is ${dateStr} GitHub AI-related trending repository data. Please filter for AI relevance, categorize, and analyze trends. - -## Data Sources -- **Trending List** (github.com/trending, today's stars most reliable): Real-time hot list with today's new stars -- **Topic Search** (GitHub Search API, topic tags): AI-related projects active in last 7 days, grouped by topic - ---- - -## GitHub Today's Trending (${data.trendingRepos.length} repositories) -${trendingSection} - ---- - -## AI Topic Search Results (${data.searchRepos.length} repositories, deduplicated) -${searchSection} - ---- - -Generate a structured AI Open Source Trends Report in English: - -**Step 1 (Filter)**: From the above data, select projects clearly related to AI/ML (exclude unrelated general tools, frontend frameworks, games, etc.). Skip non-AI trending repos. - -**Step 2 (Categorize)**: Group filtered projects into these categories (a project can belong to multiple; pick the primary one): -- 🔧 AI Infrastructure (frameworks, SDKs, inference engines, dev tools, CLI) -- 🤖 AI Agents / Workflows (agent frameworks, automation, multi-agent systems) -- 📦 AI Applications (specific apps, vertical solutions) -- 🧠 LLMs / Training (model weights, training frameworks, fine-tuning tools) -- 🔍 RAG / Knowledge (vector databases, retrieval-augmented generation, knowledge management) - -**Step 3 (Output Report)** with these sections: - -1. **Today's Highlights** — 3-5 sentences on the most noteworthy AI open-source developments today - -2. **Top Projects by Category** — For each category, list 3-8 representative projects, each with: - - Project name (with link) - - Stars data (total + today's new, if available) - - One sentence: what it is and why it's worth attention today - -3. **Trend Signal Analysis** — 200-300 words, distill from today's hot list: - - Which type of AI tool is getting explosive community attention? - - Any new tech stacks or directions appearing for the first time? - - Connection to recent LLM releases / industry events - -4. **Community Hot Spots** — Bullet list of 3-5 specific projects or directions worth developer focus, with brief reasoning - -Style: English, professional and concise, must include GitHub links for every project. -`; - } - - return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${dateStr} 的 GitHub AI 相关热门仓库数据,请进行 AI 相关性筛选、分类和趋势分析。 - -## 数据说明 -- **Trending 榜单**(github.com/trending,今日 stars 数最可信):今日实时热榜,含今日新增 stars -- **主题搜索**(GitHub Search API,topic 标签):7天内活跃的 AI 相关项目,按主题分类 - ---- - -## GitHub 今日 Trending 榜单(共 ${data.trendingRepos.length} 个仓库) -${trendingSection} - ---- - -## AI 主题搜索结果(共 ${data.searchRepos.length} 个仓库,已去重) -${searchSection} - ---- - -请生成一份结构清晰的《AI 开源趋势日报》,要求: - -**第一步(过滤)**:从以上数据中筛选出与 AI/ML 明确相关的项目(排除与 AI 无关的通用工具、前端框架、游戏等),对于 Trending 榜单中的非 AI 项目直接略去。 - -**第二步(分类)**:将筛选后的项目按以下维度分类(一个项目可归入多类,优先归入最主要类别): -- 🔧 AI 基础工具(框架、SDK、推理引擎、开发工具、CLI) -- 🤖 AI 智能体/工作流(Agent 框架、自动化、多智能体) -- 📦 AI 应用(具体应用产品、垂直场景解决方案) -- 🧠 大模型/训练(模型权重、训练框架、微调工具) -- 🔍 RAG/知识库(向量数据库、检索增强、知识管理) - -**第三步(输出报告)**,包含以下部分: - -1. **今日速览** — 3~5 句话概括今日 AI 开源领域最值得关注的动向 - -2. **各维度热门项目** — 每个维度列出 3~8 个代表项目,每项包含: - - 项目名(附链接) - - stars 数据(总量 + 今日新增,如有) - - 一句话说明:这个项目是什么,为什么今天值得关注 - -3. **趋势信号分析** — 200~300 字,从今日热榜中提炼: - - 哪类 AI 工具正在获得社区爆发性关注? - - 有无新兴技术栈或方向首次登榜? - - 与近期大模型发布/行业事件的关联 - -4. **社区关注热点** — 以 bullet 形式列出 3~5 个值得开发者重点关注的具体项目或方向,给出简短理由 - -语言要求:中文,专业简洁,每个项目必须附 GitHub 链接。 -`; -} - -export function buildWebReportPrompt( - results: WebFetchResult[], - dateStr: string, - lang: "zh" | "en" = "zh", -): string { - const isAnyFirstRun = results.some((r) => r.isFirstRun); - - const siteSections = results - .map(({ siteName, isFirstRun, newItems, totalDiscovered }) => { - const mode = - lang === "en" - ? isFirstRun - ? `First full crawl (sitemap total ${totalDiscovered} URLs, showing latest ${newItems.length} articles)` - : `Incremental update, ${newItems.length} new articles today` - : isFirstRun - ? `首次全量抓取(sitemap 共 ${totalDiscovered} 条 URL,以下为最新 ${newItems.length} 篇正文内容)` - : `今日增量更新,共 ${newItems.length} 篇新内容`; - - if (newItems.length === 0) return `## ${siteName}\n\n(${mode},暂无可供分析的内容。)`; - - const unableToExtract = lang === "en" ? "(Unable to extract text content)" : "(无法提取文本内容)"; - const itemsText = newItems - .map((item) => - [ - `### [${item.title || item.url}](${item.url})`, - `- 分类: ${item.category} | 发布/更新: ${item.lastmod.slice(0, 10) || "未知"}`, - `- 内容节选: ${item.content || unableToExtract}`, - ].join("\n"), - ) - .join("\n\n"); - - return `## ${siteName}(${mode})\n\n${itemsText}`; - }) - .join("\n\n---\n\n"); - - const firstRunNote = - lang === "en" - ? isAnyFirstRun - ? "This is the first full crawl. Please focus on the overall content landscape, historical context, and core themes of each site, rather than individual articles." - : "This is an incremental update. Please focus on today's new content and assess its strategic significance in context." - : isAnyFirstRun - ? "本次为首次全量抓取,请重点梳理各站点的内容格局、历史脉络与核心主题,而非仅关注单篇文章。" - : "本次为增量更新,请聚焦今日新增内容,并结合上下文判断其战略意义。"; - - if (lang === "en") { - return `You are a deep content analyst focused on AI, skilled at extracting strategic signals from official announcements, technical blogs, research papers, and product documentation. - -The following content was crawled on ${dateStr} from Anthropic (claude.com / anthropic.com) and OpenAI (openai.com). ${firstRunNote} - -${siteSections} - ---- - -Generate a detailed AI Official Content Tracking Report in English with these sections: - -1. **Today's Highlights** — 3-5 sentences on the most important new releases or developments, calling out key highlights - -2. **Anthropic / Claude Content Highlights** — Organize important content by category (news / research / engineering / learn, etc.): - - For each piece, 2-4 sentences extracting core insights, technical details, or business significance - - Note publication date and original link - - If first full crawl, trace important milestones chronologically - -3. **OpenAI Content Highlights** — Same structure, organized by research / release / company / safety categories - -4. **Strategic Signal Analysis** — Based on both companies' release cadence and content focus, analyze: - - Each company's recent technical priorities (model capabilities / safety / productization / ecosystem) - - Competitive dynamics: who is setting the agenda, who is following - - Potential impact on developers and enterprise users - -5. **Notable Details** — Extract hidden signals from titles, phrasing, and timing, e.g.: - - New terms or topics appearing for the first time - - Dense releases in a category (may signal a product milestone) - - Policy, compliance, and safety developments - -${isAnyFirstRun ? "6. **Content Landscape Overview** — First full crawl only: summarize the content category distribution for both companies and describe their content strategy style (academic-oriented vs product-oriented vs user stories, etc.)\n\n" : ""}Style: English, professional and detailed, suited for AI researchers, product managers, and technical decision-makers. Every item must include official links. -`; - } - - return `你是一位专注于 AI 领域的深度内容分析师,擅长从官方公告、技术博客、研究论文和产品文档中提炼战略信号。 - -以下是 ${dateStr} 从 Anthropic(claude.com / anthropic.com)和 OpenAI(openai.com)官网抓取的内容,${firstRunNote} - -${siteSections} - ---- - -请生成一份详实的《AI 官方内容追踪报告》,包含以下部分: - -1. **今日速览** — 3~5 句话概括最重要的新发布或动向,点出核心亮点 - -2. **Anthropic / Claude 内容精选** — 按分类(news / research / engineering / learn 等)逐条整理重要内容: - - 每篇用 2~4 句话提炼核心观点、技术细节或业务意义 - - 标注发布日期和原文链接 - - 如首次全量,按时间线梳理重要里程碑 - -3. **OpenAI 内容精选** — 同上,按 research / release / company / safety 等分类整理 - -4. **战略信号解读** — 基于两家公司的发布节奏和内容重点,分析: - - 各自近期的技术优先级(模型能力 / 安全 / 产品化 / 生态) - - 竞争态势:谁在引领议题,谁在跟进 - - 对开发者和企业用户的潜在影响 - -5. **值得关注的细节** — 从标题、措辞、发布时机中提取隐含信号,例如: - - 新兴词汇或话题的首次出现 - - 某类主题的密集发布(可能预示产品节点) - - 政策、合规、安全方面的动向 - -${isAnyFirstRun ? "6. **内容格局总览** — 首次全量独有:汇总两家公司各内容类别的数量分布,并说明各自的内容运营风格(学术导向 vs 产品导向 vs 用户故事等)\n\n" : ""}语言要求:中文,专业深入,内容详实,适合 AI 领域研究者、产品经理和技术决策者阅读。每个条目必须附上 GitHub/官网链接。 -`; -} - -export function buildWeeklyPrompt( - dailyDigests: Record, - weekStr: string, - lang: "zh" | "en" = "zh", -): string { - const digestEntries = Object.entries(dailyDigests) - .map(([date, content]) => `## ${date}\n\n${content}`) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a technical analyst focused on the AI open-source ecosystem. The following are daily digest summaries from the past 7 days (${weekStr}) of AI tool community activity. Generate a comprehensive weekly recap. - -${digestEntries} - ---- - -Generate an AI Tools Ecosystem Weekly Report with these sections: - -1. **Week's Top Stories** - 5-8 most important events, releases, and community developments this week, each with date -2. **CLI Tools Progress** - Overall activity and key changes for each AI CLI tool (Claude Code, Codex, Gemini CLI, etc.) -3. **AI Agent Ecosystem** - Key developments from OpenClaw and peer projects this week -4. **Open Source Trends** - Most notable technical directions from GitHub Trending and AI community this week -5. **HN Community Highlights** - Core AI discussion topics and community sentiment on Hacker News this week -6. **Official Announcements** - Important content published by Anthropic and OpenAI this week (if any) -7. **Next Week's Signals** - Based on this week's data, predict trends and upcoming events worth watching - -Style: English, concise and professional, helping technical developers quickly grasp the week's developments. -`; - } - - return `你是一位专注于 AI 开源生态的技术分析师。以下是过去 7 天(${weekStr})的 AI 工具社区每日动态摘要,请生成本周综合回顾报告。 - -${digestEntries} - ---- - -请生成《AI 工具生态周报》,包含以下部分: - -1. **本周要闻** - 5-8 条本周最重要的事件、版本发布、社区动向,每条附日期 -2. **CLI 工具进展** - 各 AI CLI 工具(Claude Code、Codex、Gemini CLI 等)本周整体动态与关键变化 -3. **AI Agent 生态** - OpenClaw 及同赛道项目的本周重要进展 -4. **开源趋势** - 本周 GitHub Trending 和 AI 社区最关注的技术方向 -5. **HN 社区热议** - 本周 Hacker News AI 讨论的核心话题与社区情绪 -6. **官方动态** - Anthropic 和 OpenAI 本周发布的重要内容(若有) -7. **下周信号** - 基于本周数据,预判值得关注的趋势或即将到来的事件 - -语言要求:中文,简洁专业,适合技术开发者快速掌握一周动态。 -`; -} - -export function buildMonthlyPrompt( - sourceDigests: Record, - monthStr: string, - lang: "zh" | "en" = "zh", -): string { - const digestEntries = Object.entries(sourceDigests) - .map(([key, content]) => `## ${key}\n\n${content}`) - .join("\n\n---\n\n"); - - if (lang === "en") { - return `You are a technical analyst focused on the AI open-source ecosystem. The following are ${monthStr} AI tool community digest summaries (${Object.keys(sourceDigests).length} reports total). Generate a comprehensive monthly review. - -${digestEntries} - ---- - -Generate an AI Tools Ecosystem Monthly Report with these sections: - -1. **Month's Top Stories** - 5-10 most important events and milestones this month, in chronological order -2. **CLI Tools Monthly Progress** - Overall development trajectory, major releases, and community growth for each key AI CLI tool -3. **AI Agent Ecosystem Monthly Review** - Ecosystem landscape shifts, emerging projects, notable signals this month -4. **Technical Trend Summary** - Most significant technical directions and paradigm shifts in AI open-source this month -5. **Community Health Assessment** - Monthly activity comparison across major projects, developer engagement evaluation -6. **Official Announcements Review** - Strategic analysis of Anthropic and OpenAI content published this month -7. **Next Month's Outlook** - Based on this month's trends, predict key directions and potential events to watch - -Style: English, in-depth analysis, data-driven, suited for monthly retrospectives and strategic decision-making. -`; - } - - return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${monthStr} 月的 AI 工具社区动态汇总(共 ${Object.keys(sourceDigests).length} 份报告),请生成本月综合回顾报告。 - -${digestEntries} - ---- - -请生成《AI 工具生态月报》,包含以下部分: - -1. **月度要闻** - 本月最重要的 5-10 条事件和里程碑,按时间排列 -2. **CLI 工具月度进展** - 各主要 AI CLI 工具本月整体发展轨迹、重要版本、社区规模变化 -3. **AI Agent 生态月报** - 本月生态格局变化、新兴项目、值得关注的信号 -4. **技术趋势总结** - 本月 AI 开源领域最显著的技术方向与范式变化 -5. **社区生态健康度** - 各主要项目月度活跃度对比、开发者参与度评估 -6. **官方动态回顾** - Anthropic 和 OpenAI 本月发布内容的战略意义分析 -7. **下月展望** - 基于本月趋势,预判值得重点关注的方向和潜在事件 - -语言要求:中文,深度分析,数据驱动,适合月度复盘和战略决策参考。 -`; -} - -export function buildHnPrompt(data: HnData, dateStr: string, lang: "zh" | "en" = "zh"): string { - const storiesText = data.stories - .map((s, i) => - lang === "en" - ? `${i + 1}. **${s.title}**\n` + - ` Link: ${s.url}\n` + - ` Discussion: ${s.hnUrl}\n` + - ` Score: ${s.points} | Comments: ${s.comments} | Author: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}` - : `${i + 1}. **${s.title}**\n` + - ` 链接: ${s.url}\n` + - ` 讨论: ${s.hnUrl}\n` + - ` 分数: ${s.points} | 评论: ${s.comments} | 作者: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}`, - ) - .join("\n\n"); - - if (lang === "en") { - return `You are an AI industry news analyst. The following are AI-related top posts from Hacker News in the past 24 hours as of ${dateStr} (sorted by score, ${data.stories.length} total): - ---- - -${storiesText} - ---- - -Generate a structured Hacker News AI Community Digest in English: - -1. **Today's Highlights** — 3-5 sentences on the hottest AI discussion topics and community sentiment on HN today - -2. **Top News & Discussions** — Organized by category, select the 2-5 most representative items per category, each with: - - Title (with original link) + HN discussion link - - Score and comment count - - One sentence: why this matters, what the community's typical reaction is - - Categories: - - 🔬 Models & Research (new model releases, papers, benchmarks) - - 🛠️ Tools & Engineering (open-source projects, frameworks, engineering practices) - - 🏢 Industry News (company news, funding, product launches) - - 💬 Opinions & Debates (notable Ask HN, Show HN, or hot discussion threads) - -3. **Community Sentiment Signal** — 100-200 words analyzing today's HN AI discussion mood and focus: - - Which topics are most active (high score + high comments)? - - Any clear points of controversy or consensus? - - Compared to last cycle, any notable shift in focus? - -4. **Worth Deep Reading** — List 2-3 pieces most worth developers/researchers reading in depth, with brief reasoning - -Style: English, concise and professional, preserve all original links. -`; - } - - return `你是 AI 行业资讯分析师。以下是 ${dateStr} 从 Hacker News 抓取的过去 24 小时内 AI 相关热门帖子(按分数降序,共 ${data.stories.length} 条): - ---- - -${storiesText} - ---- - -请生成一份结构清晰的《Hacker News AI 社区动态日报》,要求: - -1. **今日速览** — 3~5 句话,概括今日 HN 社区围绕 AI 最热门的讨论方向和情绪 - -2. **热门新闻与讨论** — 按以下分类整理,每类选取最具代表性的 2~5 条,每条包含: - - 标题(附原文链接)+ HN 讨论链接 - - 分数和评论数 - - 一句话说明:这条内容为什么值得关注,社区有何典型反应 - - 分类: - - 🔬 模型与研究(新模型发布、论文、基准测试) - - 🛠️ 工具与工程(开源项目、框架、工程实践) - - 🏢 产业动态(公司新闻、融资、产品发布) - - 💬 观点与争议(值得关注的 Ask HN、Show HN 或热议帖子) - -3. **社区情绪信号** — 100~200 字,分析今日 HN AI 讨论的整体情绪和关注重点: - - 社区对哪类话题最活跃(高分 + 高评论)? - - 有无明显的争议点或共识? - - 与上周期相比,关注方向有无明显变化? - -4. **值得深读** — 列出 2~3 条今日最值得开发者/研究者深入阅读的内容,简述理由 - -语言要求:中文,简洁专业,保留所有原文链接。 -`; -} +/** + * LLM prompt builders and item formatting. + */ + +import type { RepoConfig, GitHubItem, GitHubRelease } from "./github.ts"; +import type { WebFetchResult } from "./web.ts"; +import type { TrendingData } from "./trending.ts"; +import type { HnData } from "./hn.ts"; + +// --------------------------------------------------------------------------- +// Types +// --------------------------------------------------------------------------- + +export interface RepoDigest { + config: RepoConfig; + issues: GitHubItem[]; + prs: GitHubItem[]; + releases: GitHubRelease[]; + summary: string; +} + +// --------------------------------------------------------------------------- +// Formatting +// --------------------------------------------------------------------------- + +export function formatItem(item: GitHubItem, lang: "zh" | "en" = "zh"): string { + const labels = item.labels.map((l) => l.name).join(", "); + const labelStr = labels ? ` [${labels}]` : ""; + const body = (item.body ?? "").replace(/\n/g, " ").trim().slice(0, 300); + const ellipsis = (item.body ?? "").length > 300 ? "..." : ""; + const t = + lang === "en" + ? { + author: "Author", + created: "Created", + updated: "Updated", + comments: "Comments", + url: "URL", + summary: "Summary", + } + : { author: "作者", created: "创建", updated: "更新", comments: "评论", url: "链接", summary: "摘要" }; + return [ + `#${item.number} [${item.state.toUpperCase()}]${labelStr} ${item.title}`, + ` ${t.author}: @${item.user.login} | ${t.created}: ${item.created_at.slice(0, 10)} | ${t.updated}: ${item.updated_at.slice(0, 10)} | ${t.comments}: ${item.comments} | 👍: ${item.reactions?.["+1"] ?? 0}`, + ` ${t.url}: ${item.html_url}`, + ` ${t.summary}: ${body}${ellipsis}`, + ].join("\n"); +} + +// --------------------------------------------------------------------------- +// Sampling helpers (shared) +// --------------------------------------------------------------------------- + +const CLI_ISSUE_LIMIT = 30; +const CLI_PR_LIMIT = 20; + +/** Sort by comment count desc, take top N. */ +function topN(items: GitHubItem[], n: number): GitHubItem[] { + return [...items].sort((a, b) => b.comments - a.comments).slice(0, n); +} + +function sampleNote(total: number, sampled: number, lang: "zh" | "en" = "zh"): string { + if (lang === "en") { + return total > sampled + ? `(Total: ${total} items; showing top ${sampled} by comment count)` + : `(Total: ${total} items)`; + } + return total > sampled ? `(共 ${total} 条,以下展示评论数最多的 ${sampled} 条)` : `(共 ${total} 条)`; +} + +// --------------------------------------------------------------------------- +// Prompts +// --------------------------------------------------------------------------- + +export function buildCliPrompt( + cfg: RepoConfig, + issues: GitHubItem[], + prs: GitHubItem[], + releases: GitHubRelease[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const sampledIssues = topN(issues, CLI_ISSUE_LIMIT); + const sampledPrs = topN(prs, CLI_PR_LIMIT); + + const issuesText = + sampledIssues.map((i) => formatItem(i, lang)).join("\n") || (lang === "en" ? "None" : "无"); + const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || (lang === "en" ? "None" : "无"); + const releasesText = releases.length + ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") + : lang === "en" + ? "None" + : "无"; + + const issueNote = sampleNote(issues.length, sampledIssues.length, lang); + const prNote = sampleNote(prs.length, sampledPrs.length, lang); + + if (lang === "en") { + return `You are a technical analyst focused on AI developer tools. Based on the following GitHub data, generate the ${cfg.name} community digest for ${dateStr}. + +# Data source: github.com/${cfg.repo} + +## Latest Releases (last 24h) +${releasesText} + +## Latest Issues (updated in last 24h)${issueNote} +${issuesText} + +## Latest Pull Requests (updated in last 24h)${prNote} +${prsText} + +--- + +Generate a structured English digest with the following sections: + +1. **Today's Highlights** - 2-3 sentences summarizing the most important updates +2. **Releases** - If new versions exist, summarize changes; omit if none +3. **Hot Issues** - Pick 10 noteworthy Issues, explain why they matter and community reaction +4. **Key PR Progress** - Pick 10 important PRs, describe features or fixes +5. **Feature Request Trends** - Distill the most-requested feature directions from all Issues +6. **Developer Pain Points** - Summarize recurring developer frustrations or high-frequency requests + +Style: concise and professional, suited for technical developers. Include GitHub links for each item. +`; + } + + return `你是一位专注于 AI 开发工具的技术分析师。请根据以下 GitHub 数据,生成 ${dateStr} 的 ${cfg.name} 社区动态日报。 + +# 数据来源: github.com/${cfg.repo} + +## 最新 Releases(过去24小时) +${releasesText} + +## 最新 Issues(过去24小时内更新)${issueNote} +${issuesText} + +## 最新 Pull Requests(过去24小时内更新)${prNote} +${prsText} + +--- + +请生成一份结构清晰的中文日报,包含以下部分: + +1. **今日速览** - 用2-3句话概括今天最重要的动态 +2. **版本发布** - 如有新版本,总结更新内容;无则省略 +3. **社区热点 Issues** - 挑选 10 个最值得关注的 Issue,说明为什么重要、社区反应如何 +4. **重要 PR 进展** - 挑选 10 个重要的 PR,说明功能或修复内容 +5. **功能需求趋势** - 从所有 Issues 中提炼出社区最关注的功能方向(如 IDE 集成、性能、新模型支持等) +6. **开发者关注点** - 总结开发者反馈中的痛点或高频需求 + +语言要求:简洁专业,适合技术开发者阅读。每个条目附上 GitHub 链接。 +`; +} + +const PEER_ISSUE_LIMIT = 30; +const PEER_PR_LIMIT = 20; + +export function buildPeerPrompt( + cfg: RepoConfig, + issues: GitHubItem[], + prs: GitHubItem[], + releases: GitHubRelease[], + dateStr: string, + issueLimit = PEER_ISSUE_LIMIT, + prLimit = PEER_PR_LIMIT, + lang: "zh" | "en" = "zh", +): string { + const totalIssues = issues.length; + const totalPrs = prs.length; + + const sampledIssues = topN(issues, issueLimit); + const sampledPrs = topN(prs, prLimit); + + const noneStr = lang === "en" ? "None" : "无"; + const issuesText = sampledIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; + const prsText = sampledPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; + const releasesText = releases.length + ? releases.map((r) => `- ${r.tag_name}: ${r.name}\n ${(r.body ?? "").slice(0, 300)}`).join("\n") + : noneStr; + + const openIssues = issues.filter((i) => i.state === "open").length; + const closedIssues = issues.filter((i) => i.state === "closed").length; + const openPrs = prs.filter((p) => p.state === "open").length; + const mergedPrs = prs.filter((p) => p.state === "closed").length; + + const issueSampleNote = sampleNote(totalIssues, sampledIssues.length, lang); + const prSampleNote = sampleNote(totalPrs, sampledPrs.length, lang); + + if (lang === "en") { + return `You are an analyst of AI agent and personal AI assistant open-source projects. Based on the following GitHub data from ${cfg.name} (github.com/${cfg.repo}), generate a project digest for ${dateStr}. + +# Data Overview +- Issues updated in last 24h: ${totalIssues} (open/active: ${openIssues}, closed: ${closedIssues}) +- PRs updated in last 24h: ${totalPrs} (open: ${openPrs}, merged/closed: ${mergedPrs}) +- New releases: ${releases.length} + +## Latest Releases +${releasesText} + +## Latest Issues ${issueSampleNote} +${issuesText} + +## Latest Pull Requests ${prSampleNote} +${prsText} + +--- + +Generate a structured English ${cfg.name} project digest with the following sections: + +1. **Today's Overview** - 3-5 sentences summarizing project status, including activity assessment +2. **Releases** - If new versions exist, detail changes, breaking changes, migration notes; omit if none +3. **Project Progress** - Merged/closed PRs today, what features advanced or were fixed +4. **Community Hot Topics** - Most active Issues/PRs with most comments/reactions (with links), analyze underlying needs +5. **Bugs & Stability** - Bugs, crashes, regressions reported today, ranked by severity, note if fix PRs exist +6. **Feature Requests & Roadmap Signals** - User-requested features, predict which might be in next version +7. **User Feedback Summary** - Real user pain points, use cases, satisfaction/dissatisfaction +8. **Backlog Watch** - Long-unanswered important Issues or PRs needing maintainer attention + +Style: objective, data-driven, highlighting project health. Include GitHub links for each item. +`; + } + + return `你是一位 AI 智能体与个人 AI 助手领域开源项目分析师。请根据以下来自 ${cfg.name} (github.com/${cfg.repo}) 的 GitHub 数据,生成 ${dateStr} 的项目动态日报。 + +# 数据概览 +- 过去24小时 Issues 更新:${totalIssues} 条(新开/活跃: ${openIssues},已关闭: ${closedIssues}) +- 过去24小时 PR 更新:${totalPrs} 条(待合并: ${openPrs},已合并/关闭: ${mergedPrs}) +- 新版本发布:${releases.length} 个 + +## 最新 Releases +${releasesText} + +## 最新 Issues ${issueSampleNote} +${issuesText} + +## 最新 Pull Requests ${prSampleNote} +${prsText} + +--- + +请生成一份结构清晰的 ${cfg.name} 项目日报,包含以下部分: + +1. **今日速览** - 用3-5句话概括项目今日整体状态,包括活跃度评估 +2. **版本发布** - 如有新版本,详细说明更新内容、破坏性变更、迁移注意事项;无则省略 +3. **项目进展** - 今日合并/关闭的重要 PR,说明推进了哪些功能或修复,项目整体向前迈进了多少 +4. **社区热点** - 今日讨论最活跃、评论最多、反应最多的 Issues/PRs(附链接),分析背后的诉求 +5. **Bug 与稳定性** - 今日报告的 Bug、崩溃、回归问题,按严重程度排列,标注是否已有 fix PR +6. **功能请求与路线图信号** - 用户提出的新功能需求,结合已有 PR 判断哪些可能被纳入下一版本 +7. **用户反馈摘要** - 从 Issues 评论中提炼真实用户痛点、使用场景、满意/不满意的地方 +8. **待处理积压** - 长期未响应的重要 Issue 或 PR,提醒维护者关注 + +语言要求:客观专业,数据驱动,突出项目健康度。每个条目附上 GitHub 链接。 +`; +} + +export function buildPeersComparisonPrompt( + openclawDigest: RepoDigest, + peerDigests: RepoDigest[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; + + const openclawSection = + lang === "en" + ? `## OpenClaw (core reference, github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}` + : `## OpenClaw(核心参照,github.com/${openclawDigest.config.repo})\n${openclawDigest.summary}`; + + const peerSections = peerDigests + .map((d) => { + const hasData = d.issues.length || d.prs.length || d.releases.length; + if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; + return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; + }) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a senior analyst of the AI agent and personal AI assistant open-source ecosystem. The following are ${dateStr} community digest summaries for each project. + +${openclawSection} + +--- + +${peerSections} + +--- + +Generate a cross-project comparison report in English with these sections: + +1. **Ecosystem Overview** - 3-5 sentences on the overall personal AI assistant / agent open-source landscape +2. **Activity Comparison** - Table comparing Issues count, PR count, Release status, and health score for each project +3. **OpenClaw's Position** - Advantages vs peers, technical approach differences, community size comparison +4. **Shared Technical Focus Areas** - Requirements emerging across multiple projects (note which projects, specific needs) +5. **Differentiation Analysis** - Key differences in feature focus, target users, technical architecture +6. **Community Momentum & Maturity** - Activity tiers, which are rapidly iterating, which are stabilizing +7. **Trend Signals** - Industry trends extracted from community feedback, value for AI agent developers + +Style: concise and professional, data-backed, suited for technical decision-makers and developers. +`; + } + + return `你是一位专注于 AI 智能体与个人 AI 助手开源生态的资深技术分析师。以下是 ${dateStr} 各开源项目的社区动态摘要。 + +${openclawSection} + +--- + +${peerSections} + +--- + +请基于上述各项目的动态,生成一份横向对比分析报告,包含以下部分: + +1. **生态全景** - 用3-5句话概括个人 AI 助手/自主智能体开源生态整体态势 +2. **各项目活跃度对比** - 以表格形式汇总各项目今日的 Issues 数、PR 数、Release 情况及健康度评估 +3. **OpenClaw 在生态中的定位** - 与同类相比的优势、技术路线差异、社区规模对比 +4. **共同关注的技术方向** - 多项目共同涌现的需求(注明涉及哪些项目、具体诉求) +5. **差异化定位分析** - 功能侧重、目标用户、技术架构的关键差异 +6. **社区热度与成熟度** - 活跃度分层,哪些处于快速迭代阶段,哪些在质量巩固阶段 +7. **值得关注的趋势信号** - 从社区反馈中提炼行业趋势,对 AI 智能体开发者的参考价值 + +语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 +`; +} + +export function buildSkillsPrompt( + prs: GitHubItem[], + issues: GitHubItem[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const topPrs = topN(prs, 20); + const topIssues = topN(issues, 15); + + const noneStr = lang === "en" ? "None" : "无"; + const prsText = topPrs.map((p) => formatItem(p, lang)).join("\n") || noneStr; + const issuesText = topIssues.map((i) => formatItem(i, lang)).join("\n") || noneStr; + + if (lang === "en") { + return `You are a technical analyst focused on the Claude Code ecosystem. The following data is from github.com/anthropics/skills (official Claude Code Skills repository). Analyze the community's most-watched Skills activity (data as of ${dateStr}). + +## Repository Context +anthropics/skills is the official Claude Code Skills collection. Each PR typically represents a new or improved Skill. The community proposes new Skills and reports issues via Issues; PRs represent actual Skill submissions. + +## Popular Pull Requests (sorted by comments, ${prs.length} total, showing top ${topPrs.length}) +${prsText} + +## Community Issues (sorted by comments, ${issues.length} total, showing top ${topIssues.length}) +${issuesText} + +--- + +Generate a Claude Code Skills community highlights report in English with these sections: + +1. **Top Skills Ranking** - List the 5-8 most-discussed Skills (PRs) by comments/attention, describe each Skill's functionality, discussion highlights, and current status (open/merged/draft) +2. **Community Demand Trends** - From Issues, distill the most-anticipated new Skill directions (e.g. workflow automation, code review, test generation, documentation) +3. **High-Potential Pending Skills** - Active-comment PRs not yet merged; these Skills may land soon +4. **Skills Ecosystem Insight** - One-sentence summary: what is the community's most concentrated demand at the Skills level? + +Style: concise and professional, include GitHub links for each item. +`; + } + + return `你是一位专注于 Claude Code 生态的技术分析师。以下是来自 github.com/anthropics/skills(Claude Code Skills 官方仓库)的数据,请分析社区最关注的 Skills 动态(数据截止 ${dateStr})。 + +## 仓库说明 +anthropics/skills 是 Claude Code 官方 Skills 集合仓库,每个 PR 通常对应一个新增或改进的 Skill。社区通过 Issues 提出新 Skill 需求或反馈问题,PR 则代表实际提交的 Skill。 + +## 热门 Pull Requests(按评论数排序,共 ${prs.length} 条,展示前 ${topPrs.length} 条) +${prsText} + +## 社区 Issues(按评论数排序,共 ${issues.length} 条,展示前 ${topIssues.length} 条) +${issuesText} + +--- + +请生成一份 Claude Code Skills 社区热点报告,包含以下部分: + +1. **热门 Skills 排行** - 列出评论/关注度最高的 5~8 个 Skills(PR),说明每个 Skill 的功能、社区讨论热点及当前状态(open/merged/draft) +2. **社区需求趋势** - 从 Issues 中提炼社区最期待的新 Skill 方向(如工作流自动化、代码审查、测试生成、文档等) +3. **高潜力待合并 Skills** - 评论活跃但尚未合并的 PR,这些 Skills 可能近期落地 +4. **Skills 生态洞察** - 一句话总结:当前社区在 Skills 层面最集中的诉求是什么 + +语言要求:简洁专业,每个条目附上 GitHub 链接。 +`; +} + +export function buildComparisonPrompt( + digests: RepoDigest[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const noActivityStr = lang === "en" ? "No activity in the last 24 hours." : "过去24小时无活动。"; + + const sections = digests + .map((d) => { + const hasData = d.issues.length || d.prs.length || d.releases.length; + if (!hasData) return `## ${d.config.name} (github.com/${d.config.repo})\n${noActivityStr}`; + return `## ${d.config.name} (github.com/${d.config.repo})\n${d.summary}`; + }) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a senior technical analyst of the AI developer tools ecosystem. The following are ${dateStr} community digest summaries for each major AI CLI tool: + +${sections} + +--- + +Generate a cross-tool comparison report in English with these sections: + +1. **Ecosystem Overview** - 3-5 sentences on the overall AI CLI tools development landscape +2. **Activity Comparison** - Table comparing Issues count, PR count, Release status for each tool today +3. **Shared Feature Directions** - Requirements appearing across multiple tool communities (note which tools, specific needs) +4. **Differentiation Analysis** - Differences in feature focus, target users, and technical approach +5. **Community Momentum & Maturity** - Which tools have more active communities, which are rapidly iterating +6. **Trend Signals** - Industry trends from community feedback, reference value for developers + +Style: concise and professional, data-backed, suited for technical decision-makers and developers. +`; + } + + return `你是一位专注于 AI 开发工具生态的资深技术分析师。以下是 ${dateStr} 各主流 AI CLI 工具的社区动态摘要: + +${sections} + +--- + +请基于上述各工具的动态,生成一份横向对比分析报告,包含以下部分: + +1. **生态全景** - 用3-5句话概括当前 AI CLI 工具整体发展态势 +2. **各工具活跃度对比** - 以表格形式汇总各工具今日的 Issues 数、PR 数、Release 情况 +3. **共同关注的功能方向** - 多个工具社区都在关注的需求(说明哪些工具、具体诉求) +4. **差异化定位分析** - 各工具在功能侧重、目标用户、技术路线上的差异 +5. **社区热度与成熟度** - 哪些工具社区更活跃,哪些处于快速迭代阶段 +6. **值得关注的趋势信号** - 从社区反馈中提炼出的行业趋势,对开发者有何参考价值 + +语言要求:简洁专业,有数据支撑,适合技术决策者和开发者阅读。 +`; +} + +export function buildTrendingPrompt(data: TrendingData, dateStr: string, lang: "zh" | "en" = "zh"): string { + const trendingSection = + data.trendingFetchSuccess && data.trendingRepos.length > 0 + ? data.trendingRepos + .map( + (r) => + `- [${r.fullName}](${r.url})` + + (r.language ? ` [${r.language}]` : "") + + ` ⭐${r.totalStars.toLocaleString()}` + + (r.todayStars > 0 ? ` (+${r.todayStars} today)` : "") + + (r.forks > 0 ? ` 🍴${r.forks.toLocaleString()}` : "") + + (r.description ? `\n ${r.description}` : ""), + ) + .join("\n") + : lang === "en" + ? "(Unable to fetch today's GitHub Trending list)" + : "(未能抓取今日 GitHub Trending 榜单)"; + + const searchSection = + data.searchRepos.length > 0 + ? data.searchRepos + .map( + (r) => + `- [${r.fullName}](${r.url})` + + (r.language ? ` [${r.language}]` : "") + + ` ⭐${r.stargazersCount.toLocaleString()}` + + ` [topic:${r.searchQuery}]` + + (r.description ? `\n ${r.description}` : ""), + ) + .join("\n") + : lang === "en" + ? "(No search results)" + : "(无搜索结果)"; + + if (lang === "en") { + return `You are a technical analyst focused on the AI open-source ecosystem. The following is ${dateStr} GitHub AI-related trending repository data. Please filter for AI relevance, categorize, and analyze trends. + +## Data Sources +- **Trending List** (github.com/trending, today's stars most reliable): Real-time hot list with today's new stars +- **Topic Search** (GitHub Search API, topic tags): AI-related projects active in last 7 days, grouped by topic + +--- + +## GitHub Today's Trending (${data.trendingRepos.length} repositories) +${trendingSection} + +--- + +## AI Topic Search Results (${data.searchRepos.length} repositories, deduplicated) +${searchSection} + +--- + +Generate a structured AI Open Source Trends Report in English: + +**Step 1 (Filter)**: From the above data, select projects clearly related to AI/ML (exclude unrelated general tools, frontend frameworks, games, etc.). Skip non-AI trending repos. + +**Step 2 (Categorize)**: Group filtered projects into these categories (a project can belong to multiple; pick the primary one): +- 🔧 AI Infrastructure (frameworks, SDKs, inference engines, dev tools, CLI) +- 🤖 AI Agents / Workflows (agent frameworks, automation, multi-agent systems) +- 📦 AI Applications (specific apps, vertical solutions) +- 🧠 LLMs / Training (model weights, training frameworks, fine-tuning tools) +- 🔍 RAG / Knowledge (vector databases, retrieval-augmented generation, knowledge management) + +**Step 3 (Output Report)** with these sections: + +1. **Today's Highlights** — 3-5 sentences on the most noteworthy AI open-source developments today + +2. **Top Projects by Category** — For each category, list 3-8 representative projects, each with: + - Project name (with link) + - Stars data (total + today's new, if available) + - One sentence: what it is and why it's worth attention today + +3. **Trend Signal Analysis** — 200-300 words, distill from today's hot list: + - Which type of AI tool is getting explosive community attention? + - Any new tech stacks or directions appearing for the first time? + - Connection to recent LLM releases / industry events + +4. **Community Hot Spots** — Bullet list of 3-5 specific projects or directions worth developer focus, with brief reasoning + +Style: English, professional and concise, must include GitHub links for every project. +`; + } + + return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${dateStr} 的 GitHub AI 相关热门仓库数据,请进行 AI 相关性筛选、分类和趋势分析。 + +## 数据说明 +- **Trending 榜单**(github.com/trending,今日 stars 数最可信):今日实时热榜,含今日新增 stars +- **主题搜索**(GitHub Search API,topic 标签):7天内活跃的 AI 相关项目,按主题分类 + +--- + +## GitHub 今日 Trending 榜单(共 ${data.trendingRepos.length} 个仓库) +${trendingSection} + +--- + +## AI 主题搜索结果(共 ${data.searchRepos.length} 个仓库,已去重) +${searchSection} + +--- + +请生成一份结构清晰的《AI 开源趋势日报》,要求: + +**第一步(过滤)**:从以上数据中筛选出与 AI/ML 明确相关的项目(排除与 AI 无关的通用工具、前端框架、游戏等),对于 Trending 榜单中的非 AI 项目直接略去。 + +**第二步(分类)**:将筛选后的项目按以下维度分类(一个项目可归入多类,优先归入最主要类别): +- 🔧 AI 基础工具(框架、SDK、推理引擎、开发工具、CLI) +- 🤖 AI 智能体/工作流(Agent 框架、自动化、多智能体) +- 📦 AI 应用(具体应用产品、垂直场景解决方案) +- 🧠 大模型/训练(模型权重、训练框架、微调工具) +- 🔍 RAG/知识库(向量数据库、检索增强、知识管理) + +**第三步(输出报告)**,包含以下部分: + +1. **今日速览** — 3~5 句话概括今日 AI 开源领域最值得关注的动向 + +2. **各维度热门项目** — 每个维度列出 3~8 个代表项目,每项包含: + - 项目名(附链接) + - stars 数据(总量 + 今日新增,如有) + - 一句话说明:这个项目是什么,为什么今天值得关注 + +3. **趋势信号分析** — 200~300 字,从今日热榜中提炼: + - 哪类 AI 工具正在获得社区爆发性关注? + - 有无新兴技术栈或方向首次登榜? + - 与近期大模型发布/行业事件的关联 + +4. **社区关注热点** — 以 bullet 形式列出 3~5 个值得开发者重点关注的具体项目或方向,给出简短理由 + +语言要求:中文,专业简洁,每个项目必须附 GitHub 链接。 +`; +} + +export function buildWebReportPrompt( + results: WebFetchResult[], + dateStr: string, + lang: "zh" | "en" = "zh", +): string { + const isAnyFirstRun = results.some((r) => r.isFirstRun); + + const siteSections = results + .map(({ siteName, isFirstRun, newItems, totalDiscovered }) => { + const mode = + lang === "en" + ? isFirstRun + ? `First full crawl (sitemap total ${totalDiscovered} URLs, showing latest ${newItems.length} articles)` + : `Incremental update, ${newItems.length} new articles today` + : isFirstRun + ? `首次全量抓取(sitemap 共 ${totalDiscovered} 条 URL,以下为最新 ${newItems.length} 篇正文内容)` + : `今日增量更新,共 ${newItems.length} 篇新内容`; + + if (newItems.length === 0) return `## ${siteName}\n\n(${mode},暂无可供分析的内容。)`; + + const unableToExtract = lang === "en" ? "(Unable to extract text content)" : "(无法提取文本内容)"; + const itemsText = newItems + .map((item) => + [ + `### [${item.title || item.url}](${item.url})`, + `- 分类: ${item.category} | 发布/更新: ${item.lastmod.slice(0, 10) || "未知"}`, + `- 内容节选: ${item.content || unableToExtract}`, + ].join("\n"), + ) + .join("\n\n"); + + return `## ${siteName}(${mode})\n\n${itemsText}`; + }) + .join("\n\n---\n\n"); + + const firstRunNote = + lang === "en" + ? isAnyFirstRun + ? "This is the first full crawl. Please focus on the overall content landscape, historical context, and core themes of each site, rather than individual articles." + : "This is an incremental update. Please focus on today's new content and assess its strategic significance in context." + : isAnyFirstRun + ? "本次为首次全量抓取,请重点梳理各站点的内容格局、历史脉络与核心主题,而非仅关注单篇文章。" + : "本次为增量更新,请聚焦今日新增内容,并结合上下文判断其战略意义。"; + + if (lang === "en") { + return `You are a deep content analyst focused on AI, skilled at extracting strategic signals from official announcements, technical blogs, research papers, and product documentation. + +The following content was crawled on ${dateStr} from Anthropic (claude.com / anthropic.com) and OpenAI (openai.com). ${firstRunNote} + +${siteSections} + +--- + +Generate a detailed AI Official Content Tracking Report in English with these sections: + +1. **Today's Highlights** — 3-5 sentences on the most important new releases or developments, calling out key highlights + +2. **Anthropic / Claude Content Highlights** — Organize important content by category (news / research / engineering / learn, etc.): + - For each piece, 2-4 sentences extracting core insights, technical details, or business significance + - Note publication date and original link + - If first full crawl, trace important milestones chronologically + +3. **OpenAI Content Highlights** — Same structure, organized by research / release / company / safety categories + +4. **Strategic Signal Analysis** — Based on both companies' release cadence and content focus, analyze: + - Each company's recent technical priorities (model capabilities / safety / productization / ecosystem) + - Competitive dynamics: who is setting the agenda, who is following + - Potential impact on developers and enterprise users + +5. **Notable Details** — Extract hidden signals from titles, phrasing, and timing, e.g.: + - New terms or topics appearing for the first time + - Dense releases in a category (may signal a product milestone) + - Policy, compliance, and safety developments + +${isAnyFirstRun ? "6. **Content Landscape Overview** — First full crawl only: summarize the content category distribution for both companies and describe their content strategy style (academic-oriented vs product-oriented vs user stories, etc.)\n\n" : ""}Style: English, professional and detailed, suited for AI researchers, product managers, and technical decision-makers. Every item must include official links. +`; + } + + return `你是一位专注于 AI 领域的深度内容分析师,擅长从官方公告、技术博客、研究论文和产品文档中提炼战略信号。 + +以下是 ${dateStr} 从 Anthropic(claude.com / anthropic.com)和 OpenAI(openai.com)官网抓取的内容,${firstRunNote} + +${siteSections} + +--- + +请生成一份详实的《AI 官方内容追踪报告》,包含以下部分: + +1. **今日速览** — 3~5 句话概括最重要的新发布或动向,点出核心亮点 + +2. **Anthropic / Claude 内容精选** — 按分类(news / research / engineering / learn 等)逐条整理重要内容: + - 每篇用 2~4 句话提炼核心观点、技术细节或业务意义 + - 标注发布日期和原文链接 + - 如首次全量,按时间线梳理重要里程碑 + +3. **OpenAI 内容精选** — 同上,按 research / release / company / safety 等分类整理 + +4. **战略信号解读** — 基于两家公司的发布节奏和内容重点,分析: + - 各自近期的技术优先级(模型能力 / 安全 / 产品化 / 生态) + - 竞争态势:谁在引领议题,谁在跟进 + - 对开发者和企业用户的潜在影响 + +5. **值得关注的细节** — 从标题、措辞、发布时机中提取隐含信号,例如: + - 新兴词汇或话题的首次出现 + - 某类主题的密集发布(可能预示产品节点) + - 政策、合规、安全方面的动向 + +${isAnyFirstRun ? "6. **内容格局总览** — 首次全量独有:汇总两家公司各内容类别的数量分布,并说明各自的内容运营风格(学术导向 vs 产品导向 vs 用户故事等)\n\n" : ""}语言要求:中文,专业深入,内容详实,适合 AI 领域研究者、产品经理和技术决策者阅读。每个条目必须附上 GitHub/官网链接。 +`; +} + +export function buildWeeklyPrompt( + dailyDigests: Record, + weekStr: string, + lang: "zh" | "en" = "zh", +): string { + const digestEntries = Object.entries(dailyDigests) + .map(([date, content]) => `## ${date}\n\n${content}`) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a technical analyst focused on the AI open-source ecosystem. The following are daily digest summaries from the past 7 days (${weekStr}) of AI tool community activity. Generate a comprehensive weekly recap. + +${digestEntries} + +--- + +Generate an AI Tools Ecosystem Weekly Report with these sections: + +1. **Week's Top Stories** - 5-8 most important events, releases, and community developments this week, each with date +2. **CLI Tools Progress** - Overall activity and key changes for each AI CLI tool (Claude Code, Codex, Gemini CLI, etc.) +3. **AI Agent Ecosystem** - Key developments from OpenClaw and peer projects this week +4. **Open Source Trends** - Most notable technical directions from GitHub Trending and AI community this week +5. **HN Community Highlights** - Core AI discussion topics and community sentiment on Hacker News this week +6. **Official Announcements** - Important content published by Anthropic and OpenAI this week (if any) +7. **Next Week's Signals** - Based on this week's data, predict trends and upcoming events worth watching + +Style: English, concise and professional, helping technical developers quickly grasp the week's developments. +`; + } + + return `你是一位专注于 AI 开源生态的技术分析师。以下是过去 7 天(${weekStr})的 AI 工具社区每日动态摘要,请生成本周综合回顾报告。 + +${digestEntries} + +--- + +请生成《AI 工具生态周报》,包含以下部分: + +1. **本周要闻** - 5-8 条本周最重要的事件、版本发布、社区动向,每条附日期 +2. **CLI 工具进展** - 各 AI CLI 工具(Claude Code、Codex、Gemini CLI 等)本周整体动态与关键变化 +3. **AI Agent 生态** - OpenClaw 及同赛道项目的本周重要进展 +4. **开源趋势** - 本周 GitHub Trending 和 AI 社区最关注的技术方向 +5. **HN 社区热议** - 本周 Hacker News AI 讨论的核心话题与社区情绪 +6. **官方动态** - Anthropic 和 OpenAI 本周发布的重要内容(若有) +7. **下周信号** - 基于本周数据,预判值得关注的趋势或即将到来的事件 + +语言要求:中文,简洁专业,适合技术开发者快速掌握一周动态。 +`; +} + +export function buildMonthlyPrompt( + sourceDigests: Record, + monthStr: string, + lang: "zh" | "en" = "zh", +): string { + const digestEntries = Object.entries(sourceDigests) + .map(([key, content]) => `## ${key}\n\n${content}`) + .join("\n\n---\n\n"); + + if (lang === "en") { + return `You are a technical analyst focused on the AI open-source ecosystem. The following are ${monthStr} AI tool community digest summaries (${Object.keys(sourceDigests).length} reports total). Generate a comprehensive monthly review. + +${digestEntries} + +--- + +Generate an AI Tools Ecosystem Monthly Report with these sections: + +1. **Month's Top Stories** - 5-10 most important events and milestones this month, in chronological order +2. **CLI Tools Monthly Progress** - Overall development trajectory, major releases, and community growth for each key AI CLI tool +3. **AI Agent Ecosystem Monthly Review** - Ecosystem landscape shifts, emerging projects, notable signals this month +4. **Technical Trend Summary** - Most significant technical directions and paradigm shifts in AI open-source this month +5. **Community Health Assessment** - Monthly activity comparison across major projects, developer engagement evaluation +6. **Official Announcements Review** - Strategic analysis of Anthropic and OpenAI content published this month +7. **Next Month's Outlook** - Based on this month's trends, predict key directions and potential events to watch + +Style: English, in-depth analysis, data-driven, suited for monthly retrospectives and strategic decision-making. +`; + } + + return `你是一位专注于 AI 开源生态的技术分析师。以下是 ${monthStr} 月的 AI 工具社区动态汇总(共 ${Object.keys(sourceDigests).length} 份报告),请生成本月综合回顾报告。 + +${digestEntries} + +--- + +请生成《AI 工具生态月报》,包含以下部分: + +1. **月度要闻** - 本月最重要的 5-10 条事件和里程碑,按时间排列 +2. **CLI 工具月度进展** - 各主要 AI CLI 工具本月整体发展轨迹、重要版本、社区规模变化 +3. **AI Agent 生态月报** - 本月生态格局变化、新兴项目、值得关注的信号 +4. **技术趋势总结** - 本月 AI 开源领域最显著的技术方向与范式变化 +5. **社区生态健康度** - 各主要项目月度活跃度对比、开发者参与度评估 +6. **官方动态回顾** - Anthropic 和 OpenAI 本月发布内容的战略意义分析 +7. **下月展望** - 基于本月趋势,预判值得重点关注的方向和潜在事件 + +语言要求:中文,深度分析,数据驱动,适合月度复盘和战略决策参考。 +`; +} + +export function buildHnPrompt(data: HnData, dateStr: string, lang: "zh" | "en" = "zh"): string { + const storiesText = data.stories + .map((s, i) => + lang === "en" + ? `${i + 1}. **${s.title}**\n` + + ` Link: ${s.url}\n` + + ` Discussion: ${s.hnUrl}\n` + + ` Score: ${s.points} | Comments: ${s.comments} | Author: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}` + : `${i + 1}. **${s.title}**\n` + + ` 链接: ${s.url}\n` + + ` 讨论: ${s.hnUrl}\n` + + ` 分数: ${s.points} | 评论: ${s.comments} | 作者: @${s.author} | 时间: ${s.createdAt.slice(0, 16)}`, + ) + .join("\n\n"); + + if (lang === "en") { + return `You are an AI industry news analyst. The following are AI-related top posts from Hacker News in the past 24 hours as of ${dateStr} (sorted by score, ${data.stories.length} total): + +--- + +${storiesText} + +--- + +Generate a structured Hacker News AI Community Digest in English: + +1. **Today's Highlights** — 3-5 sentences on the hottest AI discussion topics and community sentiment on HN today + +2. **Top News & Discussions** — Organized by category, select the 2-5 most representative items per category, each with: + - Title (with original link) + HN discussion link + - Score and comment count + - One sentence: why this matters, what the community's typical reaction is + + Categories: + - 🔬 Models & Research (new model releases, papers, benchmarks) + - 🛠️ Tools & Engineering (open-source projects, frameworks, engineering practices) + - 🏢 Industry News (company news, funding, product launches) + - 💬 Opinions & Debates (notable Ask HN, Show HN, or hot discussion threads) + +3. **Community Sentiment Signal** — 100-200 words analyzing today's HN AI discussion mood and focus: + - Which topics are most active (high score + high comments)? + - Any clear points of controversy or consensus? + - Compared to last cycle, any notable shift in focus? + +4. **Worth Deep Reading** — List 2-3 pieces most worth developers/researchers reading in depth, with brief reasoning + +Style: English, concise and professional, preserve all original links. +`; + } + + return `你是 AI 行业资讯分析师。以下是 ${dateStr} 从 Hacker News 抓取的过去 24 小时内 AI 相关热门帖子(按分数降序,共 ${data.stories.length} 条): + +--- + +${storiesText} + +--- + +请生成一份结构清晰的《Hacker News AI 社区动态日报》,要求: + +1. **今日速览** — 3~5 句话,概括今日 HN 社区围绕 AI 最热门的讨论方向和情绪 + +2. **热门新闻与讨论** — 按以下分类整理,每类选取最具代表性的 2~5 条,每条包含: + - 标题(附原文链接)+ HN 讨论链接 + - 分数和评论数 + - 一句话说明:这条内容为什么值得关注,社区有何典型反应 + + 分类: + - 🔬 模型与研究(新模型发布、论文、基准测试) + - 🛠️ 工具与工程(开源项目、框架、工程实践) + - 🏢 产业动态(公司新闻、融资、产品发布) + - 💬 观点与争议(值得关注的 Ask HN、Show HN 或热议帖子) + +3. **社区情绪信号** — 100~200 字,分析今日 HN AI 讨论的整体情绪和关注重点: + - 社区对哪类话题最活跃(高分 + 高评论)? + - 有无明显的争议点或共识? + - 与上周期相比,关注方向有无明显变化? + +4. **值得深读** — 列出 2~3 条今日最值得开发者/研究者深入阅读的内容,简述理由 + +语言要求:中文,简洁专业,保留所有原文链接。 +`; +} From af4aac6fb3f7e66a4b00e594d8c931975da6d643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=BE=99?= <76432572+nankingjing@users.noreply.github.com> Date: Tue, 14 Jul 2026 09:31:18 +0800 Subject: [PATCH 4/4] fix(prompts): avoid extra space before Chinese section parentheses --- src/prompts.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/prompts.ts b/src/prompts.ts index a5e303a..774a180 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -590,20 +590,34 @@ export function buildWebReportPrompt( ? `首次全量抓取(sitemap 共 ${totalDiscovered} 条 URL,以下为最新 ${newItems.length} 篇正文内容)` : `今日增量更新,共 ${newItems.length} 篇新内容`; - if (newItems.length === 0) return `## ${siteName}\n\n(${mode},暂无可供分析的内容。)`; + if (newItems.length === 0) { + const emptyMsg = + lang === "en" + ? `(${mode}, no content available for analysis.)` + : `(${mode},暂无可供分析的内容。)`; + return `## ${siteName}\n\n${emptyMsg}`; + } const unableToExtract = lang === "en" ? "(Unable to extract text content)" : "(无法提取文本内容)"; + const itemLabels = + lang === "en" + ? { category: "Category", published: "Published/Updated", unknown: "Unknown", excerpt: "Excerpt" } + : { category: "分类", published: "发布/更新", unknown: "未知", excerpt: "内容节选" }; const itemsText = newItems .map((item) => [ `### [${item.title || item.url}](${item.url})`, - `- 分类: ${item.category} | 发布/更新: ${item.lastmod.slice(0, 10) || "未知"}`, - `- 内容节选: ${item.content || unableToExtract}`, + `- ${itemLabels.category}: ${item.category} | ${itemLabels.published}: ${item.lastmod.slice(0, 10) || itemLabels.unknown}`, + `- ${itemLabels.excerpt}: ${item.content || unableToExtract}`, ].join("\n"), ) .join("\n\n"); - return `## ${siteName}(${mode})\n\n${itemsText}`; + const sectionParen = + lang === "en" + ? ` (${mode})` + : `(${mode})`; + return `## ${siteName}${sectionParen}\n\n${itemsText}`; }) .join("\n\n---\n\n");