npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@beaverslab/rss-digest

v0.5.0

Published

Reusable RSS digest CLI orchestration and digest engine.

Readme

@beaverslab/rss-digest

一个可复用的 RSS Digest 包,提供:

  • CLI 编排
  • RSS 抓取与摘要生成
  • Prompt 组装
  • 多 LLM 回退

这个包是刻意从 skill 层拆出来的。现在它同时提供:

  • 可直接通过 bunx @beaverslab/rss-digest 调用的 CLI
  • 可复用的模块接口

而像 skills/beaver-rss-digest 这样的 skill 主要负责:

  • 用户配置路径
  • 模板目录选择
  • skill 特定文档与 prompt

作用范围

@beaverslab/rss-digest 既可以作为可复用包嵌入,也可以作为一个需要显式传入路径参数的 CLI 使用。它不是零配置应用,但已经不再依赖 skill 侧的 package.json 包装。

当前 LLM 行为:

  • openai-compatible 模型通过 @ai-sdk/openai-compatible 使用 Vercel AI SDK
  • anthropic-compatible 模型使用包内置 adapter
  • 启用的 provider 会按配置顺序依次尝试,直到有一个成功

Exports

当前包导出:

  • @beaverslab/rss-digest
  • @beaverslab/rss-digest/cli
  • @beaverslab/rss-digest/file-config
  • @beaverslab/rss-digest/digest-core
  • @beaverslab/rss-digest/prompts
  • @beaverslab/rss-digest/config-types

对应文件:

  • ./src/bin.ts
  • ./src/cli.ts
  • ./src/file-config.ts
  • ./src/digest-core.ts
  • ./src/prompts.ts
  • ./src/types.ts

Standalone CLI

包现在暴露可执行命令:

  • rss-digest

适合在只复制 skill 目录时直接运行:

bunx @beaverslab/rss-digest init \
  --config ~/.beaver-skill/beaver-rss-digest/config.yaml \
  --i18n ~/.beaver-skill/beaver-rss-digest/i18n.yaml \
  --templates-dir ./templates

bunx @beaverslab/rss-digest run \
  --config ~/.beaver-skill/beaver-rss-digest/config.yaml \
  --i18n ~/.beaver-skill/beaver-rss-digest/i18n.yaml \
  --templates-dir ./templates

bunx @beaverslab/rss-digest run \
  --config ~/.beaver-skill/beaver-rss-digest/config.yaml \
  --i18n ~/.beaver-skill/beaver-rss-digest/i18n.yaml \
  --templates-dir ./templates \
  --stdout

推荐优先使用 bunx。发布包会预编译到 dist/,因此 npx 也可以直接使用 Node 运行,不需要 tsx

CLI 内置默认资源:

  • config.example.yaml
  • i18n.yaml

可选全局参数:

  • --config
  • --i18n
  • --config-example
  • --repo-i18n
  • --templates-dir

运行命令额外支持:

  • --stdout: 将最终生成的报告输出到标准输出,而不是写入文件

主要接口

runCli(args, deps)

源码: cli.ts

用途: 提供一个通用 CLI 外壳,用于配置初始化、配置校验、RSS 源管理和 digest 执行。

所有环境相关行为都通过 DigestCliDeps 注入。

核心接口:

export interface DigestCliDeps<TConfig extends DigestConfigShape = DigestConfigShape> {
  configPath: string;
  defaultLlmApiKeyEnv: string;
  loadConfig: () => Promise<TConfig>;
  initConfig: (force?: boolean) => Promise<{ created: boolean; path: string }>;
  loadI18n: () => Promise<Record<OutputLanguage, Record<string, string>>>;
  saveConfig: (config: TConfig) => Promise<void>;
  validateConfig: (config: TConfig) => Promise<ValidationResult>;
  resolveConfiguredLlmApiKeyEnv: (config: TConfig) => string;
  resolveConfiguredLlmApiKey: (config: TConfig) => string;
  runDigest: (options: {
    feeds: FeedSource[];
    prompts: TConfig['prompts'];
    hours: number;
    topN: number;
    language: OutputLanguage;
    outputPath: string;
    llms: TConfig['llms'];
    llmApiKey: string;
    categories: TConfig['categories'];
    reportTemplate: string;
    i18n: Record<string, string>;
  }) => Promise<DigestRunResult>;
}

