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

openai-inbox

v0.1.1

Published

Multi-source message inbox powered by opencli (Hacker News / Reddit / 知乎).

Readme

📬 open-inbox

基于 opencli 的多源消息收件箱。Node 后端 spawn opencli 子进程拉取数据,前端左源右消息布局,手动刷新获取最新。

当前接入:

  • Hacker News (top / new / best / ask / show / jobs) — 免登录,公开 API
  • Reddit (hot / popular / frontpage) — 免登录,首次会启动 Chromium
  • 知乎 (热榜 / 推荐) — ⚠️ 当前返回空,见下文「已知问题」

一、首次准备(只做一次)

1. 装 opencli

npm install -g opencli
opencli --version   # 应输出 1.8.3 或更高

2. 装项目依赖

cd ~\Desktop\opencli-inbox
npm install

Reddit 走浏览器自动化,首次调用会拉起 Chromium,后续会复用 session。HN 直接走公开 API,不需要浏览器。


二、启动 / 停止

前台启动(开发常用,关终端即停)

cd ~\Desktop\opencli-inbox
npm start

看到 📬 Inbox running at http://localhost:3000 就说明起来了,浏览器打开该地址。停止:终端按 Ctrl + C

后台启动(关终端不退,日志写文件)

:: 启动(默认端口 3000)
npm run start:bg

:: 查看日志
npm run logs
:: 或:type logs\server.log

:: 停止
npm run stop:bg

也可以直接调脚本:scripts\start-bg.cmd / scripts\stop-bg.cmd(推荐 cmd / PowerShell 调用,Git Bash 可用 cmd //c scripts/start-bg.cmd)。

工作机制:

  • start-bg.cmdstart /bnode server.js detach 到后台,日志输出到 logs\server.log,PID 写进 .server.pid
  • stop-bg.cmd 优先用 .server.pid 杀;找不到再回退到「占用 PORT 的进程」

自定义端口

:: 前台
set PORT=4000 && npm start

:: 后台
set PORT=4000 && npm run start:bg
set PORT=4000 && npm run stop:bg    :: 停止时端口要保持一致

三、知乎需要登录

知乎热榜/推荐都要求登录,首次进入「知乎」tab 通常会看到 0 条 · 该源暂无数据

操作步骤:

  1. 点空数据态下的 「打开 知乎 登录页」 按钮
  2. opencli 会唤起浏览器(前台可见)并跳到知乎登录页 — 这是 opencli 自身的登录机制,不是另起一个浏览器
  3. 在浏览器完成登录(扫码 / 密码均可)
  4. 登录成功后关闭那个浏览器标签,回到 inbox 点 ↻ 刷新

opencli 用 --site-session persistent 保留 cookies,后续 npm start 不需要重新登录,除非 cookies 过期。

如果一直拿不到数据,排查:

opencli zhihu hot -f json --window foreground   # 直接跑一次,看浏览器里发生了什么
opencli profile list                             # 看 session 状态

四、使用

  • 左侧点 Hacker NewsReddit 切换源
  • 顶部下拉切换 feed (top / hot / …)
  • ↻ 刷新 重新拉数据(每次刷新都会重新 spawn opencli)
  • 状态栏显示「条数 · 时间 · 耗时」

五、常见问题

启动报 EADDRINUSE: address already in use :::3000

端口被占,可能上一个服务没关。两种解法:

# A. 换端口
PORT=4000 npm start

# B. 杀掉占用端口的进程 (Windows)
netstat -ano | findstr :3000
taskkill /PID <上一步看到的PID> /F

刷新时弹出 Connect Timeout Error

opencli 调用外部 API 偶发网络抖动,再点一次刷新通常就好。HN 的源在 hacker-news.firebaseio.com,Reddit 走的是真实浏览器,都需要能访问外网。

Reddit 第一次特别慢 / 卡住

首次会自动下载并启动 Chromium,可能要 30 秒以上。后续会快很多。如果一直卡:

opencli reddit hot -f json     # 单独跑一次,看真实报错
opencli doctor                 # 检查浏览器桥连接

想加新数据源

  1. sources/ 下新建 xxx.js,实现:
    export default {
      id: 'xxx',
      label: '显示名',
      icon: 'X',
      feeds: [{ value: 'hot', label: 'Hot' }],
      defaultFeed: 'hot',
      async fetch(feed) {
        const out = await runOpencli(['xxx', feed, '-f', 'json']);
        return extractJson(out).map(it => ({
          id: String(it.id), title: it.title, url: it.url,
          score: it.score, comments: it.comments, author: it.author,
        }));
      },
    };
  2. sources/index.js import 并放进 sources 数组,完工。

先用 opencli <name> --help 确认该 adapter 的命令名和是否支持 -f json


六、目录结构

open-inbox/
├── server.js                # Express 路由
├── package.json
├── sources/
│   ├── _runner.js           # spawn opencli + 容错 JSON 解析
│   ├── index.js             # 源注册表
│   ├── hackernews.js        # HN adapter
│   └── reddit.js            # Reddit adapter
└── public/
    └── index.html           # 前端单页

API:

  • GET /api/sources — 列出所有源(含 supportsLogin 标记)
  • GET /api/sources/:id/messages?feed=<feed> — 拉某源某 feed 的消息
  • POST /api/sources/:id/login — 触发该源的登录流程(目前只有知乎实现)