Skip to main content

qkb — local knowledge-base CLI

A small CLI for ingesting and querying local knowledge files (markdown, plain text, JSON, YAML, CSV) using SQLite FTS5 BM25, with optional LLM-powered summarization on ingest and reranking on query.

Install

Requires Python 3.12+ and uv.

git clone <this-repo>
cd qkb_trial
uv sync
uv pip install -e .

After install, qkb is on your PATH. (Or run any command via uv run qkb ….)

Quick start

# Initialize the database (creates ~/.qkb/index.sqlite)
qkb init

# Ingest some files
qkb ingest examples/

# See what's there
qkb list
qkb status

# BM25 search — no LLM required
qkb search "user_id"
qkb search "Postgres"

# Show a single document's metadata + chunk layout
qkb show 1

# Drop a document
qkb delete 1

LLM features (optional)

With an LLM configured, ingest stores a generated summary and tags per document, and qkb query does BM25 → LLM rerank for higher-quality results.

Configure once via env vars or qkb config set:

# OpenAI
export QKB_LLM_PROVIDER=openai
export QKB_LLM_MODEL=gpt-4o-mini
export QKB_LLM_API_KEY=sk-...

# Or local Ollama
qkb config set llm_provider ollama
qkb config set llm_base_url http://localhost:11434/v1
qkb config set llm_model llama3.1:8b

# Then:
qkb ingest examples/
qkb query "how do we handle authentication?"

qkb config list prints the effective configuration. Env vars override ~/.qkb/config.toml.

Commands

Command Purpose
qkb init Create the data directory and database
qkb ingest <paths>... [-r] [--no-llm] [--force] Ingest files or directories
qkb list [--format md] [--json] List ingested documents
qkb show <id|path> Show metadata and chunk layout
qkb delete <id|path> Remove a document
qkb reindex [<path>] [--force] Reprocess changed (or all) documents
qkb search <query> [-n 20] [--json] BM25 search, no LLM needed
qkb query <question> [-n 5] [--pool 20] [--json] BM25 → LLM rerank
qkb status Database stats
qkb config list|get|set Read/write configuration

Storage

Single SQLite file at ~/.qkb/index.sqlite (override with QKB_DATA_DIR or QKB_DB_PATH). Schema: documents (one row per file), chunks (header- or window-bounded fragments), chunks_fts (FTS5 BM25 index over chunk content + heading + summary).

Supported formats

Extension Strategy
.md, .markdown Split by H1/H2/H3 headings; long sections sliding-windowed
.txt, .text Sliding 800-char windows with 100-char overlap
.json Flattened to key.path: value lines per leaf
.yaml, .yml Flattened to key.path: value lines per leaf
.csv One chunk per row, formatted row N: col=val; …

Testing

pytest -q

The test suite uses an in-memory SQLite database and a mocked LLM client — no network required.

Metadata

Release files for qkb 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qkb 0.0.1
File Size Uploaded Provenance
qkb-0.0.1.tar.gz 15.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for qkb 0.0.1
File Interpreter ABI Platform
qkb-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.9 kB

Release files / qkb-0.0.1.tar.gz

Download URL qkb-0.0.1.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a3529cbd7197a6ee4e57f411ae69dfb8d7bee631e424c28cef3729081cf4a469
BLAKE2b-256 checksum
How to use checksums
2dc8677a814e6cccf112a133b3e45950618c62665cd084450e58d72563521a88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / qkb-0.0.1-py3-none-any.whl

Download URL qkb-0.0.1-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66d66594a383dadd195d9148db3f0b7a32c7837ac99d167035a462f2100eb0ef
BLAKE2b-256 checksum
How to use checksums
aabaf4a7bce6c839a0dbdeff4b59e48d3150cd018f4019e451d6778c514c298c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Security for qkb 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page