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

@yangxiaolang/smart-doc-sse-parser

v0.5.2

Published

TypeScript SDK for parsing the Smart Doc SSE response format.

Readme

smart-doc-sse-sdk

smart-doc-sse-sdk 是一个用于解析 Smart Doc SSE 响应的 TypeScript SDK。它把 smart-doc-plugin 里的协议处理抽成独立包,覆盖三层能力:

  • SSE data: 事件解析与快照/流式消费
  • docs / think / error / 正文的语义拆分
  • Markdown 整理与完整文档渲染

安装

pnpm add @alauda/smart-doc-sse-sdk

本地开发使用 pnpm

pnpm install
pnpm run build

快速开始

如果你的输入是完整 SSE 快照:

import { parseSmartDocSseMessage } from '@alauda/smart-doc-sse-sdk';

const parsed = parseSmartDocSseMessage(rawSseSnapshot);

console.log(parsed.content);
console.log(parsed.message.refDocs);

如果你还需要把结果整理成更稳定的 Markdown:

import {
  formatSmartDocMarkdown,
  parseSmartDocSseMessage,
  renderSmartDocMarkdownDocument,
} from '@alauda/smart-doc-sse-sdk';

const parsed = parseSmartDocSseMessage(rawSseSnapshot);
const markdown = formatSmartDocMarkdown(parsed.content);
const fullDocument = renderSmartDocMarkdownDocument(parsed.message, {
  title: 'Smart Doc Result',
  question: 'How to install ACP?',
});

核心规则

  • 默认过滤 {"type":"metadata"} 这类元数据事件
  • 默认忽略 [DONE] 这类结束消息
  • 默认把 <trace> 替换为 <plg-hf-trace>
  • parseSmartDocMessage() 会提取 <docs> / <think> / <error>
  • data: 事件之间存在空块时,会补一个换行符,尽量保留段落结构

文档

发布产物

对外入口是 src/index.ts,公开导出:

  • parseSmartDocSseSnapshot
  • SmartDocSseParser
  • consumeSmartDocSseStream
  • consumeSmartDocDisplayStream
  • parseSmartDocMessage
  • parseSmartDocDisplayMessage
  • normalizeSmartDocReferenceDocs
  • getSmartDocDisplayThoughtProcess
  • getSmartDocDisplayResult
  • parseSmartDocSseMessage
  • formatSmartDocMarkdown
  • renderSmartDocMarkdownDocument