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

@liu_jimmy/blocks-spec

v1.1.4

Published

BlockSpec protocol: AI ↔ code generator (schema, validator, registry). Part of fe-kit AI Code Cache layer.

Readme

@liu_jimmy/blocks-spec

BlockSpec = AI 与代码生成器之间的 API,是 fe-kit AI Code Cache 的中间协议层。

位置 in 三层体系

规范层(tokens + eslint-preset)
    ↓
抽象层(BlockSpec)  ← 本包
    ↓
缓存层(AI Cache Store)+ Compiler → Vue/React/Svelte
  • AI 输出 BlockSpec JSON
  • 本包 提供 schema 校验 + TypeScript 类型
  • 插件 / CLI 校验通过后写入缓存,再由 Compiler 生成框架代码

安装

pnpm add @liu_jimmy/blocks-spec

BlockSpec 格式(block.v1)

{
  "specVersion": "block.v1",
  "kind": "block",
  "name": "hero",
  "variant": "split",
  "props": {
    "title": "Build faster",
    "subtitle": "Ship modern web apps"
  }
}

| 字段 | 必填 | 说明 | |------|------|------| | specVersion | ✅ | 固定 "block.v1" | | kind | ✅ | 固定 "block" | | name | ✅ | 块类型:hero, faq, footer, cta, nav... | | variant | | 变体:split, centered, accordion... | | props | | 块级数据,由 name/variant 决定结构 | | slots | | 具名插槽内容 | | meta | | description, tags |

用法

校验

import { validateBlockSpec, assertBlockSpec } from "@liu_jimmy/blocks-spec";

const result = validateBlockSpec(aiOutput);
if (!result.valid) {
  console.error(result.errors);
  return;
}
// 通过后可写入缓存或交给 Compiler

断言(用于编译前)

import { assertBlockSpec } from "@liu_jimmy/blocks-spec";

assertBlockSpec(spec); // 抛错则 invalid
// spec 此处为 BlockSpec 类型,可传给 compiler

类型

import type { BlockSpec } from "@liu_jimmy/blocks-spec";

插件流程建议

  1. 用户输入(如 “Generate hero section”)
  2. 查缓存(key = hash(BlockSpec 或 name+variant+props))
  3. 命中 → 直接取已生成代码
  4. 未命中 → 调 AI 生成 BlockSpec(不要直接生成 Vue/React 代码)
  5. validateBlockSpec(spec) 校验
  6. 保存到 AI Cache Store
  7. Compiler(spec, framework) → 生成 Vue/React/Svelte 代码并写入项目

文件结构

blocks-spec/
  schema/
    block.v1.schema.json   # JSON Schema
  registry/                 # Block Library:按 block/variant 组织
    blocks.json             # block 与 variant 列表
    hero/
      split.json
      centered.json
    faq/accordion.json
    footer/default.json
    navbar/default.json
    features/grid.json
    pricing/default.json
    cta/banner.json
    hero.spec.json          # 兼容旧路径
    faq.spec.json
    footer.spec.json
  patches/
    registry.json           # Patch Library:各 block 支持的修改动作(add_faq_item、replace_text 等)
  validator.ts
  types.ts
  index.ts

Block Library

  • 目录约定:registry/<block>/<variant>.json,参见 registry/blocks.json
  • 当前支持:hero(split/centered)、faq(accordion)、footer(default)、navbar(default)、features(grid)、pricing(default)、cta(banner)。

Patch Library

  • patches/registry.json 列出各 block 可用的 patch 名称(如 add_faq_item、replace_text)。
  • 对源码的修改动作(AST/模板级)由 @liu_jimmy/blocks-compilerapplyPatch(source, payload) 实现;初版仅实现 replace_text,其余留二期。

后续

  • Compiler:根据 BlockSpec + framework 输出 .vue / .tsx / .svelte(可放在独立包如 @liu_jimmy/blocks-compiler
  • AI Cache Store:持久化 BlockSpec ↔ 生成代码,减少重复调用 AI