@docmd/plugin-okf

中文文档
0.9.9发布于 2026/11/04MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 5.5万

Generate an Open Knowledge Format (OKF) bundle from your docmd site for AI agent consumption.

原始使用文档
文档目录6 节
  1. Output structure
  2. Options
  3. Per-page opt-out
  4. Type resolution precedence
  5. Documentation
  6. License

@docmd/plugin-okf

Generates an Open Knowledge Format (OKF) bundle at build time so your documentation is consumable by AI agents — Gemini, Claude, GPT, Cursor, and any tool that speaks the vendor-neutral OKF spec.

OKF represents organisational knowledge as a directory of markdown files with YAML frontmatter, plus a typed manifest (okf.yaml), an interactive graph viewer, and a machine-readable bundle summary. The bundle sits next to your site (e.g. site/okf/) so agents can be pointed at it directly.

// docmd.config.json

{
  "plugins": {
    "okf": {
      // config options, okf is enabled by default
    }
  }
}

Part of the docmd documentation engine.

Output structure

site/okf/                          # Always emitted
├── okf.yaml                       # Typed manifest (bundle summary)
├── index.md                       # Karpathy-style catalog grouped by type
├── concepts/
│   └── <slug>.md                 # One markdown file per page
└── _meta/
    ├── bundle.json                # JSON mirror of okf.yaml
    └── lint-report.txt            # Warnings produced during generation

# Emitted only when `plugins.okf.graph: true`
├── graph/                         # Interactive viewer (open /okf/graph/)
│   ├── index.html                 # Force-directed graph viewer
│   ├── graph.json                 # Graph data (nodes + edges)
│   ├── graph.js                   # Viewer runtime (vanilla, no CDN deps)
│   └── graph.css                  # Viewer styles (theme-aware)

Each concept file carries the OKF-required type field in frontmatter plus the original markdown body verbatim, so an agent can both navigate the manifest and read full pages.

Options

OptionTypeDefaultDescription
outputDirstring'okf'Bundle directory, relative to the site output.
bundleNamestringslugified config.titleName used inside okf.yaml and the graph viewer title.
defaultTypestring'concept'Type assigned to pages with no explicit type.
typeFieldstring'type'Frontmatter field name for OKF type.
warnOnMissingTypebooleantrueEmit a TUI warning for pages that fell back to defaultType.
includeFullMarkdownbooleantrueCopy raw .md body into each concept file.
graphbooleanfalseEmit a graph/ subdirectory containing index.html + graph.js + graph.css + graph.json. Opt-in since 0.8.8 — the OKF spec does not require a viewer, and shipping extra files by default adds noise to a clean bundle. The viewer is reachable at /okf/graph/ without a custom filename, and fetches graph.json from the same directory at runtime, so file:// also works.
localeStrategy'default-only' | 'folders' | 'mixed' | 'latest-only''default-only'Single-locale by default (the bundle contains only pages in the default locale). Set to 'folders' to nest concepts by locale id when i18n is enabled, or 'mixed' / 'latest-only' for the other strategies.
versionStrategy'folders' | 'mixed' | 'latest-only''latest-only'Nest concepts by version id when versioning is enabled.
excludePatternsstring[][]Additional glob patterns to skip on top of frontmatter.noindex / frontmatter.okf === false.

Per-page opt-out

Pages can opt out of the OKF bundle in two ways:

---
noindex: true   # also excludes from sitemap, llms.txt, etc.
---

---
okf: false       # only excludes from the OKF bundle
---

Type resolution precedence

For every page the plugin picks a type with this precedence:

  1. frontmatter.okf.type (nested)
  2. frontmatter.type (top-level)
  3. frontmatter.okfType (legacy)
  4. Path-prefix inference (e.g. /guides/foo → guide)
  5. defaultType (with a warning if warnOnMissingType)

The path-prefix map covers guides/, api/, reference/, concepts/, runbooks/, datasets/, metrics/, and tables/.

Documentation

See docs.docmd.io for full usage and API reference.

License

MIT

版本与发布记录

@docmd/plugin-okf 共发布 21 个版本,首次发布于 2026/06/26;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.9latest2026/11/049 天前
0.9.82026/10/1727 天前
0.9.72026/09/271 个月前
0.9.62026/09/211 个月前
0.9.52026/09/082 个月前
0.9.42026/08/242 个月前

关于 @docmd/plugin-okf 的常见问题

@docmd/plugin-okf 是什么?

Generate an Open Knowledge Format (OKF) bundle from your docmd site for AI agent consumption.

如何安装 @docmd/plugin-okf?

在项目目录运行 npm install @docmd/plugin-okf,或使用 pnpm add / yarn add / bun add。

@docmd/plugin-okf 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@docmd/plugin-okf 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@docmd/plugin-okf 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@docmd/plugin-okf 可以商用吗?

@docmd/plugin-okf 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@docmd/plugin-okf 的下载量有多少?

根据 npm 官方下载统计,@docmd/plugin-okf 在 2026/10/13 – 2026/11/11 这 30 天内被下载 55,364 次,日均约 1,845 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@docmd/plugin-okf 还在维护吗?

最新版本 0.9.9 发布于 2026/11/04(9 天前);至今共发布 21 个版本,其中过去 12 个月发布了 21 个;首次发布于 2026/06/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。