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

@dongfangw/study-kit

v0.3.3

Published

AI 学伴:把任意「带清单的内容库」变成可读、可搜、可标注、可问的学习台;支持多库与私人库隔离

Readme

@dongfangw/study-kit · AI 学伴

把任意"带清单的内容库"变成一个可读、可搜、可标注、可问的学习台。可同时挂多个库: 自己的课程、自学的另一门课、私人笔记,互不干扰。

你的阅读位置、标注、提问和 AI 对话都只存在这台电脑上。 没有账号、没有云同步、没有遥测。

安装(计划)

dsh plugin install @dongfangw/study-kit

能力

  • 书籍版式读 adoc / md,公式走 KaTeX;超长文档自动分段
  • PDF 阅读器:浏览器的 pdf.js 渲染(矢量清晰、可缩放、可翻页),选中文字即可取色标记 / 画重点线 / 写批注 / 问 AI——与 md/adoc 共用同一套标注面板与「带着这段问 AI」
  • 荧光笔 / 重点线 / 便签提问(标注只落本机)
  • 阅读位置记住(文档按段,PDF 按页 + 页内比例)
  • 「我的库」:加库向导、库隔离(visibility: private 三出口全隐)、每库 Git 状态
  • 5 个工具:kb_libraries / kb_catalog / kb_read / kb_search / kb_index
  • 6 个技能:学习导航、学习路径、概念答疑、物理直觉、建库向导、思维导图

检索索引(学生不用管,但值得知道)

打开「学习资料」时,宿主会在后台(worker 线程,不卡界面)把工作区的分块索引建到 <工作区>/.kb-index/kb-index.json;正文改过之后会自动重建(判据:有文件比 generatedAt 新, 或文件数变了)。有索引时 kb_search 返回「命中 N 块」(节标题 + 行范围 + 命中词), 否则退回全文扫的「命中 N 处」。学生说「刚记的笔记搜不到」时模型可调 kb_index 立即重建。

两件让检索更准的小事:每篇正文第一行写标题(= 标题 / # 标题,索引拿它当节名); 要精确命中的词写进 :kb-keywords: 词1;词2(清单里配 keywords: { field: kb-keywords })。

PDF 怎么用

  1. 在库的 library.yaml 里把 pdf 加进某个分组的 exts(例:exts: [md, pdf]), 目录树里就会出现 PDF 节点(徽章 PDF)。
  2. 点开即读:默认适宽;顶栏有页码跳转、上一页/下一页、缩小/适宽/放大(Ctrl + 滚轮也行)。
  3. 选中一段文字 → 工具条浮出:四种荧光色 / 重点线 / 写想法 / 问 AI。 标记按「第几页 + 页内文字偏移」存,换缩放、换窗口宽度后仍贴在同一段话上。
  4. 右下角「✍ N」打开标记面板:按页列出、可定位、删除、复制全部(Markdown)、清空。

实现要点(改这块之前先读,否则很容易踩回去):

| 组件 | 职责 | |---|---| | 宿主 src/pdf.ts | /kb/pdf 送 PDF 字节(Range 感知,pdf.js 靠它分块拉大文件);/kb/pdfjs/* 按白名单伺服 pdf.js 运行时(含 cmaps/ 与 standard_fonts/,中文 PDF 缺 cmaps 会抽不出文字);loader.js 带版本号 | | 客户端 pdfjs.ts | 注入宿主 loader、等 window.__aeroPdfjs;pdf.js 不进客户端 bundle(主库 350KB + worker 1.4MB,且 worker 必须是独立文件) | | 客户端 PdfViewer.tsx | 逐页 canvas + 文字层(只渲视口附近两屏的页)、缩放/翻页/位置记忆、选区 → 页内锚点 | | 客户端 pdfAnno.ts | 页内文字索引、选区 → 偏移锚点、标注 → 色块矩形(空白归一后按原文兜底找回) | | 客户端 annotations.ts | 标注库(aero.anno.v1):PDF 用 paintPageTextAnnotation,键是 pdf:<relPath> |

  • 色块画在 canvas 与文字层之间,且 pointer-events: none:文字层在最上面, 所以拖选永远不被色块拦住;点色块靠矩形反查(hitTestAnnotations)。
  • 文字层正在重建时(缩放/重新进视口)代码块会先摘掉,避免旧色块挂在新排版上。
  • 只有 md/adoc 走 /kb/doc;.pdf 走 /kb/pdf——把二进制喂给 markdown 渲染器只会得到乱码。

安装体积:pdfjs-dist 带来约 36MB(含 .map 与 legacy 构建),另有它的可选依赖 @napi-rs/canvas 约 36MB(只有 Node 端渲染才用,浏览器里用不到)。想省掉后者: npm install --omit=optional,或装完后删掉 <profile>/node_modules/@napi-rs。

已知限制:扫描件(没有文字层)里选不中文字,因此只能翻看、不能取色标注——页面上会显示 「第 N 页」占位;PDF 也不进 kb_search(全文检索只认 md/adoc)。

门禁与自测

npm test          # 含 PDF 路由的行为约定(字节/Range/白名单/教师端分组)
npm run audit     # 套件铁律(零课程专名、路由、技能完整性)
npm run probe:pdf # 真实浏览器实测:真 bundle + 真路由 + 真 PDF,断言渲染/选中/标注/缩放

probe:pdf(scripts/pdf-harness.mjs)需要工作区根装有 puppeteer-core 与本机 Chrome/Edge; 它把「学习资料」组件按 DSH 槽位约定挂到一个空白页里跑,截图落在 tmp/pdf-harness/。

状态

施工中(阶段 2)。本仓从 student-pack 的阅读器部分拆出并去课程化。

许可

MIT。