@kbkit/cli
v1.1.0
Published
A lightweight CLI tool for managing Markdown-based personal knowledge base with interactive mode
Maintainers
Readme
kb-cli
A lightweight CLI tool for managing Markdown-based personal knowledge base.
Features
- 📝 Markdown-based note management with YAML frontmatter
- 🗂️ Flat file structure (no directory classification)
- 🔍 Simple indexing and querying
- 🔄 Git integration for version control
- 🌍 Cross-platform support (macOS, Linux, Windows)
Installation
From npm
npm install -g @kbkit/cliFrom source
git clone <repository-url>
cd kb-cli
pnpm install
pnpm build
npm linkUsage
Interactive Mode (Default)
Simply run kb without any arguments to enter interactive mode:
kbIf no configuration file exists, you'll be prompted to:
- Initialize a new knowledge base - Create a new local knowledge base
- Clone a remote knowledge base - Clone an existing knowledge base from a Git repository
- Exit
If a configuration file exists, you'll be presented with options:
- 📝 新建笔记 - Create a new note
- 🔄 重建索引 - Rebuild the index file (README.md)
- 🚪 退出 - Exit the program
Command Line Mode
You can also use specific commands directly:
Initialize Knowledge Base
Initialize a new knowledge base:
kb init [path] [--clone <url>]This will:
- Create a configuration directory at a platform-specific location:
- macOS/Linux:
~/.kb - Windows:
%USERPROFILE%\.kb
- macOS/Linux:
- Use default repository path:
- macOS/Linux:
~/.kb/repo - Windows:
%USERPROFILE%\.kb\repo
- macOS/Linux:
- Save configuration to the config file in the configuration directory
Examples
# Use default path
kb init
# Specify custom local path
kb init /path/to/your/knowledge-base # macOS/Linux
kb init C:\Users\YourName\knowledge-base # Windows
# Clone from remote repository
kb init --clone https://github.com/username/knowledge-base.git
# Clone to custom path
kb init /custom/path --clone https://github.com/username/repo.git # macOS/Linux
kb init C:\custom\path --clone https://github.com/username/repo.git # WindowsConfiguration
Configuration is stored at:
- macOS/Linux:
~/.kb/config.json - Windows:
%USERPROFILE%\.kb\config.json
Example configuration:
{
"repoPath": "/Users/username/.kb/repo"
}Note:
- The configuration directory is platform-specific and cannot be changed
- The repository path defaults to the platform-specific location but can be customized
- The notes directory is fixed as
notesand cannot be changed
Create a New Note
Create a new markdown note:
kb new "My Note Title"This will:
- Generate a unique ID (format:
YYYYMMDD-HHMMSS) - Create a markdown file with frontmatter
- Open in your default editor (if
EDITORenv var is set)
The created file will have this structure:
---
id: 20260416-143052
title: My Note Title
tags: []
created: 2026-04-16
updated: 2026-04-16
---
# My Note TitleGenerate Index
Generate an index file (README.md) of all notes:
kb indexThis will:
- Parse frontmatter
- Generate a sorted index by creation date
- Create/update
README.mdin the repository root
Example output:
# Knowledge Base
## 最近更新
- [My Note Title](notes/20260416-143052.md) - 2026-04-16
- [Another Note](notes/20260415-091234.md) - 2026-04-15Development
Prerequisites
- Node.js >= 18
- pnpm
Setup
pnpm install
pnpm buildDevelopment Mode
pnpm devArchitecture
The CLI is built with a modular architecture:
/src
/commands # Command implementations
init.ts # Initialize knowledge base
clone.ts # Clone repository
new.ts # Create new note
index.ts # Generate index
/utils # Utility functions
config.ts # Configuration management
fs.ts # File system operations
id.ts # ID generation
frontmatter.ts # Frontmatter parsing
cli.ts # Main CLI entry pointExtending
The architecture supports easy extension for future commands:
kb tag- Tag managementkb list- List noteskb edit- Edit existing noteskb link- Link management
License
MIT
