@costrict/cosknow
v1.0.2
Published
Knowledge base command toolkit for AI agents
Downloads
386
Readme
CosKnow
English | 简体中文
CosKnow is a knowledge-base command toolkit for AI agents. It breaks the knowledge generation workflow into reusable Markdown commands, prompt templates, and local utilities, so you can inspect, render, install, and validate those assets through a CLI.
The repository currently provides two main layers:
- Command assets: reusable knowledge-base command templates under
commands/ - Runtime tooling: CLI, installer, template rendering, and document linting under
src/
Use Cases
- Prepare an installable knowledge command set for AI agents
- Inspect command descriptions, arguments, and dependencies locally
- Pre-render prompts or command templates to reduce manual replacement work
- Install the command set into Roo Code or a custom directory
- Run basic lint checks against generated knowledge documents
Built-in Commands
| Command | Description |
| --- | --- |
| kb-pre | Project pre-analysis |
| kb-init | Full knowledge-base generation (multi-agent coordination) |
| kb-eval | Knowledge quality evaluation (multi-agent mode) |
| kb-optimize | Knowledge quality repair based on evaluation results |
| kb-update | Incremental knowledge update based on Git diffs |
Directory Structure
CosKnow/
├── commands/ # Knowledge command templates
├── prompts/ # Prompt templates that can be rendered independently
├── linter/ # Knowledge document linting script
├── src/ # CLI and library code
├── scripts/ # Release scripts
├── test/ # bun:test suites
└── docs/ # Plans and troubleshooting notesRequirements
- Node.js 18+
- Bun 1.3+ (required for development, testing, and builds)
- An npm-compatible package registry
The published CLI prefers Bun when available. If Bun is not installed, it falls back to Node.js and runs the compiled output under
dist/.
Quick Start
1. Install dependencies
bun install2. List available commands
bun run dev list3. Show details for a specific command
bun run dev show kb-pre4. Render a command template
bun run dev render kb-pre --output ./doc/kb-pre-report.md5. Render a prompt template
bun run dev prompt "01-仓库概览.md" --输出目录 ./doc/kb6. Install the command set into Roo Code
bun run dev install --target roo-commands7. Install the command set into a custom directory
bun run dev install --path ./.cosknow/commands --only kb-pre,kb-init8. Lint a generated knowledge document
bun run dev lint ./doc/kb/仓库概览.md --project-dir .CLI Usage
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 installedSubcommands
list: list all command templatesshow: inspect command metadata, including arguments, dependencies, and related promptsrender: render placeholders in a command bodyprompt: render a template fromprompts/lint: check common document issues such as broken paths and Mermaid snippetsinstall: copy command templates and resources into a target directoryuninstall: remove files tracked by the CosKnow installation manifestinstalled: show detected installation targets
Use As a Library
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-pre', 'kb-init'],
})The main exported APIs include:
createRegistry()/clearCache()install()/uninstall()render()resolveTarget()/BUILT_IN_TARGETSloadCommand()/loadPrompt()
Installation Targets
Built-in installation targets are defined in src/targets.ts:
roo-commands: installs to~/.roo/commandscustom: installs to the output directory passed by the caller
The installer also copies:
- Markdown templates under
prompts/ linter/kb-linter.js- the
.cosknow-manifest.jsoninstallation manifest
Development Commands
bun run dev # Run the CLI
bun test # Run tests
bun run build # Build dist/
npm run release # Choose a version, generate changelog, build, publish, tag, push, and create a GitHub ReleaseNotes
- Variable replacement for
renderandpromptuses placeholder names from the templates, not the display names shown by the command help. For example, thekb-pretemplate expects--output, not--output-path. install --target roo-commandswrites resources into~/.roo/commands.npm run releasenow publishes to npm, creates a Git tag, pushes it, and creates a GitHub Release with generated notes.- By default, the script checks
gh --versionandgh auth statusbefore publishing. Ifghis missing or not logged in, it stops before any release side effects happen. - If you want to publish without creating a GitHub Release, run
SKIP_GITHUB_RELEASE=1 npm run release.
License
No standalone license file is declared in the repository yet. If you plan to publish it externally, add an explicit license policy first.
