Skip to main content

py-okf

A Python library for generating and managing Open Knowledge Format (OKF) files from Python projects.

OKF is a vendor-neutral markdown specification that lets AI agents and humans access curated knowledge without vendor lock-in — a directory of .md files with YAML frontmatter, one file per concept (module, class, API, dataset, etc.).

py-okf analyzes your Python codebase using the ast module and generates an .okf/ bundle of markdown files describing your project's concepts.

Installation

pip install py-okf

CLI Usage

# Generate OKF files for a Python project
okf generate /path/to/your/project

# Refresh stale OKF files (only regenerates files where source changed)
okf refresh /path/to/your/project

# Validate OKF files against the spec
okf validate /path/to/your/project

# Custom output directory
okf generate /path/to/your/project -o docs/okf

# Include private (underscore-prefixed) symbols
okf generate /path/to/your/project --include-private

Python API

from pyokf import analyze_project, generate_module_concepts, OKFBundle
from pathlib import Path

# Analyze a project
modules = analyze_project(Path("./myproject"))

# Generate OKF concepts
bundle = OKFBundle(Path("./.okf"))
bundle.ensure_directory()
for module in modules:
    concepts = generate_module_concepts(module)
    bundle.write_all(concepts)

# Load and validate an existing bundle
bundle = OKFBundle(Path("./.okf")).load()
errors = bundle.validate_directory()

Generated Output

Running okf generate . produces an .okf/ directory with flat, dotted-name files:

.okf/
├── mypackage.md                    # module concept
├── mypackage.Connection.md         # class concept
└── mypackage.query.md              # api concept (exported function)

Each file contains YAML frontmatter followed by a markdown description:

---
type: api
title: mypackage.query
description: Execute a SQL query against the active connection.
resource: ./mypackage/__init__.py
tags:
- python
- api
timestamp: '2026-06-22T10:00:00Z'
---

# query

Execute a SQL query against the active connection.

## Signature

    def query(sql: str, params: Optional[list[str]] = None) -> list[dict]

## Parameters

- **`sql`**: `str`
- **`params`**: `Optional[list[str]]` *(default: `None`)*

## Returns

`list[dict]`

Concept Types

Type Description
module A Python module file
class A class definition
function A top-level function
api A function listed in __all__ (publicly exported)

Requirements

  • Python 3.10+
  • PyYAML >= 6.0

Metadata

Release files for py-okf 0.2.0

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

Source distribution (sdist)

Source distribution for py-okf 0.2.0
File Size Uploaded Provenance Actions
py_okf-0.2.0.tar.gz 20.8 kB Without provenance Details for py_okf-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-okf 0.2.0
File Interpreter ABI Platform Actions
py_okf-0.2.0-py3-none-any.whl Python 3 none any Details for py_okf-0.2.0-py3-none-any.whl

Total release size: 38.6 kB

Release files / py_okf-0.2.0.tar.gz

Download URL py_okf-0.2.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c932108cd933a9f5918867b3e37d0d154ff2385c615dacfbac3b627e86b91e62
BLAKE2b-256 checksum
How to use checksums
725ce0bb85540bbd2f8171b1d7cdb35867088704d13e1c0527df05078cc7ced4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / py_okf-0.2.0-py3-none-any.whl

Download URL py_okf-0.2.0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c16e3866b8c5a364f4d45a80b1ec4ec0c4566d843619c197b7d39619af0398f1
BLAKE2b-256 checksum
How to use checksums
3392d425606784b96104054044839063d6baa5f4807b04266772eedd7979c4be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for py-okf 0.2.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 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