1. OKF 的官方定位
OKF 是一种开放的、对人类和 Agent 友好的知识表示格式,用于表示围绕数据和系统的元数据、上下文和经过整理的洞察。
a directory of markdown files with YAML frontmatter
因此,OKF 不是数据库、不是查询引擎、不是知识图谱系统,也不是某个工具链本身。它首先是一种文件格式和组织约定。
2. 官方目标与非目标
官方目标
- 定义一种
enrichment agents可以写入的通用格式。 - 指导
consumption agents如何读取和遍历知识。 - 促进知识在系统和组织之间交换。
- 标准化少量必须存在的字段,使内容可以被有意义地消费。
官方非目标
- 不定义固定的 concept type 分类体系。
- 不规定存储、服务或查询基础设施。
- 不替代 OpenAPI、Protobuf、Avro、数据库 schema 等领域专用格式。
3. 核心术语
| 术语 | 中文理解 | 关键点 |
|---|---|---|
Knowledge Bundle | 知识包 | 自包含、层级化的知识文档集合,是分发单位。 |
Concept | 概念 | Bundle 内的单个知识单元,由一个 Markdown document 表示。 |
Concept ID | 概念标识 | 由 concept 文件路径去掉 .md 后缀得到。 |
Frontmatter | 顶部 YAML 元数据块 | 由 --- 包围,位于 Markdown 文件顶部。 |
Body | 正文 | frontmatter 后面的 Markdown 内容。 |
Link | 概念链接 | 标准 Markdown 链接,用于表达 concept 之间的关系。 |
Citation | 来源引用 | 指向外部来源,用于支持正文中的声明。 |
4. Bundle 结构
path/to/bundle/
├── index.md
├── log.md
├── <concept>.md
└── <subdirectory>/
├── index.md
├── <concept>.md
└── <subdirectory>/
└── …
Bundle 可以被分发为 Git repository、tarball、zip archive,或 larger repository 中的 subdirectory。
保留文件名
| 文件名 | 作用 |
|---|---|
index.md | Directory listing,用于目录索引和 progressive disclosure。 |
log.md | Update history,用于记录更新历史。 |
index.md 和 log.md 不能作为 concept document;其他 .md 文件都是 concept documents。5. Concept Document 结构
每个 concept document 是 UTF-8 Markdown 文件,由 YAML frontmatter 和 Markdown body 两部分组成。
---
type: <Type name> # REQUIRED
title: <Optional display name>
description: <Optional one-line summary>
resource: <Optional canonical URI for the underlying asset>
tags: [<tag>, <tag>, …] # Optional
timestamp: <ISO 8601 datetime> # Optional last-modified time
# … other producer-defined key/value pairs
---
| 字段 | 官方性质 | 说明 |
|---|---|---|
type | 必需 | 标识 concept 种类。 |
title | 推荐 | 人类可读展示名。 |
description | 推荐 | 一句话摘要,用于索引、搜索片段和预览。 |
resource | 推荐 | 底层资产的 canonical URI。 |
tags | 推荐 | 用于横向分类的短字符串列表。 |
timestamp | 推荐 | 最后一次有意义修改的 ISO 8601 时间。 |
6. type 字段
type 是 OKF 中最重要的字段之一。它是一个短字符串,用于识别 concept 的种类。Consumer 可以用它做路由、过滤和展示。
BigQuery TableBigQuery DatasetAPI EndpointMetricPlaybookReference
type 字段必需,但 type 值没有官方中央注册表。7. 官方示例
绑定具体资源的 Concept
---
type: BigQuery Table
title: Customer Orders
description: One row per completed customer order across all channels.
resource: https://console.cloud.google.com/bigquery?p=acme&d=sales&t=orders
tags: [sales, orders, revenue]
timestamp: 2026-05-28T14:30:00Z
---
# Schema
| Column | Type | Description |
|---------------|-----------|------------------------------------------|
| `order_id` | STRING | Globally unique order identifier. |
| `customer_id` | STRING | Foreign key into [customers](/tables/customers.md). |
| `total_usd` | NUMERIC | Order total in US dollars. |
| `placed_at` | TIMESTAMP | When the customer submitted the order. |
# Joins
Joined with [customers](/tables/customers.md) on `customer_id`.
# Citations
[1] [BigQuery table schema](https://console.cloud.google.com/bigquery?p=acme&d=sales&t=orders)
不绑定具体资源的 Concept
---
type: Playbook
title: Incident response — data freshness alert
description: Steps to triage a freshness alert on the orders pipeline.
tags: [oncall, incident]
timestamp: 2026-04-12T09:00:00Z
---
# Trigger
A freshness alert fires when `orders` lags more than 30 minutes behind
its expected SLA. See the [orders table](/tables/orders.md).
# Steps
1. Check the [ingestion job dashboard](https://example.com/dash).
2. …
8. Links / Index / Log / Citations
Concepts 可以用标准 Markdown links 互相连接。推荐形式是以 / 开头的 bundle-relative absolute links。
See the [customers table](/tables/customers.md)
Link 表示 relationship,但具体关系类型由周围文字说明。Graph view 通常视为 directed untyped edges。
index.md 用来枚举目录内容,支持 progressive disclosure。Producer 可以自动生成,consumer 也可以动态合成。
log.md 用于记录更新历史。日期 heading 必须使用 YYYY-MM-DD。
当正文声明来自外部材料时,应在底部 # Citations 中列出来源并编号。
Consumers 必须容忍 broken links。断链不使 bundle malformed。
9. OKF Conformance
一个 bundle 符合 OKF v0.1,如果满足三条硬性要求:
- 每个非保留
.md文件都有可解析的 YAML frontmatter。 - 每个 frontmatter 都包含非空
type字段。 index.md和log.md在出现时遵循官方对应结构。
OKF v0.1 hard conformance =
非保留 .md 有可解析 YAML frontmatter
frontmatter 有非空 type
reserved files 出现时结构正确
10. AI/Agent 如何生成 OKF
OKF 设计上支持由人编写,也支持由 Agent 生成。
重要认知:详细生成要求不应主要由用户手写,而应由 Agent 读取官方 SPEC 和源资料后自动分析制定。用户主要提供源资料、目标用途和关键边界。
11. 工程实践素材:校验与可视化
以下工具脚本属于工程实践辅助能力,需要明确它们不是 OKF 协议本体。
| 文件 | 定位 | 作用 |
|---|---|---|
tools/okf_bundle_common.py | 项目级共享解析模块 | 解析 frontmatter、links、citations、log,统一 validator 和 visualizer 的解析逻辑。 |
tools/validate_okf_bundle.py | 项目级 validator | 按 spec、reference、project 三层检查 bundle。 |
tools/visualize_okf_bundle.py | 项目级 visualizer wrapper / extended viewer | 辅助浏览 concepts、links、body、frontmatter、citations、log 等。 |
12. 官方协议、官方参考实现、项目增强工具
OKF SPEC
↓
Official reference implementation
↓
Project tooling
OKFDocument.validate()。它可能比 SPEC 更严格,但不等同于 SPEC hard conformance。一句话总结:SPEC 决定什么叫 OKF;官方参考实现展示一种官方代码实践;项目工具帮助生产、校验和浏览,但不构成协议要求。
13. 官方 visualizer 的实现观察
运行官方 visualizer 后,曾出现 37 concept(s), 0 edge(s) 的输出。
- 官方 visualizer 当前只跳过
index.md,没有跳过log.md,所以会把log.md也计入 concept。 - 官方 visualizer 当前忽略以
/开头的 bundle-relative absolute links,所以没有生成 edges。
14. 最短记忆版
- OKF 是开放的、对人类和 Agent 友好的知识表示格式。
- OKF 的基本形态是 Markdown 文件目录树 + YAML frontmatter。
Knowledge Bundle是分发单位,Concept是 bundle 内的单个知识单元。- OKF v0.1 的硬性合规要求很少:非保留
.md有 frontmatter、type非空、reserved files 结构正确。 title、description、resource、tags、timestamp是推荐字段,不是合规必需项。- Links 是标准 Markdown links,推荐 bundle-relative absolute links,通常表示有方向、无显式类型的关系。
- Citations 用来支持正文中的外部来源声明。
- OKF 不规定工具、存储、查询系统,也不定义固定 type taxonomy。
- AI/Agent 可以生成 OKF bundle,但生成后应通过校验和人工 review。
- Validator 和 visualizer 是工程辅助工具,不是 OKF 协议本体。
15. 复习自测
点击按钮查看答案。建议先口头回答,再展开核对。
.md 文件都有可解析 YAML frontmatter;每个 frontmatter 都包含非空 type;index.md 和 log.md 出现时遵循官方结构。type 是官方固定枚举吗?type 字段是必需的,但 type 值没有中央注册表。Producer 应选择描述性、自解释的 type,consumer 必须优雅处理未知 type。/ 开头,相对于 bundle root 解析。当文档在子目录中移动时,这种链接形式更稳定。