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

koishi-plugin-aka-larkcontroller

v0.0.7

Published

lark controller

Readme

koishi-plugin-aka-larkcontroller

npm

基于飞书文档的企业知识库 RAG 插件,支持自然语言查询与 ChatLuna 集成。

功能特性

  • 文档索引:递归索引飞书 Wiki 空间或单个文档,自动建立向量知识库
  • 智能检索:基于 LLM + 向量检索实现语义搜索,返回最相关内容与文档链接
  • LLM 决策:索引前由 LLM 判断是否纳入、如何分段,摘要由 LLM 生成
  • ChatLuna 集成:暴露检索服务接口,可被 ChatLuna 调用实现自然语言对话 + 知识库
  • 权限复用:优先读取 adapter-lark 配置,无需重复填写飞书应用信息

快速开始

安装

npm install koishi-plugin-aka-larkcontroller

配置

  1. 飞书应用(可选,优先读取 adapter-lark 配置)

    • 飞书 API 根地址:https://open.feishu.cn
    • App ID / App Secret
    • 需要权限:docs:document.content:readdocx:document:readonly
    • (可选)Wiki 权限:wiki:space:readwiki:node:read
  2. LLM 配置(必填)

    • OpenAI 兼容 API 的 baseURL
    • API Key
    • 模型 ID(对话 + 推理)
    • Embedding 模型 ID(可选)
  3. 向量库(可选)

    • SQLite 文件路径,默认 data/aka-larkcontroller/vector.db
    • Wiki 检索返回条数,默认 8

使用

1. 建立索引

生成索引 <飞书文档/Wiki链接>

示例:

  • 单文档:生成索引 https://xxx.feishu.cn/docx/AbcDeFg...
  • 递归索引整个 Wiki 空间:生成索引 https://xxx.feishu.cn/wiki/AqM4wqj...

2. 查询知识库

wiki <问题>

示例:

wiki 请假流程是什么?

3. 查看状态

知识库状态

ChatLuna 集成

本插件通过 Koishi Context Service 暴露检索服务,可被 ChatLuna 调用实现对话式知识库。

服务接口

ctx.get('aka-larkcontroller').queryWiki(input, sessionId)
ctx.get('aka-larkcontroller').hasIndex()
ctx.get('aka-larkcontroller').stats()

集成方式

查看 CHATLUNA_INTEGRATION.md 了解详细集成步骤。

查看 CHATLUNA_PROMPTS.md 获取预设提示词模板。

典型场景

用户在 ChatLuna 对话:

用户:公司的报销流程是怎样的?
ChatLuna:[调用 queryWiki] 根据知识库...
         参考文档:[财务管理制度](链接)

架构设计

  • 服务层FeishuService(文档 API)、LlmService(OpenAI 兼容)、VectorStore(SQLite 向量库)
  • 索引流水线:拉取 → LLM 决策 → LLM 摘要 → 向量化 → 落库
  • 检索链路:向量检索 → 拉取原文(按需)→ LLM 生成回答 + 文档链接
  • 可扩展:预留能力注册机制,便于后续增加日历、云盘等飞书能力

常见问题

1. 索引失败:404

原因:飞书应用缺少权限或未被授权访问该文档/Wiki 空间。

解决

  • 确认应用已开通 docs/docx/wiki 相关权限
  • 将应用加入文档所在的空间/知识库

2. 检索无结果

原因:知识库未建立索引。

解决:执行「生成索引」指令。

3. ChatLuna 调用失败

原因:服务未正确暴露或 ChatLuna 配置错误。

解决

  • 确保插件已启用
  • 检查 ChatLuna 的工具配置是否正确引用 aka-larkcontroller 服务

开发

# 安装依赖
npm install

# 编译
npm run build

# 类型检查
npx tsc --noEmit

License

MIT