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

@costrict/cosknow

v1.0.1

Published

Knowledge base command toolkit for AI agents

Downloads

414

Readme

CosKnow

CosKnow 是一个面向 AI Agent 的知识库命令工具包。它把知识库生成流程拆成可复用的 Markdown 命令、提示词模板和本地工具,支持用 CLI 查看、渲染、安装和校验这些资源。

当前仓库主要提供两类能力:

  • 命令仓库:commands/ 下维护知识库生成相关命令模板
  • 运行工具:src/ 下提供 CLI、安装器、模板渲染和文档 lint 能力

适用场景

  • 为 AI Agent 准备一套可安装的知识库命令集
  • 在本地查看某个命令的描述、参数和依赖关系
  • 预渲染 prompt 或命令模板,减少手工替换变量
  • 将命令集安装到 Roo Code 或自定义目录
  • 对生成后的知识库文档做基础 lint 检查

内置命令

| 命令 | 说明 | | --- | --- | | kb-pre | 项目预分析 | | kb-init | 知识库完整生成(多Agent协调) | | kb-eval | 知识库质量评估(多Agent协调模式) | | kb-optimize | 知识库质量修复(基于评估报告) | | kb-gen | 一键流水线(kb-pre -> kb-init -> kb-eval -> kb-optimize) | | kb-update | 基于 Git 差异的知识库增量更新 |

目录结构

CosKnow/
├── commands/        # 知识库命令模板
├── prompts/         # 可独立渲染的提示词模板
├── linter/          # 知识库文档校验脚本
├── src/             # CLI 与库代码
├── scripts/         # 发布脚本
├── test/            # bun:test 测试
└── docs/            # 计划与排障记录

环境要求

  • Node.js 18+
  • Bun 1.3+(开发、测试、构建时需要)
  • 一个支持 npm 协议的包源

发布后的 CLI 会优先使用 Bun;如果本机没有 Bun,则回退到 Node.js 执行 dist/ 下的编译产物。

快速开始

1. 安装依赖

bun install

2. 查看可用命令

bun run dev list

3. 查看某个命令详情

bun run dev show kb-gen

4. 渲染命令模板

bun run dev render kb-gen --输入目录 ./src --输出目录 ./doc/kb

5. 渲染 prompt 模板

bun run dev prompt "01-仓库概览.md" --输出目录 ./doc/kb

6. 安装命令集到 Roo Code

bun run dev install --target roo-commands

7. 安装命令集到自定义目录

bun run dev install --path ./.cosknow/commands --only kb-gen,kb-pre

8. 校验生成后的知识库文档

bun run dev lint ./doc/kb/仓库概览.md --project-dir .

CLI 用法

cosknow list
cosknow show <name>
cosknow render <name> [--key value...]
cosknow prompt <template> [--key value...]
cosknow lint <file> --project-dir <dir>
cosknow install --path <dir> [--only cmd1,cmd2]
cosknow install --target roo-commands
cosknow uninstall --path <dir>
cosknow installed

子命令说明

  • list:列出全部命令模板
  • show:查看命令元数据,包括参数、依赖和关联 prompts
  • render:渲染命令正文中的占位符
  • prompt:渲染 prompts/ 下的模板
  • lint:检查文档中的路径、Mermaid 片段等常见问题
  • install:把命令模板和资源复制到指定目录
  • uninstall:按安装清单删除 CosKnow 管理的文件
  • installed:显示已检测到的安装位置

作为库使用

import { createRegistry, install } from '@costrict/cosknow'

const registry = createRegistry()

console.log(registry.listCommands().map((command) => command.name))

const rendered = registry.renderPrompt('01-仓库概览.md', {
  输出目录: './doc/kb',
})

console.log(rendered)

await install({
  target: 'custom',
  output: './.cosknow/commands',
  only: ['kb-gen'],
})

当前导出的主要 API 包括:

  • createRegistry() / clearCache()
  • install() / uninstall()
  • render()
  • resolveTarget() / BUILT_IN_TARGETS
  • loadCommand() / loadPrompt()

安装目标

内置安装目标定义在 src/targets.ts

  • roo-commands:安装到 ~/.roo/commands
  • custom:安装到调用时传入的目录

安装时还会一起复制:

  • prompts/ 下的 Markdown 模板
  • linter/kb-linter.js
  • .cosknow-manifest.json 安装清单

开发命令

bun run dev        # 运行 CLI
bun test           # 运行测试
bun run build      # 构建 dist/
npm run release    # 选择版本号、生成 changelog、构建、发布、打 tag、推送

注意事项

  • renderprompt 的变量替换基于模板里的占位符名,而不是命令展示出来的参数名。例如 kb-gen 模板里要传 --输入目录--输出目录,不是 --input--output
  • install --target roo-commands 会把资源写入用户目录下的 ~/.roo/commands
  • npm run release 会执行 git add -A、提交、打 tag 并推送,运行前应确认工作区内容可发布。

License

仓库内暂未声明独立许可证文件;如需对外发布,请先补充明确的 License 策略。