Open Knowledge Format tooling
Project description
okf-cli — Open Knowledge Format tooling
Converts plain markdown into OKF-conformant knowledge bundles. Domain experts write # Title then > description — okf bundle generates frontmatter, type, timestamps, and index files. Files without strict formatting are parsed leniently: title from line 0 if present, description from body text.
Also validates bundles and lists concept IDs for consumption by other tools.
Install
uv tool install okf-cli
Dev quickstart
uv sync
uv run okf --help
Commands
okf bundle — convert plain markdown to OKF bundle
okf bundle <input-dir> [output-dir] [--default-type <name>] [--force]
| Argument | Description |
|---|---|
input-dir |
Directory of plain .md files |
output-dir |
Target directory (default: bundled) |
--default-type |
Type for root-level files (skip root files if omitted) |
--force, -f |
Overwrite output directory if it exists |
okf bundle example --default-type reference # first run → bundled/
okf bundle example --default-type reference --force # re-run
cat bundled/tables/orders.md
okf list — list concept IDs in a bundle
okf list <directory>
Prints concept IDs (bundle-relative path with .md stripped) for every
concept file in the bundle. Reserved filenames (index.md, log.md)
are excluded. README.md is not reserved by the OKF spec and is listed
as a concept if present.
Requires the directory to be a valid OKF bundle; fails if any
non-reserved .md is missing frontmatter or a non-empty type.
okf list bundled/
# datasets/sales
# playbooks/incident-response
# tables/orders
# …
Useful for piping OKF bundles into other tooling:
okf list bundled/ | xargs -I{} okf show bundled/ {}
okf show — read a concept by ID
okf show <directory> <concept-id>
Prints the full contents (frontmatter + body) of a concept file.
Concept IDs are the bundle-relative path with .md stripped — exactly
as printed by okf list.
Requires the directory to be a valid OKF bundle.
okf show bundled/ tables/orders
# ---
# type: "tables"
# title: "Customer Orders"
# ...
Guards against path traversal and rejects reserved filenames.
okf validate — check OKF conformance
okf validate <directory>
Checks OKF v0.1 §9 conformance:
- Every non-reserved
.mdhas parseable YAML frontmatter with non-emptytype. - Reserved filenames (
index.md,log.md) follow spec structure (§6/§7). - Non-UTF-8 files are flagged.
okf validate bundled/
# 16 files: 16 ok
Writing input files (for bundle)
Strict format (recommended)
Every .md file starts with:
# Title
> Description
> Second optional description line.
Everything after the description block is preserved unchanged.
Lenient fallback
Files that don't follow the strict format are still bundled best-effort:
| Condition | Behavior |
|---|---|
No # Title on line 1 |
Title omitted from frontmatter |
No > description block |
Description derived from first 80 chars of body ("…" if truncated) |
Root-level file without --default-type |
Skip file, warn, continue |
Rules:
| Rule | Why |
|---|---|
| Folder name = concept type | tables/orders.md → type: "tables" |
Only .md files processed |
Non-.md files ignored |
index.md, log.md, README.md skipped in bundle |
Input may contain repo artifacts; these are not concepts. bundle warns when it skips them. Other commands (list, show, validate) operate on conformant OKF bundles where only index.md and log.md are reserved. |
Root files need --default-type. Otherwise put files in named folders.
See the example/ directory for a sample of how to structure files.
How bundle works
- Walk
input-dirfor.mdfiles (skip reserved names) - Extract
titlefrom#on line 1,descriptionfrom>block. If strict format not met, falls back: title omitted if absent, description from first 80 chars of body - Set
typefrom parent dir name,timestampfrom file mtime - Write concept files with YAML frontmatter (title field omitted if empty)
- Generate
index.mdper directory —# Contentsfor files,# Directoriesfor subdirs (recursive)
Output
Each concept becomes a markdown file with YAML frontmatter:
---
type: "tables"
title: "Customer Orders"
description: "One row per completed customer order across all channels."
timestamp: "2026-07-04T15:06:51+00:00"
---
Original body preserved as-is.
Every directory gets its own index.md:
# Contents
* [Customer Orders](orders.md) - One row per completed customer order across all channels.
# Directories
* [partitions](partitions/)
OKF Conformance
Generated bundles conform to OKF v0.1 (§9):
- Every non-reserved
.mdhas parseable YAML frontmatter with non-emptytype✓ - Reserved filenames follow spec structure ✓
- Consumers MUST tolerate missing optional fields, unknown types, broken links ✓
Project layout
okf-cli
├── .github/workflows/test.yml # CI
├── OKF_SPEC.md # OKF specification
├── pyproject.toml # uv-managed Python project
├── src/okf/
│ ├── cli.py # Typer entrypoint
│ ├── core.py # Shared parsing/formatting
│ └── commands/ # bundle, list, show, validate
├── tests/test_cli.py # Tests
└── example/ # Sample input markdown
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file okf_cli-0.3.1.tar.gz.
File metadata
- Download URL: okf_cli-0.3.1.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
979f185fcf296677fcd57ce59ae53320450358027b56f852480fb0b7b5465e64
|
|
| MD5 |
040f69035153404723753f074b18f309
|
|
| BLAKE2b-256 |
dc64c50c8cf637bfeb385deb2869239035c64795f7725dbf1be9498e5ebe1760
|
File details
Details for the file okf_cli-0.3.1-py3-none-any.whl.
File metadata
- Download URL: okf_cli-0.3.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cbf8266634f9e452918782b0c5935c7df7ccbc1179812771521f42e67fb1df8
|
|
| MD5 |
8c65e9337ff15870b56a5b3c31387635
|
|
| BLAKE2b-256 |
0d38e0a2db8dbd7fd378bb9228dae2f5745d2926df41c2bfb27661223d39db89
|