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

@zhushanwen/session-core

v0.11.0

Published

Canonical session model and pure JSONL primitives shared by session readers and importers: Entry/ParseResult/SessionHeader/NormalizedSession, parse/serialize, first-line byte primitive, session id invariants. Zero runtime dependencies.

Readme

@zhushanwen/session-core

Coding-agent session 的 canonical 模型与纯 JSONL 原语基座。零运行时依赖(import 图不可达任何驱动/外部包),可被 node 侧 tsup 与 extension 侧 esbuild 安全内联,可独立 npm 发布。

包定位

「把某个 coding-agent 的 session 读成统一结构」的唯一落点:session-reader(pi 会话读取)、runtime 导入、未来的 coding-agent source 包共用本基座,取代各自为政的字节层副本(首行读取、entry 解析、id 归一化)。

导出面

| 导出 | 说明 | |------|------| | Entry / ParseResult / SessionHeader / NormalizedSession | canonical 模型(D1):严格 Entry 树,坏行丢弃不占位 | | parseSessionContent(content) | JSONL 文本 → ParseResult(坏行计 skippedLines,末行半行记 lastLinePartial) | | parseSessionFile(path) | parseSessionContent 的 async 文件版(ENOENT 等按 fs 原生错误抛出) | | serializeSession(entries) | Entry[] → JSONL,与 pi 产物逐字节兼容(JSON.stringify(entry) + '\n') | | readFirstJsonlLine(path) / readFirstJsonlLineSync(path) | 首行字节原语(async/sync 双形态):只读首行、处理 CRLF/LF、跨块多字节安全;空文件/纯空白 → undefined;IO 错误上抛由消费方分流 | | sessionIdFromFileName(fileName) | 文件名不变量:剥 .jsonl 后最后一个 _ 之后的尾段;提取不出 → undefined | | normalizeZcodeRowId(rowId) | zcode 行 id → 8 位零填充小写十六进制(canonical entry id 域) |

显式不进基座

  • header 合法性谓词:reader 仅要求 id、runtime 要求 id+cwd 非空——语义差异是不可统一的行为契约,各消费侧保留薄包装(≤5 行,共享本基座的 readFirstJsonlLine)。
  • 形式化 source SPI:source 契约 = 「产出 NormalizedSession」的约定,形式接口在第二个 source 落地时才抽取。