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

@baichuan-os/plugin-support

v0.3.0

Published

Baichuan OS plugin SDK types and shared validation contracts

Readme

@baichuan-os/plugin-support

百川 OS 插件基础支持包(整合了原 @baichuan-os/plugin-sdk@baichuan-os/plugin-validator)。

本包统一管理百川 OS 插件生态的公共 SDK 类型声明、开发调试 Bridge 以及共享的规范校验器,确保 CLI、百川 OS 宿主端和开发者插件项目依赖同一套版本标准与契约约束。


📦 安装

在插件项目或宿主工程中安装:

pnpm add -D @baichuan-os/plugin-support
# 或
npm install -D @baichuan-os/plugin-support

🚀 模块导出与使用方式

本包采用子路径导出(Subpath Exports)结构,按关注点分离导出功能:

1. 插件 SDK 类型与 Bridge (/sdk)

提供完整的 BaiChuanSDK 类型定义、能力入参/出参、以及本地开发调试 Bridge:

// 导入 SDK 核心类型
import type {
  BaiChuanSDK,
  PluginModule,
  PluginContext,
  RobotStateData,
  SubscriptionCallback,
} from '@baichuan-os/plugin-support/sdk';

// 导入 Bridge 构建函数与版本常量
import {
  createBaiChuanSDKBridge,
  BAICHUAN_PLUGIN_SDK_VERSION,
} from '@baichuan-os/plugin-support/sdk';

全局 Window 类型声明 (/sdk/global)

若需要在插件工程中通过全局 window.baiChuanSDK 直接调用:

// 在 env.d.ts 或入口文件中引入
import '@baichuan-os/plugin-support/sdk/global';

// 即可获得全局代码提示与类型补全
const robotState = await window.baiChuanSDK.robot.getState();

2. 插件规范与清单校验器 (/validator)

提供针对 plugin.jsonpackage.json、版本兼容性及组件 Schema 的完整校验能力:

import {
  validatePluginManifest,
  assertValidPluginManifest,
  validatePackageJsonContract,
  validateOsCompatibility,
  validateSdkCompatibility,
} from '@baichuan-os/plugin-support/validator';

// 运行时校验 plugin.json
const result = validatePluginManifest(manifestContent, {
  mode: 'runtime',
  currentOsVersion: '1.5.0',
  currentSdkVersion: '0.2.0',
});

if (result.diagnostics.length > 0) {
  const errors = result.diagnostics.filter(d => d.level === 'error');
  if (errors.length > 0) {
    console.error('Plugin manifest validation failed:', errors);
  }
}

3. 根入口导出

同时也支持从根路径统一解构:

import { sdk, validator } from '@baichuan-os/plugin-support';

🛠️ 本地开发与测试

在当前包目录 (packages/plugin-support) 或根工作区下执行:

# 类型检查
pnpm run typecheck

# 运行单元测试
pnpm run test

# 运行测试覆盖率
pnpm run test:coverage

# 清理并构建产物 (dist)
pnpm run build

🚢 发布流程

  1. 确认已获取 @baichuan-os 组织在 npm 上的发布权限。
  2. 运行构建与测试:pnpm typecheck && pnpm test && pnpm build
  3. 执行预发布检查:npm pack --dry-run
  4. 正式发布:pnpm publish --access public --no-git-checks