Skip to main content

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 > descriptionokf 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] [--strict-links]
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
--strict-links Fail if local markdown links point outside bundle or to missing .md target
okf bundle example --default-type reference  # first run → bundled/
okf bundle example --default-type reference --force  # re-run
okf bundle example --default-type reference --force --strict-links  # fail on broken local .md links
cat bundled/tables/orders.md

.okfignore (bundle only):

  • Put .okfignore in input-dir.
  • Add bundle-relative markdown paths to skip, one per line.
  • Blank lines and # comments ignored.
  • Matching is exact path match (no glob, no negation).
# example/.okfignore
smoke-ignore.md
tables/orders.md

Local link checks during bundle:

  • Scans markdown body links to local .md targets.
  • Supports relative links (./x.md, ../x.md) and bundle-root links (/tables/x.md).
  • Ignores external links (https:, mailto:), fragment-only links (#section), directory links, and non-.md targets.
  • Default mode prints warnings for missing targets or links resolving outside bundle.
  • --strict-links turns those warnings into a non-zero exit (Error: strict link check failed).

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 .md has parseable YAML frontmatter with non-empty type.
  • 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.mdtype: "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.
.okfignore entries skipped in bundle Add bundle-relative markdown paths (e.g. tables/orders.md) to skip conversion for selected files. Blank lines and # comments are ignored.

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

  1. Walk input-dir for .md files (skip .okfignore matches and reserved names)
  2. Extract title from # on line 1, description from > block. If strict format not met, falls back: title omitted if absent, description from first 80 chars of body
  3. Check local markdown links against planned bundle targets (warn by default, or fail with --strict-links)
  4. Set type from parent dir name, timestamp from file mtime
  5. Write concept files with YAML frontmatter (title field omitted if empty)
  6. Generate index.md per directory — # Contents for files, # Directories for 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 .md has parseable YAML frontmatter with non-empty type
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

okf_cli-0.4.3.tar.gz (44.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

okf_cli-0.4.3-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file okf_cli-0.4.3.tar.gz.

File metadata

  • Download URL: okf_cli-0.4.3.tar.gz
  • Upload date:
  • Size: 44.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

Hashes for okf_cli-0.4.3.tar.gz
Algorithm Hash digest
SHA256 64c4a702bc166e8116707ca8ae2f4537ee7c0bd84c490b0f3fbd3305d7de118e
MD5 540c4c6dab5f3ea039211d0a029e09f9
BLAKE2b-256 101a85dca9ee12bf78591cfcdf03807788e9de6055278a52aceab19b0b20c745

See more details on using hashes here.

File details

Details for the file okf_cli-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: okf_cli-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 14.0 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

Hashes for okf_cli-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9e87bc512ca75e564a7bfe2cf9fbd8a7e25d4a1d8f5cda5ffd3416bbd64e18d4
MD5 2e8bd9f8106e6860eb8763db2c8f0f38
BLAKE2b-256 066b4974e6e4c12951ccb51087026ec3c3909e06b8ff7a1e55161aca75040b44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page