典型用法:

  • 包使用方负责配置加载和持久化
  • 包使用方决定配置文件存放位置
  • 包使用方决定如何解析 llmApiKeyEnv

runDigest(options)

源码: digest-core.ts

用途: 执行完整 digest 流程:

  1. 抓取 RSS
  2. 过滤最近文章
  3. 用 LLM 对文章打分
  4. 摘要 Top 文章
  5. 生成 highlights
  6. 用模板渲染 Markdown 输出

核心接口:

export interface RunDigestOptions {
  feeds: FeedSource[];
  prompts: PromptTemplates;
  hours: number;
  topN: number;
  language: OutputLanguage;
  outputPath: string;
  llms: LlmProfile[];
  llmApiKey: string;
  categories: CategoryConfig[];
  i18n?: Record<string, string>;
  reportTemplate: string;
  templatesDir: string;
}

Prompt 构造函数

源码: prompts.ts

导出:

  • buildScoringPrompt
  • buildSummaryPrompt
  • buildHighlightsPrompt

如果你想自己编排流程,但仍然复用本包的 prompt 组装逻辑,可以直接使用这些函数。

核心类型

源码: types.ts

重要导出类型:

  • DigestConfigShape
  • DigestDefaults
  • LlmProfile
  • FeedSource
  • CategoryConfig
  • PromptTemplates
  • Article
  • ScoredArticle
  • OutputLanguage

最小接入模式

推荐模式:

  1. 定义你自己的配置模块
  2. 让你的配置类型兼容 DigestConfigShape
  3. 把配置函数接入 runCli
  4. 在注入的 runDigest 依赖中调用包里的 runDigest

示例:

import process from 'node:process';
import { runCli } from '@beaverslab/rss-digest/cli';
import { runDigest } from '@beaverslab/rss-digest/digest-core';

await runCli(process.argv.slice(2), {
  configPath: '/path/to/config.yaml',
  defaultLlmApiKeyEnv: 'LLM_API_KEY',
  initConfig,
  loadConfig,
  loadI18n,
  saveConfig,
  validateConfig,
  resolveConfiguredLlmApiKeyEnv,
  resolveConfiguredLlmApiKey,
  runDigest: (options) =>
    runDigest({
      ...options,
      templatesDir: '/path/to/templates',
    }),
});

如果你仍然想嵌入自己的适配层,也可以继续直接调用 runLocalDigestClirunCli

包期望的配置结构

包级 CLI 假定配置对象兼容以下结构:

export interface DigestConfigShape {
  version: number;
  llmApiKeyEnv: string;
  defaults: {
    hours: number;
    topN: number;
    language: 'zh' | 'en';
    outputDir?: string;
    reportTemplate: string;
  };
  llms: LlmProfile[];
  categories: CategoryConfig[];
  prompts: PromptTemplates;
  rssFeeds: FeedSource[];
}

这个包不规定:

  • 配置存储在哪里
  • 配置是 YAML、JSON、数据库还是运行时生成
  • 环境变量如何被加载进 process.env

defaults.outputDir 是可选的。未配置时,CLI run 默认将最终报告输出到 stdout;配置后则默认写入该目录,除非显式传入 --stdout

LLM Provider 模型

这个包在一次运行中只使用一个已经解析好的 API key 字符串:

  • 调用方负责解析环境变量名
  • 调用方负责读取环境变量值
  • 调用方把 llmApiKey 传给 runDigest

这样可以把 provider 解析策略留在 package CLI 核心之外。

Provider 行为:

  • openai-compatible: 使用 Vercel AI SDK
  • anthropic-compatible: 使用内部 fetch adapter

这样 skill 层可以保持决策逻辑简单,同时复用统一执行引擎。

哪些内容应该留在 Skill 层

这些内容仍然更适合放在 package 外:

  • 类似 ~/.beaver-skill/... 的用户目录路径
  • skill frontmatter 和用户触发文档
  • 模板目录归属

这也是为什么 skills/beaver-rss-digest 仍然保留:

  • templates/

当前文件布局

Package 文件:

备注

  • 当前包直接导出源码文件。
  • 假定运行时为 Node.js 20+。
  • 这个包现在既适合嵌入,也适合通过 bunxnpx 直接调用。