Skip to main content

md2okf

CI Latest release License: MIT

Compile Markdown documents into an OKF knowledge base with a coding agent.

Point md2okf at a Markdown file or folder and a coding agent writes a wiki into the output directory: a page per topic, an index in every directory, links between them, and a log of what each run changed. OKF, the Open Knowledge Format by Google, is a tree of Markdown files with YAML frontmatter and nothing else — no schema registry, no server, nothing to install. The agent takes one source document per run and folds it into the wiki already on disk, so documents accumulate rather than overwrite. SPEC.md is the OKF specification the wiki is built against; the agent reads it at the start of every run, and it outranks any other instructions.

---
config:
  layout: dagre
  flowchart:
    nodeSpacing: 35
    rankSpacing: 45
---
flowchart LR
  subgraph IN[" "]
    direction TB
    SPEC@{ shape: doc, label: "okf spec<br>SPEC.md"}
    MD@{ shape: docs, label: "source documents<br>md/*.md"}
    STATE["session traces<br/>~/.local/state/md2okf/*/sessions"]
    DRV["host driver<br>md2okf -o okf/ md/"]
    KIT["kits/*/spec.yaml<br/>kits/*/files/"]
  end

  subgraph VM["sbx microVM"]
    AGENT["coding agent<br/>(Pi, Claude Code or Codex)"]
    LINT["okfctl linter"]
    TOOLS["skills<br>/inspect-md<br/>/compile-okf<br/>/inspect-okf<br/>/merkle-okf<br/>/curate-okf<br/>/size-okf"]
    PROXY["credential proxy"]
  end

  subgraph OUT[" "]
    direction TB
    OKF@{ shape: docs, label: "okf/<br/>the wiki"}
    NET("OpenRouter hub")
    NET3("Anthropic, OpenAI")
  end
  NET1("DeepInfra")
  NET2("...")

  SPEC -.->|"outranks all"| AGENT
  MD ==>|"read by"| AGENT
  STATE -.->|"mounts"| VM
  STATE ~~~ AGENT
  DRV -->|"sbx exec"| AGENT
  KIT -->|"builds"| VM
  AGENT -.->|"runs"| LINT
  LINT -.->|"must pass"| OKF
  AGENT ==>|"writes"| OKF
  AGENT -.->|"uses"| TOOLS
  AGENT -->|"calls"| PROXY
  PROXY -->|"injects key"| NET
  PROXY -->|"injects key"| NET3
  NET -->|"BYOK"| NET1 & NET2

  classDef data    fill:aliceblue,stroke:steelblue,stroke-width:2px,color:#10314F
  classDef host    fill:antiquewhite,stroke:darkgoldenrod,stroke-width:2px,color:#4A2E05
  classDef helper  fill:#E3F2F1,stroke:#0E7C86,stroke-width:2px,color:#0B3D40
  classDef agent   fill:mistyrose,stroke:firebrick,stroke-width:2px,color:#5A1710
  classDef ext     fill:whitesmoke,stroke:lightslategray,stroke-width:1.5px,color:#3A4250
  class MD,SPEC,STATE,OKF data
  class KIT,DRV host
  class TOOLS,LINT,PROXY helper
  class AGENT agent
  class NET,NET3,NET1,NET2 ext
  style VM fill:whitesmoke,stroke:lightslategray,stroke-width:1.5px
  style IN fill:none,stroke:none
  style OUT fill:none,stroke:none


Host tooling (amber) builds the microVM from the kit and drives it with one sbx exec per source document. Inside, the coding agent (red) runs the /compile-okf skill: it reads the source documents and SPEC.md (blue) and writes the wiki into okf/ (blue), the only content it may change. Skills and the linter (teal) support it — four of them survey the source markdown and wiki, curate-okf maintains its nodes and indexes, and the linter must pass before a run ends. Session state (blue) is mounted from the host, so transcripts outlive the sandbox. Model calls leave the VM only through the sbx credential proxy (teal), which injects the API key; OpenRouter routes them to DeepInfra or other providers (gray).

