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

@moluoxixi/ai-doc-assistant

v1.0.1

Published

组件库 AI 文档与调试助手:AST 契约提取 + 本地知识库 + 自然语言问答 + 沙箱实时预览

Readme

@moluoxixi/ai-doc-assistant

组件库的契约提取、知识库检索和 AI 问答工具。默认使用 content 检索;可选的 vector 模式使用 Vercel AI SDK 调用远程 embedding Provider。

安装

pnpm add -D @moluoxixi/ai-doc-assistant vite vue

公共入口

| 入口 | 用途 | | ------------------------------------------ | ------------------------------------------------------- | | @moluoxixi/ai-doc-assistant | 契约抽取、索引、服务端上下文和查询编排 | | @moluoxixi/ai-doc-assistant/plugin | aiDocAssistant Vite 开发服务器插件 | | @moluoxixi/ai-doc-assistant/protocol | browser-safe 请求、响应、错误码和 UI Message 数据块类型 | | @moluoxixi/ai-doc-assistant/api-contract | 把抽取结果投影为文档 API 表格的类型与规范化函数 |

Vite 配置可以直接使用独立插件入口:

import { aiDocAssistant } from '@moluoxixi/ai-doc-assistant/plugin'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    aiDocAssistant({
      componentEntries: ['packages/components/index.ts'],
    }),
  ],
})

运行

pnpm exec ai-doc-assistant serve --root . --entries packages/components/index.ts

--entries 接受逗号分隔的公共入口;没有稳定入口时可改用逗号分隔的 --globs。serve 还支持 --host 与 --port,面板默认地址为 http://127.0.0.1:5173/__ai-doc/。也可以运行 ai-doc-assistant build-index 只构建和校验知识库。

Chat 配置

Chat Provider 必须显式配置,不提供默认 Provider、模型或 relay:

AI_DOC_CHAT_PROVIDER=openai
AI_DOC_CHAT_API_KEY=your-key
AI_DOC_CHAT_MODEL=gpt-4o-mini

支持 openai、anthropic、google 和 openai-compatible。使用 openai-compatible 时还必须设置 AI_DOC_CHAT_BASE_URL。

Vector 与远程数据边界

默认的 content 模式不调用 embedding Provider。启用 vector 后,构建索引会把提取出的组件契约正文发送给所选远程 embedding Provider,查询也会发送给同一 Provider。该过程需要网络访问,可能产生调用费用,并受供应商的数据处理与保留政策约束;请确认代码和文档内容允许发送到该供应商。

AI_DOC_RETRIEVAL_MODE=vector
AI_DOC_EMBEDDING_PROVIDER=google
AI_DOC_EMBEDDING_API_KEY=your-key
AI_DOC_EMBEDDING_MODEL=gemini-embedding-001

Embedding 支持 openai、google 和 openai-compatible。使用 openai-compatible 时还必须设置 AI_DOC_EMBEDDING_BASE_URL。Provider、模型、兼容端点或组件契约发生变化后,现有索引会进入 stale,必须全量重建。

Vector 索引默认保存到 <root>/.ai-doc-index;可通过 AI_DOC_INDEX_DIR 指定其他目录。

面板运行状态会显示当前检索模式和远程 embedding Provider,并持续提示组件契约上传与潜在费用。API key 只在服务端内存中使用,不会进入浏览器请求、响应或公开状态。

Qdrant

vector 模式默认使用 Orama。切换到 Qdrant 时必须显式提供连接信息:

AI_DOC_VECTOR_STORE=qdrant
AI_DOC_QDRANT_URL=http://127.0.0.1:6333
AI_DOC_QDRANT_COLLECTION=ai-doc-components
AI_DOC_QDRANT_API_KEY=

Qdrant collection 会保存 embedding 身份与组件源哈希。远端 collection 被其他实例以不同 Provider、模型、端点或组件内容重建后,本地索引不会恢复为 ready,需重新构建。

开发验证

pnpm --filter @moluoxixi/ai-doc-assistant test
pnpm --filter @moluoxixi/ai-doc-assistant typecheck
pnpm --filter @moluoxixi/ai-doc-assistant build