okf-open-knowledge-format
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpen Knowledge Format (OKF)
Open Knowledge Format (OKF)
OKF is a vendor-neutral, open spec (v0.1, announced June 12, 2026 by Sam McVeety & Amir Hormati at Google Cloud) for representing knowledge as a directory of markdown files with YAML frontmatter. No SDK required — if you can a file, you can read OKF.
catIt formalizes the "LLM Wiki" pattern (Karpathy's gist) into an interoperable format: wikis written by different producers can be consumed by different agents without translation.
For the full spec, see references/spec-v01.md.
OKF是一种厂商中立的开放规范(v0.1版本,由Sam McVeety和Amir Hormati于2026年6月12日在Google Cloud发布),用于将知识表示为带有YAML前置元数据的Markdown文件目录。无需SDK——只要你能使用命令读取文件,就能读取OKF格式的内容。
cat它将“LLM Wiki”模式(Karpathy的gist)正式化为一种可互操作的格式:不同生产者编写的wiki可被不同Agent直接使用,无需转换。
完整规范请参阅references/spec-v01.md。
Design Principles
设计原则
- Minimally opinionated — Only is required. The spec defines interoperability surface, not content model.
type - Producer/consumer independence — Who writes and who reads are decoupled. Human-authored bundles feed agents; LLM-generated bundles are browsed by humans.
- Format, not platform — No cloud, SDK, or vendor dependency. Value comes from how many parties speak it.
- 最低限度约束——仅字段为必填项。该规范定义的是互操作层面,而非内容模型。
type - 生产者/消费者解耦——编写者和读取者相互独立。人工编写的bundle可供给Agent使用;LLM生成的bundle可供人类浏览。
- 仅定义格式,不绑定平台——无需依赖云服务、SDK或特定厂商。其价值在于有多少参与者采用该格式。
Key Terminology
关键术语
- Bundle — A directory tree of files. The unit of distribution (git repo, tarball, or subdirectory).
.md - Concept — One markdown file = one unit of knowledge (table, metric, playbook, API, etc.)
- Concept ID — File path within the bundle, minus suffix. Example:
.md→ IDtables/users.mdtables/users - Frontmatter — YAML block between delimiters at file top.
--- - Body — Everything after the frontmatter. Standard markdown.
- Link — Standard markdown link expressing a relationship between concepts.
- Citation — Link to an external source backing a claim in the body.
- Bundle——包含文件的目录树。是分发的基本单元(Git仓库、压缩包或子目录)。
.md - Concept——一个Markdown文件对应一个知识单元(表格、指标、操作手册、API等)。
- Concept ID——bundle内的文件路径,去除后缀。示例:
.md→ ID为tables/users.mdtables/users - Frontmatter——文件顶部位于分隔符之间的YAML块。
--- - Body——前置元数据之后的所有内容,为标准Markdown格式。
- Link——表示Concept之间关联关系的标准Markdown链接。
- Citation——指向正文内容中论点的外部来源的链接。
Quick Reference — Frontmatter Fields
快速参考——前置元数据字段
| Field | Required? | Description |
|---|---|---|
| YES | Kind of concept (free-form string, e.g. |
| Recommended | Human-readable display name |
| Recommended | One-sentence summary |
| Recommended | URI identifying the underlying asset (omit for abstract concepts) |
| Optional | YAML list for cross-cutting categorization |
| Optional | ISO 8601 datetime of last meaningful change |
Additional producer-defined keys are allowed. Never reject unknown fields.
| 字段 | 是否必填? | 描述 |
|---|---|---|
| 是 | Concept的类型(自由格式字符串,例如 |
| 推荐 | 便于人类阅读的显示名称 |
| 推荐 | 一句话摘要 |
| 推荐 | 标识底层资产的URI(抽象Concept可省略) |
| 可选 | 用于跨领域分类的YAML列表 |
| 可选 | 最后一次重要变更的ISO 8601格式时间戳 |
允许添加生产者自定义的字段,不得拒绝未知字段。
Reserved Filenames
保留文件名
| File | Purpose | Has frontmatter? |
|---|---|---|
| Directory listing for progressive disclosure | NO* |
| Change history, newest first | NO |
*Exception: bundle-root MAY have frontmatter with to declare spec version.
index.mdokf_version: "0.1"| 文件 | 用途 | 是否包含前置元数据? |
|---|---|---|
| 用于渐进式展示的目录列表 | 否* |
| 变更历史,按最新优先排序 | 否 |
*例外:bundle根目录下的可包含前置元数据,其中用于声明规范版本。
index.mdokf_version: "0.1"Conventional Body Headings
常规正文标题
| Heading | When to use |
|---|---|
| Data assets — describe columns/fields |
| Show concrete usage (code blocks, queries) |
| List external sources backing claims (numbered) |
| 标题 | 使用场景 |
|---|---|
| 数据资产——描述列/字段 |
| 展示具体用法(代码块、查询语句等) |
| 列出支撑论点的外部来源(编号形式) |
Create a Bundle
创建Bundle
When the user wants to create an OKF bundle from scratch:
当用户想要从零开始创建OKF bundle时:
1. Determine scope and structure
1. 确定范围与结构
Ask: What knowledge are we capturing? (tables, metrics, APIs, playbooks, etc.)
Organize into a directory tree that makes sense for the domain.
询问:我们要捕获哪些知识?(表格、指标、API、操作手册等)
按照领域逻辑组织为目录树结构。
2. Create concept documents
2. 创建Concept文档
Each concept = one file. Minimal conformant example:
.mdmarkdown
---
type: Metric
title: Monthly Recurring Revenue
description: Sum of all active subscription revenue normalized to monthly.
tags: [revenue, saas]
timestamp: 2026-06-13T10:00:00Z
---每个Concept对应一个文件。符合规范的最简示例:
.mdmarkdown
---
type: Metric
title: Monthly Recurring Revenue
description: Sum of all active subscription revenue normalized to monthly.
tags: [revenue, saas]
timestamp: 2026-06-13T10:00:00Z
---Monthly Recurring Revenue (MRR)
Monthly Recurring Revenue (MRR)
Definition
Definition
Sum of all active subscriptions normalized to a monthly amount.
Excludes one-time fees and overages.
Sum of all active subscriptions normalized to a monthly amount.
Excludes one-time fees and overages.
Formula
Formula
MRR = Σ(active_subscription_monthly_value)MRR = Σ(active_subscription_monthly_value)Related
Related
- Churn Rate uses MRR as denominator
- ARR = MRR × 12
For more examples across domains, see [references/examples.md](references/examples.md).- Churn Rate uses MRR as denominator
- ARR = MRR × 12
更多跨领域示例请参阅[references/examples.md](references/examples.md)。3. Cross-link concepts
3. 交叉链接Concept
Use standard markdown links. Two forms:
- Absolute (bundle-relative, starts with ):
/— preferred (stable when files move)[customers](/tables/customers.md) - Relative:
[churn](./churn.md)
Links assert relationships. The kind of relationship is conveyed by surrounding prose, not by the link syntax. Broken links are explicitly permitted — they represent knowledge not yet written.
使用标准Markdown链接,有两种形式:
- 绝对路径(相对于bundle,以开头):
/—— 推荐(文件移动时仍保持稳定)[customers](/tables/customers.md) - 相对路径:
[churn](./churn.md)
链接用于声明关联关系,关联类型由周围的文本表述,而非链接语法。明确允许存在断链——断链代表尚未编写的知识。
4. Generate index.md
4. 生成index.md
Place in any directory for progressive disclosure. No frontmatter. Format:
markdown
undefined可在任意目录下创建,用于渐进式展示,无需前置元数据。格式如下:
markdown
undefinedMetrics
Metrics
- MRR - Monthly recurring revenue
- Churn - Monthly churn rate
- NPS - Net Promoter Score
Entries should include the description from the linked concept's frontmatter.- MRR - Monthly recurring revenue
- Churn - Monthly churn rate
- NPS - Net Promoter Score
条目应包含链接Concept的前置元数据中的描述信息。5. Generate log.md (optional)
5. 生成log.md(可选)
Chronological change history, newest first, ISO 8601 date headings:
markdown
undefined按时间顺序排列的变更历史,最新优先,使用ISO 8601格式日期作为标题:
markdown
undefinedUpdate Log
Update Log
2026-06-13
2026-06-13
- Creation: Added MRR, Churn, and NPS metrics.
- Creation: Established directory structure.
- Creation: Added MRR, Churn, and NPS metrics.
- Creation: Established directory structure.
2026-06-10
2026-06-10
- Initialization: Bundle created.
The bold leading word (`**Update**`, `**Creation**`, `**Deprecation**`) is convention, not requirement.- Initialization: Bundle created.
开头的加粗词汇(`**Update**`、`**Creation**`、`**Deprecation**`)是惯例,而非强制要求。6. Declare version (optional)
6. 声明版本(可选)
Bundle-root may include frontmatter declaring the spec version:
index.mdmarkdown
---
okf_version: "0.1"
---Bundle根目录下的可包含前置元数据以声明规范版本:
index.mdmarkdown
---
okf_version: "0.1"
---My Knowledge Bundle
My Knowledge Bundle
- Tables - Database tables
- Metrics - Business KPIs
This is the only place frontmatter is permitted in an `index.md`.- Tables - Database tables
- Metrics - Business KPIs
这是`index.md`中唯一允许包含前置元数据的场景。7. Distribution
7. 分发
A bundle can be distributed as:
- A git repository (recommended — history, attribution, diffs)
- A tarball or zip archive
- A subdirectory within a larger repository
Bundle可通过以下方式分发:
- Git仓库(推荐——包含历史记录、归属信息、差异对比)
- Tarball或Zip压缩包
- 大型仓库中的子目录
8. Verify conformance
8. 验证合规性
Three rules — all must pass:
- Every non-reserved file has parseable YAML frontmatter
.md - Every frontmatter has a non-empty field
type - Reserved files (,
index.md) follow their defined structure when presentlog.md
需满足三条规则,全部通过才算合规:
- 所有非保留文件均包含可解析的YAML前置元数据
.md - 所有前置元数据均包含非空的字段
type - 保留文件(、
index.md)在存在时需遵循其定义的结构log.md
Validate a Bundle
验证Bundle
Preferred: okflint (when available)
首选方案:okflint(若可用)
okflint is a dedicated Python linter for OKF bundles with 18 rules across 3 tiers (OKF core, profile, hygiene). If installed, always prefer it over the built-in bash script.
Agent behavior: Before validating, check if okflint is installed (). If NOT installed, ask the user:
command -v okflint"okflint (linter dedicado para OKF com 18 regras, profiles via manifesto e suporte a wikilinks) não está instalado. Quer que eu instale? Opções:
(recomendado, isolado)uv tool install okflintpip install okflint- Seguir sem ele (validação básica com o script bash embutido)"
If the user agrees to install:
bash
undefinedokflint是一款专门用于OKF bundle的Python检查工具,包含3个层级(OKF核心、配置文件、卫生检查)的18条规则。若已安装,优先使用它而非内置的bash脚本。
Agent行为:验证前,检查okflint是否已安装(执行)。若未安装,询问用户:
command -v okflint"okflint(专为OKF设计的检查工具,包含18条规则、通过清单实现配置文件支持、支持维基链接)未安装。是否需要安装?选项:
(推荐,隔离环境安装)uv tool install okflintpip install okflint- 不安装,使用内置bash脚本进行基础验证"
若用户同意安装:
bash
undefinedOption 1: uv (recommended — installs isolated, no venv needed)
选项1:uv(推荐——隔离安装,无需虚拟环境)
uv tool install okflint
uv tool install okflint
Option 2: pip (installs in current environment)
选项2:pip(安装到当前环境)
pip install okflint
pip install okflint
Verify installation
验证安装
okflint --version
After installation (or if already available):
```bashokflint --version
安装完成后(或已安装时):
```bashFull validation with manifest (if okf-base.yaml exists)
若存在okf-base.yaml,使用清单进行完整验证
if [ -f okf-base.yaml ]; then
okflint validate --manifest okf-base.yaml ./bundle/
else
Core OKF validation only (no manifest needed)
okflint validate ./bundle/
fi
**okflint advantages over the built-in script:**
- Manifest-driven profiles (enforce custom required fields, status vocabularies, per-type constraints)
- Wikilink resolution against full Obsidian vault
- JSON output (`--json`) for CI pipeline parsing
- Detects broken markdown links and ambiguous wikilinks
- Exit codes: `0` = pass, `1` = conformance failure, `2` = bad manifestif [ -f okf-base.yaml ]; then
okflint validate --manifest okf-base.yaml ./bundle/
else
仅进行OKF核心验证(无需清单)
okflint validate ./bundle/
fi
**okflint相较于内置脚本的优势**:
- 基于清单的配置文件(强制自定义必填字段、状态词汇、按类型约束)
- 针对完整Obsidian库解析维基链接
- 支持JSON输出(`--json`),便于CI流水线解析
- 检测无效Markdown链接和模糊维基链接
- 退出码:`0`=通过,`1`=合规失败,`2`=清单错误Fallback: built-in bash script
备选方案:内置bash脚本
When okflint is not installed, use scripts/validate.sh which checks the 3 core conformance rules.
When asked to validate, check the 3 conformance rules. Report:
✅ PASS: 12/12 concept files have valid frontmatter with type field
✅ PASS: index.md follows list structure (no frontmatter)
✅ PASS: log.md uses ISO 8601 date headings, newest first
⚠ WARNING: 3 files missing 'description' field (recommended)
⚠ WARNING: 2 broken cross-links (permitted but worth noting)For a script-based check, see scripts/validate.sh.
当okflint未安装时,使用scripts/validate.sh检查3条核心合规规则。
验证时,检查这3条规则,并输出如下报告:
✅ 通过:12/12个Concept文件均包含带type字段的有效前置元数据
✅ 通过:index.md符合列表结构(无前置元数据)
✅ 通过:log.md使用ISO 8601格式日期标题,按最新优先排序
⚠ 警告:3个文件缺少'description'字段(推荐添加)
⚠ 警告:2个无效交叉链接(允许存在,但值得注意)基于脚本的检查请参阅scripts/validate.sh。
Errors (conformance failures)
错误(合规失败)
- : File
E1has no YAML frontmatter{path} - : File
E2has frontmatter but no{path}field (or empty)type - : Reserved file
E3has unexpected structure{path}
- :文件
E1无YAML前置元数据{path} - :文件
E2有前置元数据但无{path}字段(或为空)type - :保留文件
E3结构不符合预期{path}
Warnings (non-blocking, spec allows these)
警告(非阻塞,规范允许)
- : Missing recommended field
W1ortitledescription - : Broken cross-link
W2in{link}{file} - : No
W3fieldtimestamp - : No
W4in directoryindex.md{dir} - :
W5dates not in ISO 8601 formatlog.md
Consumers MUST NOT reject a bundle because of: missing optional fields, unknown type values, unknown frontmatter keys, broken links, or missing index files.
- :缺少推荐字段
W1或titledescription - :文件
W2中存在无效链接{file}{link} - :无
W3字段timestamp - :目录
W4中无{dir}index.md - :
W5中的日期非ISO 8601格式log.md
消费者不得因以下原因拒绝bundle:缺少可选字段、未知type值、未知前置元数据字段、断链或缺少index文件。
Enrich Concepts
增强Concept
When the user has existing OKF concepts that need enrichment:
当用户已有OKF Concept需要增强时:
Add schema section
添加Schema章节
For data assets, add with a columns table:
# Schemamarkdown
undefined对于数据资产,添加章节并包含列信息表格:
# Schemamarkdown
undefinedSchema
Schema
| Column | Type | Description |
|---|---|---|
| STRING | Unique identifier |
| STRING | FK to customers |
undefined| Column | Type | Description |
|---|---|---|
| STRING | Unique identifier |
| STRING | FK to customers |
undefinedAdd examples section
添加Examples章节
For APIs, queries, or tools, add with fenced code blocks showing usage.
# Examples对于API、查询语句或工具,添加章节并包含代码块展示用法。
# ExamplesAdd citations
添加Citations
When claims reference external sources, add at the bottom, numbered:
# Citationsmarkdown
undefined当论点引用外部来源时,在底部添加章节,采用编号形式:
# Citationsmarkdown
undefinedCitations
Citations
[1] Official docs
[2] Internal runbook
Citations may be absolute URLs, bundle-relative paths, or paths into a `references/` subdirectory.[1] Official docs
[2] Internal runbook
引用可以是绝对URL、相对于bundle的路径,或指向`references/`子目录的路径。Add cross-links
添加交叉链接
Weave links into natural prose. Don't create a standalone "links" section — express relationships in context where they're meaningful.
将链接融入自然文本中,不要创建独立的“链接”章节——在有意义的上下文环境中表述关联关系。
Fill recommended fields
补充推荐字段
If , , , or are missing, add them. Derive values from body content when possible.
titledescriptiontagstimestamp若缺少、、或字段,补充这些信息。尽可能从正文内容中推导值。
titledescriptiontagstimestampEnrichment workflow reference
增强流程参考
The official enrichment agent follows this pattern — apply the same logic manually:
- Start with metadata-only docs (just frontmatter + minimal body)
- Add schema/structure from source system
- Add citations from authoritative documentation
- Weave cross-links based on discovered relationships (FKs, shared tags, join paths)
- Generate files for progressive disclosure
index.md
官方增强Agent遵循以下模式——手动操作时可应用相同逻辑:
- 从仅含元数据的文档开始(仅前置元数据+极简正文)
- 从源系统添加Schema/结构信息
- 从权威文档添加引用
- 根据发现的关联关系(外键、共享标签、关联路径)添加交叉链接
- 生成用于渐进式展示的文件
index.md
Convert Sources to OKF
转换为OKF格式
For detailed conversion guides, see references/conversion.md.
详细转换指南请参阅references/conversion.md。
Quick rules
快速规则
Notion export: Properties → frontmatter. Remove UUID suffixes from filenames. Convert Notion links → relative markdown links.
Obsidian vault: Convert → . Ensure field exists. Move inline to frontmatter.
[[wikilinks]][title](./file.md)type#tagsCSV/spreadsheet: Each row = one concept. Map columns to frontmatter fields. First column = filename.
Notion导出:属性→前置元数据。移除文件名中的UUID后缀。将Notion链接转换为相对Markdown链接。
Obsidian库:将转换为。确保存在字段。将行内移至前置元数据中。
[[wikilinks]][title](./file.md)type#tagsCSV/电子表格:每行对应一个Concept。将列映射到前置元数据字段。第一列为文件名。
Guardrails
约束规则
- NEVER invent data. If you don't know the correct , ask. If you don't have schema info, leave it out. No fabricated URLs or column names.
type - Preserve unknown fields. OKF explicitly allows extension. Don't delete fields you don't recognize.
- Don't impose taxonomy. Type values are free-form strings. Suggest descriptive values but never reject a bundle for having unexpected types.
- Broken links are OK. The spec explicitly permits them — they represent not-yet-written knowledge.
- Minimal by default. Generate only (required) + recommended fields that are warranted. Don't pad with empty values.
type - Ask before assuming. If the domain is unclear, ask what types and structure make sense.
- 绝不编造数据。若不知道正确的值,询问用户。若无Schema信息,留空。不得伪造URL或列名。
type - 保留未知字段。OKF明确允许扩展,不得删除无法识别的字段。
- 不强制分类体系。Type值为自由格式字符串。可建议描述性值,但不得因type值不符合预期而拒绝bundle。
- 断链是允许的。规范明确允许断链——断链代表尚未编写的知识。
- 默认保持极简。仅生成必填的字段+有必要的推荐字段。不得填充空值。
type - 先询问再假设。若领域不明确,询问用户哪种类型和结构更合理。
Serve via Google Cloud Knowledge Catalog
通过Google Cloud Knowledge Catalog提供服务
Google Cloud's Knowledge Catalog natively ingests OKF bundles and serves them to agents. This is the enterprise path — optional but powerful.
Google Cloud的Knowledge Catalog原生支持导入OKF bundle,并为Agent提供服务。这是企业级方案——可选但功能强大。
kcmd CLI (Metadata as Code)
kcmd CLI(元数据即代码)
kcmdbash
undefinedkcmdbash
undefinedInitialize from BigQuery dataset
从BigQuery数据集初始化
kcmd init --bigquery-dataset <project>.<dataset>
kcmd init --bigquery-dataset <project>.<dataset>
Pull current state from catalog
从Catalog拉取当前状态
kcmd pull
kcmd pull
Push local changes
推送本地变更
kcmd push --dry-run
kcmd push
Also ships as an **MCP server** for agent integration:
```json
{
"mcpServers": {
"kc-mac": {
"command": "kcmd",
"args": ["mcp", "--path", "/path/to/root"]
}
}
}MCP tools: , , , , .
pullpushlist-entrieslookup-entrymodify-entrykcmd push --dry-run
kcmd push
它还可作为**MCP服务器**供Agent集成:
```json
{
"mcpServers": {
"kc-mac": {
"command": "kcmd",
"args": ["mcp", "--path", "/path/to/root"]
}
}
}MCP工具命令:、、、、。
pullpushlist-entrieslookup-entrymodify-entryReference Enrichment Agent
参考增强Agent
The official enrichment agent (Python, ADK, Gemini) auto-generates OKF bundles from BigQuery metadata. Two-pass architecture:
- BQ pass — one OKF doc per table/view from metadata
- Web pass — LLM crawls seed URLs and for each page decides to:
- (a) Enrich existing concepts with citations/schemas
- (b) Mint a new doc
references/<slug> - (c) Skip irrelevant content
Controls: , , , .
--web-seed-file--web-max-pages--web-allowed-host--no-webWhen to mention this to users: If they're enriching BigQuery datasets, point them to the reference agent. If they want enterprise catalog integration, point to kcmd and the ingest demo.
官方增强Agent(Python、ADK、Gemini)可从BigQuery元数据自动生成OKF bundle。采用两阶段架构:
- BQ阶段——从元数据为每个表/视图生成一个OKF文档
- Web阶段——LLM爬取种子URL,对每个页面决定:
- (a) 增强:为现有Concept添加引用/Schema
- (b) 新建:创建一个新的文档
references/<slug> - (c) 跳过:忽略无关内容
控制参数:、、、。
--web-seed-file--web-max-pages--web-allowed-host--no-webOutput Format
输出格式
When creating a bundle, present results as:
- Directory tree showing the full structure
- Each file's content in fenced code blocks
- Conformance check confirming the bundle passes the 3 rules
saas-metrics/
├── index.md
├── log.md
├── mrr.md
├── churn.md
└── nps.mdThen show each file, then confirm: "Bundle is OKF v0.1 conformant ✅"
创建bundle时,结果呈现方式如下:
- 目录树展示完整结构
- 每个文件的内容放在代码块中
- 合规性检查确认bundle通过3条规则
saas-metrics/
├── index.md
├── log.md
├── mrr.md
├── churn.md
└── nps.md然后展示每个文件内容,最后确认:"Bundle符合OKF v0.1规范 ✅"