Contents

Quickstart

md2okf needs sbx, which runs the sandbox, and uv, which installs the tool. Pi, the default agent, also needs an OpenRouter API key.

uv tool install md2okf       # Install from PyPI
md2okf --version

md2okf -v my-document.md     # The wiki lands in ./okf
md2okf -v md/ -o okf/

uv installs the tool from PyPI, so there is no need to clone the repository. Point md2okf at a single Markdown file or a folder of Markdown files, and it compiles them into an OKF wiki. The first run builds the sandbox; later runs reuse it. -v turns on verbose mode, which also shows the agent's tool calls and messages. Leave it out for a quieter run that prints only progress.

uvx md2okf -v my-document.md
uvx md2okf -v md/ -o okf/

Alternatively, skip the installation and run the tool directly with uvx.

MD2OKF_AGENT=claude md2okf -v md/ -o okf/     # Claude Code
MD2OKF_AGENT=codex md2okf -v md/ -o okf/      # Codex

Pi is the default agent. To compile with Claude Code or Codex instead, set MD2OKF_AGENT; each agent needs its own credential first. See Choosing an agent for the sign-in steps.

md2okf --shell               # Interactive shell at the wiki root
md2okf --agent               # Interactive agent session

The first flag opens a shell inside the sandbox, at the wiki root; the second opens an interactive session with the agent. Both are for inspecting the sandbox. Changes made in either session stay in the sandbox's working copy: they are not copied to okf/, and the next compile replaces them.

Install sbx

Install the sbx command-line tool, version 0.48.0 or newer, and sign in. md2okf refuses an older sbx.

macOS:

brew trust docker/tap
brew install docker/tap/sbx
sbx login

Linux:

curl -fsSL https://get.docker.com | sudo REPO_ONLY=1 sh
sudo apt-get install docker-sbx
sudo usermod -aG kvm "$USER" && newgrp kvm
sbx login

Set up the OpenRouter key

sbx keeps the key out of the virtual machine. It holds the real key on the host and swaps it into requests at its proxy, so inside the sandbox $OPENROUTER_API_KEY reads proxy-managed. Store the key with sbx once:

export OPENROUTER_API_KEY=sk-or-...
echo "$OPENROUTER_API_KEY" | sbx secret set openrouter

The secret is global, so it reaches md2okf-pi, the sandbox Pi runs in; each agent gets its own, called md2okf-<agent>. The export only passes the key to the sbx command: md2okf reads it from sbx secret, never from your shell environment.

Further documentation

Guide Covers
Usage What you can compile, reading the output, the wiki's layout, every CLI flag and exit code
Configuration Choosing an agent, credentials for Claude Code and Codex, models and providers
Architecture The run loop, the sandbox's mounts, credentials, session state, the repository layout
Contributing Lint, tests, the helper CLIs, releasing

License

Released under the MIT License.

Metadata

Release files for md2okf 0.3.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 md2okf 0.3.1
File Size Uploaded Provenance
md2okf-0.3.1.tar.gz 446.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 618.4 kB

Release files / md2okf-0.3.1.tar.gz

Download URL md2okf-0.3.1.tar.gz
Size 446.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f1462082432a29ba6edd200110745ff93e90423a4d06aac35199f841980d982b
BLAKE2b-256 checksum
How to use checksums
dc3fa5d51a78d419062ccfe1abc8c7443de8feb7ae0b523ee87c4ab83f0cb4d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / md2okf-0.3.1-py3-none-any.whl

Download URL md2okf-0.3.1-py3-none-any.whl
Size 172.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d1b2ce83c028a2ab07ee07bf23ee678c6545d0fe7af8ca3c76f7a2a8c4a2296
BLAKE2b-256 checksum
How to use checksums
b99844b4d62b8317d27956d07f380c262896b402923a33654cfa498abf2ee58b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for md2okf 0.3.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.

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