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

@prettier-ai/dsh-session-format

v0.1.3-alpha.1

Published

Pure adjacent whole-artifact Session format migration machinery

Readme


description: "纯函数式相邻 Session 格式规划、无损 JSON 快照、仅标头迁移与物理编解码分派。" kind: "package-library"

@deepseek-ai/dsh-session-format

English | 中文

概述

dsh-session-format 让持久化代码可以直接还原当前 Session,或组合唯一的相邻全产物迁移序列。它会把每个持久化输入和输出快照为分离的无损 JSON,校验精确的版本推进,并把仅标头的列表读取与正文读取分开。物理分帧、压缩、不可变 generation 命名、排他发布和 Cordis 生命周期行为不属于这个纯函数库。

目录


使用本包

何时使用

当持久化或格式目录代码需要分类物理 Session header、还原当前逻辑值或组合已发布相邻迁移时,使用本库。它不是 Cordis 插件,也没有 profile 挂载行。它不发布运行时不变式伴生入口,因为每个操作都会在返回前校验借入的完整 artifact,且不保留跨调用的可变状态。

入口

const catalog = createSessionFormatCatalog({ currentVersion, codecs, encodeCurrentArtifact, migrations, restoreCurrent, restoreCurrentHeader })
const descriptor = catalog.readHeader(physicalHeader)

createSessionFormatCatalog() 接收每个受支持版本的一个冻结解码器、当前格式的编码器、每组相邻版本的一个迁移,以及当前产物与标头还原器。readHeader() 在不读取事件的情况下返回 current、migration-required、unsupported 或 malformed 描述符。每个迁移边会先校验自己的目标标头,然后再运行最终的当前标头还原器。正文读取方调用 decodeArtifact() 或 decodeRecoverableArtifact(),然后调用 migrate();写入方只使用经过校验的当前产物调用 encodeCurrent()。冻结的 v0/v1 编解码器导出会保留其格式专用的 packChunks 选项,但不会把这项历史控制加入当前 writer 或通用解码器接口。

可恢复解码器返回已接受的逻辑前缀。编解码器可以丢弃一个格式错误或序号不连续的行及其未提交后缀,但后续成功解码的 turn/end 会使原始问题成为致命错误。


理解实现

迁移链在构造时校验唯一且无缺口的顺序。当前产物绕过所有迁移回调,只经过当前格式还原器。旧产物在内存中依次运行每个相邻的全产物函数;只有调用方决定是否发布最终结果以及如何发布。

| 文件 | 职责 | |---|---| | src/chain.ts | 相邻计划构造与当前格式绕过 | | src/catalog.ts | 物理版本分派与标头分类 | | src/json.ts | 分离的无损 JSON 快照与通用坐标校验 | | src/filename.ts | 持久化、导出与 fixture 共用的规范 session[.vN].jsonl 文件名 |


进一步探索


模型体验

Session 还原

模型看到什么

没有直接内容。消费方通过 deriveMessages() 从经过校验的当前产物重建模型历史。

Token 影响

不直接产生 token。

KV Cache 影响

没有直接影响。迁移若改变当前历史,可能改变由请求重建逻辑拥有的缓存身份。

已知限制与延期工作

  • 全产物内存占用——受支持的迁移会物化完整逻辑 Session;只有实测产物规模提出要求时,才会引入流式转换。
  • 仅支持相邻整数版本——本库不暴露 span、稳定事件身份或通用引用重写代数。

开发备注

无。