okf 1.12.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +296 -0
- data/README.md +94 -466
- data/lib/okf/bundle/folder.rb +48 -3
- data/lib/okf/bundle/graph.rb +12 -3
- data/lib/okf/bundle/linter.rb +470 -47
- data/lib/okf/bundle/reader.rb +47 -18
- data/lib/okf/bundle/references.rb +111 -0
- data/lib/okf/bundle/row_filter.rb +53 -0
- data/lib/okf/bundle/search.rb +20 -2
- data/lib/okf/bundle/validator/result.rb +6 -3
- data/lib/okf/bundle/validator.rb +267 -26
- data/lib/okf/bundle/writer.rb +1 -1
- data/lib/okf/bundle.rb +124 -8
- data/lib/okf/cli/catalog.rb +2 -2
- data/lib/okf/cli/command.rb +93 -19
- data/lib/okf/cli/dirs.rb +1 -1
- data/lib/okf/cli/files.rb +2 -2
- data/lib/okf/cli/index.rb +3 -3
- data/lib/okf/cli/lint.rb +70 -12
- data/lib/okf/cli/references.rb +97 -0
- data/lib/okf/cli/search.rb +23 -8
- data/lib/okf/cli/stats.rb +3 -39
- data/lib/okf/cli/tags.rb +6 -43
- data/lib/okf/cli/types.rb +1 -1
- data/lib/okf/cli/validate.rb +3 -3
- data/lib/okf/cli.rb +4 -1
- data/lib/okf/concept/file.rb +17 -2
- data/lib/okf/concept.rb +362 -10
- data/lib/okf/markdown/citations.rb +41 -4
- data/lib/okf/markdown/frontmatter.rb +1 -1
- data/lib/okf/markdown/links.rb +67 -7
- data/lib/okf/path.rb +17 -3
- data/lib/okf/render/graph/template.html.erb +173 -41
- data/lib/okf/render/graph.rb +11 -3
- data/lib/okf/safe_read.rb +50 -0
- data/lib/okf/server/app.rb +47 -15
- data/lib/okf/server/hub.rb +1 -1
- data/lib/okf/skill/SKILL.md +14 -12
- data/lib/okf/skill/playbooks/curate.md +8 -3
- data/lib/okf/skill/playbooks/doctor.md +3 -1
- data/lib/okf/skill/playbooks/maintain.md +7 -6
- data/lib/okf/skill/playbooks/menu.md +5 -4
- data/lib/okf/skill/playbooks/migrate.md +31 -8
- data/lib/okf/skill/playbooks/produce.md +16 -9
- data/lib/okf/skill/playbooks/search.md +2 -2
- data/lib/okf/skill/reference/SPEC.md +739 -187
- data/lib/okf/skill/reference/authoring.md +154 -35
- data/lib/okf/skill/reference/cli.md +160 -44
- data/lib/okf/skill/templates/attested-computation.md +41 -0
- data/lib/okf/skill/templates/concept.md +13 -6
- data/lib/okf/skill/templates/root-index.md +1 -1
- data/lib/okf/version.rb +1 -1
- data/lib/okf.rb +23 -2
- metadata +7 -3
- data/CODE_OF_CONDUCT.md +0 -10
data/README.md
CHANGED
|
@@ -1,200 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://okfgem.com">
|
|
3
|
-
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset=".github/hero-dark.png">
|
|
5
|
-
<img src=".github/hero-light.png" width="100%" alt="okf-gem, the Open Knowledge Format toolkit. Everything OKF, in one gem: author, curate, and consume your project's knowledge, with your agent. 100% local. Start at https://okfgem.com/#try. Three pieces in one install: the Agent Skill (the brain) authors, curates and consumes; the CLI/Lib (the muscle) validates, lints and does full-text search; the Graph (the dashboard) searches and explores it, live or static. Available from RubyGems, as a Docker image, and as a Claude Code plugin.">
|
|
6
|
-
</picture>
|
|
7
|
-
</a>
|
|
8
|
-
</p>
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="https://rubygems.org/gems/okf"><img src="https://img.shields.io/gem/v/okf" alt="Gem version"></a>
|
|
12
|
-
<a href="https://rubygems.org/gems/okf"><img src="https://img.shields.io/gem/dt/okf" alt="Downloads"></a>
|
|
13
|
-
<a href="https://github.com/serradura/okf-gem/pkgs/container/okf"><img src="https://img.shields.io/badge/ghcr.io-okf-2496ED?logo=docker&logoColor=white" alt="Docker image"></a>
|
|
14
|
-
<a href="https://github.com/serradura/okf-gem/actions/workflows/main.yml"><img src="https://github.com/serradura/okf-gem/actions/workflows/main.yml/badge.svg" alt="CI"></a>
|
|
15
|
-
<a href="https://github.com/serradura/okf-gem"><img src="https://img.shields.io/badge/ruby-%3E%3D%202.4-black" alt="Ruby >= 2.4"></a>
|
|
16
|
-
<a href="LICENSE.txt"><img src="https://img.shields.io/badge/license-Apache--2.0-blue" alt="License: Apache-2.0"></a>
|
|
17
|
-
<a href="lib/okf/skill/reference/SPEC.md"><img src="https://img.shields.io/badge/OKF-v0.1-6E56CF" alt="OKF v0.1"></a>
|
|
18
|
-
<a href="#claude-code-plugin"><img src="https://img.shields.io/badge/Claude%20Code-plugin-D97757" alt="Claude Code plugin"></a>
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
<p align="center">
|
|
22
|
-
<b><a href="https://okfgem.com">Site</a></b> ·
|
|
23
|
-
<b><a href="https://okfgem.com/docs/">Docs</a></b> ·
|
|
24
|
-
<b><a href="https://demo.okfgem.com">Live demo</a></b> ·
|
|
25
|
-
<b><a href="https://claude.okfgem.com">Claude plugin</a></b> ·
|
|
26
|
-
<b><a href="https://docker.okfgem.com">Docker image</a></b>
|
|
27
|
-
</p>
|
|
28
|
-
|
|
29
|
-
**okf-gem** (`okf` on RubyGems or Docker) gives your project's knowledge one
|
|
30
|
-
durable home in your repo, in Markdown your team and your agents both read: the
|
|
31
|
-
decisions and the reasoning an agent cannot re-derive from the code, versioned
|
|
32
|
-
beside the code they explain.
|
|
33
|
-
|
|
34
|
-
One install carries the whole workflow, and that is the point of a single gem:
|
|
35
|
-
|
|
36
|
-
- an **Agent Skill**, so your agent writes and curates the knowledge instead of you;
|
|
37
|
-
- a **CLI and Ruby library**, so it stays correct: validated, linted, and searchable in milliseconds;
|
|
38
|
-
- a **Graph**, so anyone can see the shape of what the team knows, live or as one static file you can host anywhere.
|
|
39
|
-
|
|
40
|
-
The package is **Agent Skill + CLI/Lib + Graph**. It runs 100% local, adds no
|
|
41
|
-
service to your stack, and does not define a new place to keep knowledge: it
|
|
42
|
-
gives you leverage over the Markdown you already have.
|
|
43
|
-
|
|
44
|
-
## Why OKF
|
|
45
|
-
|
|
46
|
-
Project knowledge (why a service exists, what a metric really measures, the
|
|
47
|
-
reasoning a schema encodes) lives scattered across wikis, code comments, and
|
|
48
|
-
whoever happened to be in the room, and an agent re-derives it every session. OKF
|
|
49
|
-
gives it one durable, diffable home, versioned next to the code it describes and
|
|
50
|
-
read from the same file by people and agents alike. [OKF][okf] is an open,
|
|
51
|
-
vendor-neutral format (Google Cloud, 2026); this gem is the Ruby-native way to
|
|
52
|
-
work with it.
|
|
53
|
-
|
|
54
|
-
[okf]: https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing
|
|
55
|
-
|
|
56
|
-
Knowledge already has several homes near an agent, and each holds a different
|
|
57
|
-
thing. None of the others is built for curated, durable team knowledge:
|
|
58
|
-
|
|
59
|
-
| | OKF bundle (this) | `CLAUDE.md` / `AGENTS.md` | Agent auto-memory | Wiki / Notion |
|
|
60
|
-
| ------------------------------ | ----------------------------------------------------- | -------------------------- | ------------------------ | ---------------- |
|
|
61
|
-
| Holds | curated team knowledge | standing instructions | what one agent picked up | human docs |
|
|
62
|
-
| Versioned with the code | ✅ | ✅ | ❌ | ❌ |
|
|
63
|
-
| Portable across agents | ✅ plain Markdown + YAML | ⚠️ per-harness conventions | ❌ per-agent store | ⚠️ export needed |
|
|
64
|
-
| Typed and queryable | ✅ frontmatter + graph | ❌ prose | ❌ | ⚠️ partially |
|
|
65
|
-
| Reviewed in PRs | ✅ | ✅ | ❌ implicit | ⚠️ rarely |
|
|
66
|
-
| Scales past one context window | ✅ progressive disclosure<br>(`okf index` + `search`) | ❌ loaded whole | ⚠️ partially | n/a |
|
|
67
|
-
| Checked by tooling | ✅ exit codes for CI<br>(`okf validate` + `lint`) | ❌ | ❌ | ❌ |
|
|
68
|
-
|
|
69
|
-
The last two rows are this gem's job. Scaling past one context window is
|
|
70
|
-
progressive disclosure — `okf index` reads the map, `okf search` pulls only the
|
|
71
|
-
concepts a task needs, so the bundle is never loaded whole. And drift never
|
|
72
|
-
hides here: the other homes have no detector, but `okf validate` and `lint` turn
|
|
73
|
-
a bundle's drift into findings you can gate on in CI.
|
|
74
|
-
|
|
75
|
-
## What a bundle looks like
|
|
76
|
-
|
|
77
|
-
A bundle is just a directory; each concept is one Markdown file whose path is its
|
|
78
|
-
id. This repo documents _itself_ in OKF, so the tree below is real:
|
|
1
|
+
# okf
|
|
79
2
|
|
|
80
|
-
|
|
81
|
-
.
|
|
82
|
-
├── index.md # progressive-disclosure map (root carries okf_version)
|
|
83
|
-
├── log.md # ISO-dated change history, newest first
|
|
84
|
-
├── overview.md
|
|
85
|
-
├── format/frontmatter.md
|
|
86
|
-
├── model/graph.md
|
|
87
|
-
└── capabilities/graph-server.md # one concept = one file
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
The only hard requirement is YAML frontmatter with a non-empty `type`; everything
|
|
91
|
-
else is optional and tolerated when missing. A concept (here the real
|
|
92
|
-
`capabilities/graph-server.md`, body trimmed) reads:
|
|
93
|
-
|
|
94
|
-
```markdown
|
|
95
|
-
---
|
|
96
|
-
type: Capability
|
|
97
|
-
title: Interactive graph server (server)
|
|
98
|
-
description: A self-contained HTML knowledge graph served over HTTP, and a mountable Rack app.
|
|
99
|
-
resource: lib/okf/server/app.rb
|
|
100
|
-
tags: [server, graph, rack, diagram]
|
|
101
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
# Overview
|
|
3
|
+
**The complete Open Knowledge Format toolkit: an agent skill, a CLI and library,
|
|
4
|
+
ranked search, and a live knowledge graph. 100% local.**
|
|
105
5
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
That bundle is this gem's own documentation. Clone the repo and run
|
|
110
|
-
`okf server .okf` to browse it as an interactive graph.
|
|
111
|
-
|
|
112
|
-
## Try it in four steps
|
|
6
|
+
[Site](https://okfgem.com) · [Docs](https://okfgem.com/docs/) ·
|
|
7
|
+
[Live demo](https://demo.okfgem.com) ·
|
|
8
|
+
[Project README](https://github.com/serradura/okf-gem#readme)
|
|
113
9
|
|
|
114
|
-
|
|
10
|
+
OKF (Open Knowledge Format) is portable project knowledge: Markdown files with
|
|
11
|
+
YAML frontmatter that both humans and agents read from one source. This gem is
|
|
12
|
+
the Ruby-native way to work with it — the decisions and the reasoning an agent
|
|
13
|
+
cannot re-derive from the code, versioned beside the code they explain.
|
|
115
14
|
|
|
116
|
-
|
|
15
|
+
One install carries the whole workflow: an **Agent Skill** so your agent writes
|
|
16
|
+
and curates the knowledge, a **CLI and Ruby library** so it stays correct, and a
|
|
17
|
+
**Graph** so anyone can see the shape of what the team knows.
|
|
117
18
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```
|
|
19
|
+
It adds no service to your stack. `rack`, `webrick` and `minifts` are the only
|
|
20
|
+
runtime dependencies, there is no native extension and no build step, and it runs
|
|
21
|
+
on every Ruby since **2.4** — the one your OS already ships.
|
|
122
22
|
|
|
123
|
-
|
|
124
|
-
other agent.
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
okf skill .claude # or: okf skill .agents
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**3. Start an agent session** where your project lives.
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
claude
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**4. Make your first bundle.** Two ways in, by what you already have: docs keep
|
|
137
|
-
every word, code gets written up for you.
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
/okf migrate <path-to-your-docs> # have docs? adopted in place, bodies verbatim
|
|
141
|
-
/okf produce based on <path-to-your-code> # only code? the skill authors the concepts
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
> [!TIP]
|
|
145
|
-
> **Once you have a bundle**, run `/okf maintain` in the agent session to keep it
|
|
146
|
-
> in sync as the code changes, and `okf server <folder>` to explore it as a graph.
|
|
147
|
-
> In Claude Code, the [plugin](#claude-code-plugin) adds a post-edit curation hook
|
|
148
|
-
> that runs `validate` + `lint` for you.
|
|
149
|
-
|
|
150
|
-
The package, end to end:
|
|
151
|
-
|
|
152
|
-
<p align="center">
|
|
153
|
-
<picture>
|
|
154
|
-
<source media="(prefers-color-scheme: dark)" srcset=".github/overview-dark.png">
|
|
155
|
-
<img src=".github/overview-light.png" width="760" alt="The package: the Agent Skill (your coding agent authors and curates, you stay the editor) writes and maintains the bundle, a folder of Markdown + YAML in your repo where one concept is one file and links between files are the knowledge graph. The bundle is read by the CLI/Lib (validate: legal OKF per section 9; lint: well-curated and fresh; search: ranked retrieval; require okf for Ruby objects) and by the Graph, in four modes: okf server (a live local server), okf render (the same page exported as one static, self-contained HTML file you can host anywhere), okf registry (every registered bundle behind one hub), and OKF::Server::App (the Rack app mounted in a Rails route). One gem, 100% local, Ruby 2.4 or newer, only rack, webrick and minifts as dependencies.">
|
|
156
|
-
</picture>
|
|
157
|
-
</p>
|
|
158
|
-
|
|
159
|
-
What the gem does, and which verb does it. This table is the map; **[the
|
|
160
|
-
docs](https://okfgem.com/docs/)** are the manual.
|
|
161
|
-
|
|
162
|
-
| Capability | What it answers | Verb |
|
|
163
|
-
| ------------------------------------------------------------- | --------------------------------- | -------------------------- |
|
|
164
|
-
| [Companion agent skill](https://okfgem.com/docs/skill/) | Can an agent author it? | `skill` |
|
|
165
|
-
| [Conformance validator](https://okfgem.com/docs/cli/validate/) | Is this a legal OKF bundle? | `validate` |
|
|
166
|
-
| [Curation linter](https://okfgem.com/docs/cli/lint/) | Is it navigable, complete, fresh? | `lint` / `loose` |
|
|
167
|
-
| [Ranked text search](https://okfgem.com/docs/cli/search/) | Which concept covers X? | `search` |
|
|
168
|
-
| [Read views](https://okfgem.com/docs/cli/) | What is in here, and where? | `index` / `dirs` / `catalog` |
|
|
169
|
-
| [Interactive graph server](https://okfgem.com/docs/cli/server/) | Can I explore it visually? | `server` |
|
|
170
|
-
| [Static render](https://okfgem.com/docs/cli/render/) | Can I ship a serverless snapshot? | `render` |
|
|
171
|
-
| [Library API](https://okfgem.com/docs/library/) | Can my Ruby program use it? | in-process |
|
|
172
|
-
|
|
173
|
-
And because knowledge rarely lives in one bundle, a per-user
|
|
174
|
-
[registry](.okf/registry.md) gives each bundle a name: `okf registry set ./docs`
|
|
175
|
-
once, then `@docs` works anywhere a `<dir>` does — from any directory — and a
|
|
176
|
-
bare `okf server` hosts every registered bundle behind one hub.
|
|
177
|
-
|
|
178
|
-
> [!TIP]
|
|
179
|
-
> **Browse the gem as knowledge, not just docs.** This README is the front door;
|
|
180
|
-
> the depth lives in the [`.okf/`](.okf) bundle this repo ships. Start at the
|
|
181
|
-
> [overview](.okf/overview.md), then follow the graph into the
|
|
182
|
-
> [capabilities](.okf/capabilities/) (what it does), the
|
|
183
|
-
> [design constraints](.okf/design/) (why it stays this light), and the
|
|
184
|
-
> [format itself](.okf/format/) (what it operates on). Run `okf server .okf` to
|
|
185
|
-
> walk the same bundle as an interactive graph.
|
|
186
|
-
|
|
187
|
-
**It installs on the Ruby your OS already ships** — every Ruby since 2.4, three
|
|
188
|
-
small dependencies, no native extension and no build step — so there is nothing
|
|
189
|
-
to provision and nothing to keep up to date. The
|
|
190
|
-
[design constraints](.okf/design/) that hold that line are enforced by tests on
|
|
191
|
-
every supported Ruby.
|
|
192
|
-
|
|
193
|
-
## Installation
|
|
194
|
-
|
|
195
|
-
> **In Claude Code**, the plugin is the fastest path: two commands install the whole
|
|
196
|
-
> toolchain (skill, `/okf:gem`, and the curation hook). See
|
|
197
|
-
> [Claude Code plugin](#claude-code-plugin). Everywhere else, install the gem:
|
|
23
|
+
## Install
|
|
198
24
|
|
|
199
25
|
```bash
|
|
200
26
|
gem install okf
|
|
@@ -202,214 +28,53 @@ gem install okf
|
|
|
202
28
|
bundle add okf
|
|
203
29
|
```
|
|
204
30
|
|
|
205
|
-
|
|
206
|
-
`bundle exec rake install` builds and installs it locally.
|
|
207
|
-
|
|
208
|
-
### No Ruby? Use Docker
|
|
209
|
-
|
|
210
|
-
The official image bundles the CLI, so every `okf` command runs against a bundle
|
|
211
|
-
you mount at `/data`:
|
|
31
|
+
No Ruby? The official image carries the CLI:
|
|
212
32
|
|
|
213
33
|
```bash
|
|
214
34
|
docker run --rm -v "$PWD:/data" ghcr.io/serradura/okf validate .
|
|
215
|
-
docker run --rm -v "$PWD:/data" -p 8808:8808 ghcr.io/serradura/okf server . --bind 0.0.0.0
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Tired of the long line? The Docker-backed [`okf` command](https://docker.okfgem.com)
|
|
219
|
-
drops the prefix so every verb reads exactly like the native CLI:
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
curl -fsSL https://docker.okfgem.com/install.sh | sh # PowerShell: irm https://docker.okfgem.com/install.ps1 | iex
|
|
223
|
-
okf validate .
|
|
224
|
-
okf server .
|
|
225
35
|
```
|
|
226
36
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
## Where to go next
|
|
231
|
-
|
|
232
|
-
Installed. The rest of this page is each surface the gem gives you over a bundle,
|
|
233
|
-
in the order most people meet them:
|
|
234
|
-
|
|
235
|
-
- **[The graph](#the-graph)** — the whole bundle on one page, live or baked into a
|
|
236
|
-
single HTML file you can host anywhere. Start here if you want to *see* it.
|
|
237
|
-
- **[Agent skill](#agent-skill)** — the verbs your agent runs to author, maintain
|
|
238
|
-
and answer from a bundle, so you stay the editor rather than the typist.
|
|
239
|
-
- **[Claude Code plugin](#claude-code-plugin)** — that skill, a slash command and a
|
|
240
|
-
post-edit curation hook, in two lines.
|
|
241
|
-
- **[Command line](#command-line)** — every view as scannable text or as JSON, with
|
|
242
|
-
exit codes stable enough to gate CI on.
|
|
243
|
-
- **[Library](#library)** — `OKF::Bundle` in your own Ruby, and the graph as a Rack
|
|
244
|
-
app you can mount in an app you already have.
|
|
245
|
-
- **[Extending okf](#extending-okf-and-running-it-safely)** — ship a verb as a gem,
|
|
246
|
-
and what the page does and does not trust in a bundle you did not write.
|
|
247
|
-
|
|
248
|
-
Full reference for every verb and flag lives in
|
|
249
|
-
**[the docs](https://okfgem.com/docs/)**.
|
|
250
|
-
|
|
251
|
-
## The graph
|
|
252
|
-
|
|
253
|
-
<picture>
|
|
254
|
-
<source media="(prefers-color-scheme: dark)" srcset=".github/server-dark.png">
|
|
255
|
-
<img src=".github/server-light.png" alt="The okf graph server: a force-directed knowledge graph with a concept selected, its neighbors highlighted and the rest of the bundle dimmed, and the inspector panel showing the concept's type, description, tags, and every concept it links to and from, each labelled with its type.">
|
|
256
|
-
</picture>
|
|
257
|
-
|
|
258
|
-
_The graph server on this repo's own [`.okf`](.okf) bundle, with the `overview`
|
|
259
|
-
concept selected. Try it live at
|
|
260
|
-
**[demo.okfgem.com](https://demo.okfgem.com)**._
|
|
261
|
-
|
|
262
|
-
One page, from a phone to a desktop: the navigation rail becomes a drawer, the
|
|
263
|
-
toolbar folds into a `⚙` sheet, and a tap opens a preview card at the bottom edge
|
|
264
|
-
rather than a panel over the whole viewport, so the graph stays live while you
|
|
265
|
-
read. Drag the card up for the neighbourhood, tap a link and it walks there in
|
|
266
|
-
place.
|
|
267
|
-
|
|
268
|
-
It is keyboard-first: **`⌘/Ctrl-K`** opens a command palette that searches
|
|
269
|
-
concepts, jumps to a view, and — behind a [hub](#one-registry-many-bundles) —
|
|
270
|
-
switches bundles. **`/`** jumps to the current view's search, **`?`** answers with
|
|
271
|
-
every shortcut. Cluster mode boxes the graph by directory and nests as deep as
|
|
272
|
-
your tree does.
|
|
37
|
+
The Docker-backed [`okf` command](https://docker.okfgem.com) drops the prefix so
|
|
38
|
+
every verb reads exactly like the native CLI.
|
|
273
39
|
|
|
274
|
-
|
|
275
|
-
self-contained HTML file, the whole bundle baked in, so you can publish the graph
|
|
276
|
-
on GitHub Pages or any static host.
|
|
277
|
-
|
|
278
|
-
### One registry, many bundles
|
|
279
|
-
|
|
280
|
-
The [registry](.okf/registry.md) is a per-user, ordered list of bundles in one
|
|
281
|
-
plain JSON file (`$OKF_HOME/registry.json`, default `~/.okf`) — hand-editable,
|
|
282
|
-
greppable, no database. It stores references, never content: the bundles stay in
|
|
283
|
-
the repos that own them.
|
|
284
|
-
|
|
285
|
-
```bash
|
|
286
|
-
okf registry set ./docs --as handbook # give the bundle a name
|
|
287
|
-
okf lint @handbook # @slug works wherever a <dir> does, from anywhere
|
|
288
|
-
okf search @all rate limit # ranked retrieval across every registered bundle
|
|
289
|
-
okf server # no args: the whole registry behind one hub
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Related bundles can share a name: `okf registry group backend @handbook @runbooks`
|
|
293
|
-
makes `@backend` stand for the set (members can be groups too, so they nest), and
|
|
294
|
-
`okf search @backend rate limit` or `okf server @backend` then targets all of them
|
|
295
|
-
at once — a durable subset for the two verbs that take several bundles.
|
|
296
|
-
|
|
297
|
-
The registry lives under `$OKF_HOME` (default `~/.okf`) — one per user. For one
|
|
298
|
-
scoped to a single project instead, `okf registry init` drops a
|
|
299
|
-
`.okf-registry.json` in the current directory; okf then discovers it by walking up
|
|
300
|
-
from wherever you run, and every registry op — and every `@slug` — resolves through
|
|
301
|
-
it in place of the global one. So a bare `okf server` inside that repo serves *its*
|
|
302
|
-
bundles with no `$OKF_HOME` setup. The nearest registry wins, and
|
|
303
|
-
`OKF_NO_DISCOVERY=1` forces the global one.
|
|
304
|
-
|
|
305
|
-
Commit that file and it travels with the repo: a bundle under the project root is
|
|
306
|
-
stored relative to the registry, so a checkout on another machine — or a container
|
|
307
|
-
that mounts the repo — resolves the same bundles unchanged. (Bundles outside the
|
|
308
|
-
tree keep absolute paths, which do not travel.)
|
|
309
|
-
|
|
310
|
-
Behind the hub each bundle mounts at `/b/<slug>/`, `/b/` lists them all, and the
|
|
311
|
-
`⌘/Ctrl-K` palette both switches bundles and **searches every one at once** — type
|
|
312
|
-
a few words and the matching concepts appear with their bundle and a snippet, from
|
|
313
|
-
wherever you are.
|
|
314
|
-
|
|
315
|
-
The ⚙ rail opens **Bundles**, the registry on the graph page itself: make
|
|
316
|
-
default, rename, remove, where you are already reading. Those controls are the one
|
|
317
|
-
thing that does not follow you onto a network — bind anywhere but loopback and
|
|
318
|
-
they are refused outright, since `--bind 0.0.0.0` is how a personal tool becomes a
|
|
319
|
-
public one.
|
|
320
|
-
|
|
321
|
-
## Agent skill
|
|
322
|
-
|
|
323
|
-
The gem carries the [companion OKF agent skill](.okf/capabilities/agent-skill.md):
|
|
324
|
-
a `SKILL.md` plus reference and template files that teach a coding agent to
|
|
325
|
-
author, maintain, and consume OKF bundles and to drive the
|
|
326
|
-
[commands below](#command-line).
|
|
327
|
-
Because the skill ships inside the gem, installing the gem already puts the skill
|
|
328
|
-
on your machine, and the skill's CLI reference can never drift from the
|
|
329
|
-
executable it was released with.
|
|
330
|
-
|
|
331
|
-
The skill routes a small set of verbs. In Claude Code they run as `/okf:gem
|
|
332
|
-
<verb>`; used standalone, the skill infers the verb from your request.
|
|
333
|
-
|
|
334
|
-
| Verb | What it does |
|
|
335
|
-
| ---------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
336
|
-
| _(none)_ | Orient on the bundle and recommend the highest-value next move |
|
|
337
|
-
| `search` | Answer a question from the bundle, token-lean: the map, the finder, only the winning bodies |
|
|
338
|
-
| `produce` | Create or extend a bundle from code, docs, or knowledge in people's heads |
|
|
339
|
-
| `migrate` | Adopt existing Markdown docs in place: frontmatter and reserved files added, bodies kept verbatim |
|
|
340
|
-
| `maintain` | Sync the bundle's content with reality after the code or docs change |
|
|
341
|
-
| `refine` | Restructure it for retrieval: evidence-first, cohesion over balance — proposes, never applies |
|
|
342
|
-
| `consume` | Use the bundle as context for a task, writing back what you learn |
|
|
343
|
-
| `curate` | Structural upkeep as it stands: `validate` + `lint` + `loose` |
|
|
344
|
-
| `doctor` | Install and verify the CLI, then doctor the bundle |
|
|
345
|
-
| `<okf-cli-verb>` | Run any CLI verb (`validate`, `lint`, `search`, `index`, `server`, the read views) and interpret its output |
|
|
346
|
-
|
|
347
|
-
Three of those look alike and are not, which is the distinction worth learning
|
|
348
|
-
first: **`curate`** keeps the bundle *sound* (the structure as it stands),
|
|
349
|
-
**`maintain`** keeps it *true* (the code changed, so the content must catch up),
|
|
350
|
-
and **`refine`** changes *where knowledge lives* — the folder a concept sits in,
|
|
351
|
-
a fact re-explained in three overviews. Reach for `refine` when nothing is wrong
|
|
352
|
-
and everything is hard to find. It reads the evidence, then hands you a proposal
|
|
353
|
-
— it never rearranges your bundle on its own.
|
|
354
|
-
|
|
355
|
-
Point it at your agent's config directory and the tree settles in its own
|
|
356
|
-
`skills/okf/` folder, so a shared skills directory never gets the files loose:
|
|
40
|
+
## Four steps to your first bundle
|
|
357
41
|
|
|
358
42
|
```bash
|
|
359
|
-
okf skill .claude
|
|
360
|
-
|
|
43
|
+
okf skill .claude # 1. teach your agent the format (or: okf skill .agents)
|
|
44
|
+
claude # 2. start an agent session where your project lives
|
|
361
45
|
```
|
|
362
46
|
|
|
363
|
-
The resolved directory must be empty unless you pass `--force`, so a customized
|
|
364
|
-
skill is never clobbered.
|
|
365
|
-
|
|
366
|
-
## Claude Code plugin
|
|
367
|
-
|
|
368
|
-
This repository doubles as a Claude Code plugin marketplace, so the whole
|
|
369
|
-
toolchain installs with two commands inside Claude Code:
|
|
370
|
-
|
|
371
47
|
```
|
|
372
|
-
/
|
|
373
|
-
/
|
|
48
|
+
/okf migrate <path-to-your-docs> # 3a. have docs? adopted in place, bodies verbatim
|
|
49
|
+
/okf produce based on <path-to-your-code> # 3b. only code? the skill authors the concepts
|
|
374
50
|
```
|
|
375
51
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
auto-runs); and a **curation hook** that runs `okf validate` + `okf lint` after
|
|
380
|
-
every edit inside a bundle and returns the findings as context. The checks are
|
|
381
|
-
the CLI's own, so the feedback is deterministic.
|
|
382
|
-
|
|
383
|
-
The hook stays silent outside bundles, and it is config-free to switch off:
|
|
384
|
-
`OKF_CURATE_DISABLED=1` turns it off, `OKF_CURATE_QUIET=1` keeps the findings
|
|
385
|
-
without the install suggestion, and an `<!-- okf-disable -->` comment skips one
|
|
386
|
-
file.
|
|
52
|
+
```bash
|
|
53
|
+
okf server <folder> # 4. explore what you got, as a live graph
|
|
54
|
+
```
|
|
387
55
|
|
|
388
|
-
|
|
389
|
-
alone, and the skill itself instructs the agent to run the same checks after
|
|
390
|
-
editing a bundle.
|
|
56
|
+
Then `/okf maintain` keeps it in sync as the code changes.
|
|
391
57
|
|
|
392
|
-
##
|
|
58
|
+
## The command line
|
|
393
59
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
exit codes are stable enough to branch on in CI. The same commands render as
|
|
399
|
-
scannable plain text when a human is the one looking.
|
|
60
|
+
Written to be read by an **agent first and a person second** — that is what the
|
|
61
|
+
skill drives, with no wrapper in between. Every read verb takes `--json`, the
|
|
62
|
+
list views project down to the fields you ask for (`--fields`/`--except`), and
|
|
63
|
+
the exit codes are stable enough to branch on in CI.
|
|
400
64
|
|
|
401
65
|
```bash
|
|
402
66
|
okf validate <dir|@slug> # is this legal OKF?
|
|
403
67
|
okf lint <dir|@slug> [--fail-on warn] # is it navigable, complete, fresh?
|
|
404
68
|
okf loose <dir|@slug> # concepts with no links in or out
|
|
405
69
|
okf search <dir|@slug…|@all> <term…> # ranked retrieval; @all spans every bundle
|
|
406
|
-
okf index <dir|@slug> [--dir D] [--depth N] # the §
|
|
70
|
+
okf index <dir|@slug> [--dir D] [--depth N] # the §8 map: index bodies, rollups, listings
|
|
407
71
|
okf dirs <dir|@slug> [--dir D] [--depth N] # the shape: every directory and what it holds
|
|
408
72
|
okf catalog | files | tags | types | stats <dir|@slug> # the browser views, on the CLI
|
|
73
|
+
okf references <dir|@slug> # the references/ inventory: files, citers, dangling pointers
|
|
409
74
|
okf graph <dir|@slug> [--hubs] [--traffic] # the raw graph; --hubs ranks concepts, --traffic dirs
|
|
410
75
|
okf server [DIR|@slug…] [-p PORT] [--bind ADDR] # the live graph: one bundle, or all of them
|
|
411
76
|
okf render <dir|@slug> [-o FILE] # the same page as one static, self-contained file
|
|
412
|
-
okf registry init | list | set | del | default | rename | group | ungroup # name & group your bundles
|
|
77
|
+
okf registry init | list | set | del | default | rename | group | ungroup # name & group your bundles
|
|
413
78
|
okf skill <dest> # install the companion agent skill
|
|
414
79
|
okf --version
|
|
415
80
|
```
|
|
@@ -418,57 +83,30 @@ Exit codes: `0` success, `1` non-conformant bundle (or a `lint --fail-on`
|
|
|
418
83
|
threshold crossed), `2` usage error. Every flag is in `okf <verb> --help` and in
|
|
419
84
|
[the docs](https://okfgem.com/docs/).
|
|
420
85
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
…
|
|
427
|
-
✓ conformant (33 warning(s))
|
|
86
|
+
**A registry names your bundles.** `okf registry set ./docs --as handbook` once,
|
|
87
|
+
then `@handbook` works anywhere a `<dir>` does, from any directory; `okf search
|
|
88
|
+
@all rate limit` spans every one of them, and a bare `okf server` hosts them all
|
|
89
|
+
behind one hub. `okf registry init` scopes one to a single project instead, and a
|
|
90
|
+
committed `.okf-registry.json` travels with the repo.
|
|
428
91
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
```
|
|
92
|
+
**A big bundle is read a level at a time.** `okf index --depth 1 --except
|
|
93
|
+
body,listing` is the map an agent orients on — on a 414-concept bundle, 2.8 KB
|
|
94
|
+
against the full 313 KB — and `--dir` then opens one branch, bringing the
|
|
95
|
+
ancestors that say what it is.
|
|
434
96
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
A few hundred concepts is a map nobody reads whole, so `index` and `dirs` descend
|
|
438
|
-
instead of dumping. `--dir` takes a directory **and everything under it**,
|
|
439
|
-
`--depth N` bounds how far below that it goes, and the two compose the way you
|
|
440
|
-
actually walk a tree:
|
|
441
|
-
|
|
442
|
-
```bash
|
|
443
|
-
okf dirs @handbook # the shape: every dir, what it holds directly and below
|
|
444
|
-
okf index @handbook --depth 1 --no-body # the top of the map, no prose
|
|
445
|
-
okf index @handbook --dir platform/api # now open one branch — with the chain that places it
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
Naming a `--dir` brings its ancestors along, marked `↑`, so a branch is never
|
|
449
|
-
shown adrift of the context that says what it is — the root `index.md`'s prose
|
|
450
|
-
first among it.
|
|
451
|
-
|
|
452
|
-
For an agent the saving is the whole point. On a 400-concept bundle the full
|
|
453
|
-
`okf index --json` is 313 KB; the skeleton it orients on is 2.8 KB:
|
|
454
|
-
|
|
455
|
-
```bash
|
|
456
|
-
okf index @handbook --json --depth 1 --except body,listing
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
## Library
|
|
97
|
+
## The library
|
|
460
98
|
|
|
461
99
|
`require "okf"` gives you the whole thing as Ruby objects — two layers: pure
|
|
462
100
|
in-memory data (`OKF::Concept`, `OKF::Bundle`) you build and analyze with no disk
|
|
463
101
|
involved, and on-disk handles (`OKF::Concept::File`, `OKF::Bundle::Folder`) that
|
|
464
|
-
add load/save/reload/delete
|
|
102
|
+
add load/save/reload/delete.
|
|
465
103
|
|
|
466
104
|
```ruby
|
|
467
105
|
require "okf"
|
|
468
106
|
|
|
469
107
|
folder = OKF::Bundle::Folder.load("docs")
|
|
470
108
|
folder.concepts # => [OKF::Concept]
|
|
471
|
-
folder.validate # => §
|
|
109
|
+
folder.validate # => §11 conformance result
|
|
472
110
|
folder.lint # => curation report
|
|
473
111
|
folder.graph # => nodes, edges, indexes
|
|
474
112
|
|
|
@@ -477,80 +115,70 @@ OKF::Server::App.new(folder) # => a Rack app: the interactive graph, mountab
|
|
|
477
115
|
```
|
|
478
116
|
|
|
479
117
|
That last line is the point of the Rack app: the graph mounts inside an app you
|
|
480
|
-
already have, auth included. The
|
|
481
|
-
|
|
482
|
-
the pure layer, the
|
|
118
|
+
already have, auth included. The
|
|
119
|
+
[Rails guide](https://okfgem.com/docs/guides/rails/) walks it, and the
|
|
120
|
+
[library API](https://okfgem.com/docs/library/) covers the pure layer, the
|
|
121
|
+
writer, and the lower-level pieces.
|
|
483
122
|
|
|
484
|
-
|
|
123
|
+
## validate and lint are two different questions
|
|
485
124
|
|
|
486
|
-
`validate`
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
*forbidden* to reject a bundle for a broken link or a missing optional field.
|
|
125
|
+
`validate` asks *"is this legal OKF?"* and implements the spec's
|
|
126
|
+
[§11](lib/okf/skill/reference/SPEC.md#11-conformance) exactly — which means it is *forbidden* to
|
|
127
|
+
reject a bundle for a broken link or a missing optional field.
|
|
490
128
|
|
|
491
|
-
`lint`
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
129
|
+
`lint` asks the complementary question, *"is this well-curated, navigable,
|
|
130
|
+
trustworthy?"*, over exactly those tolerated things: reachability, backlog,
|
|
131
|
+
completeness, freshness, provenance, attestation, migration, hygiene. It is
|
|
132
|
+
advisory and exits `0` even with findings unless you pass `--fail-on warn`, or
|
|
133
|
+
`--only legacy_timestamp,legacy_citations --fail-on info` to gate a migration
|
|
134
|
+
campaign on the two findings that name a bundle's leftover v0.1 spellings and
|
|
135
|
+
nothing else.
|
|
496
136
|
|
|
497
137
|
Keeping them apart is what lets you gate CI on conformance without gating it on
|
|
498
138
|
taste. `lint --json` is also the structured input an agent reads to reason about
|
|
499
139
|
the two things no checker can compute — contradictions, and *semantic* staleness.
|
|
500
140
|
|
|
501
|
-
##
|
|
141
|
+
## Trust is data, so you can filter on it
|
|
142
|
+
|
|
143
|
+
OKF v0.2 lets a bundle say where each concept came from and how far to trust
|
|
144
|
+
it — `generated` (who or what wrote it), `verified` (who confirmed it),
|
|
145
|
+
`status` (its lifecycle), `stale_after` (a declared expiry) — and this gem
|
|
146
|
+
reads the families everywhere: `--status` and `--trust` narrow `catalog`,
|
|
147
|
+
`files`, `search`, `tags` and `types`; the graph page shows each concept's
|
|
148
|
+
tier beside its type; `lint` reports what expired, against a clock you can
|
|
149
|
+
pin (`--today`) for a reproducible report. `okf references` closes the loop
|
|
150
|
+
for §10's attested computations, inventorying the `references/` files —
|
|
151
|
+
attester code, computation files — that back them, with every pointer that
|
|
152
|
+
resolves to nothing named. A v0.1 bundle needs none of this and stays
|
|
153
|
+
readable forever (§13); the two Migration findings tell it what to modernize
|
|
154
|
+
without ever failing it.
|
|
155
|
+
|
|
156
|
+
## Extending it
|
|
502
157
|
|
|
503
158
|
Publish a gem named `okf-*` carrying an `okf/plugin.rb` and installing it is the
|
|
504
159
|
whole installation: your verb answers to `okf` and behaves like a built-in.
|
|
505
160
|
Nothing an addon registers can displace one, and a broken addon is skipped rather
|
|
506
|
-
than taking the CLI down.
|
|
507
|
-
|
|
161
|
+
than taking the CLI down. [`okf-mcp`](https://rubygems.org/gems/okf-mcp) is the
|
|
162
|
+
first one — install it and `okf mcp` serves your bundles over the Model Context
|
|
163
|
+
Protocol, with nothing in this gem naming it.
|
|
508
164
|
|
|
509
|
-
The graph page treats a bundle as untrusted content: inlined data is escaped
|
|
165
|
+
The graph page treats a bundle as untrusted content: inlined data is escaped and
|
|
510
166
|
every concept body is sanitized before it reaches the DOM, so a script hidden in
|
|
511
167
|
Markdown is stripped rather than run. It still loads libraries from a CDN, so
|
|
512
168
|
treat an unfamiliar bundle the way you would treat any document from a source you
|
|
513
|
-
do not know.
|
|
514
|
-
[server trust boundary](.okf/design/server-trust-boundary.md).
|
|
515
|
-
|
|
516
|
-
## Development
|
|
169
|
+
do not know.
|
|
517
170
|
|
|
518
|
-
|
|
519
|
-
bin/setup # install dependencies
|
|
520
|
-
bundle exec rake # tests + RuboCop (what CI runs)
|
|
521
|
-
bundle exec rake test # just the test suite
|
|
522
|
-
ruby -Ilib exe/okf validate <dir> # run the CLI from a checkout
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
The suite runs on every supported Ruby; to check the 2.4 floor locally:
|
|
171
|
+
## More
|
|
526
172
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
The graph page has its own suite in a real browser (`bundle exec rake
|
|
533
|
-
browser:setup`, then `rake test:browser`). See [AGENTS.md](AGENTS.md) for the
|
|
534
|
-
maintainer guide.
|
|
535
|
-
|
|
536
|
-
## Contributing
|
|
537
|
-
|
|
538
|
-
Bug reports and pull requests are welcome on GitHub at
|
|
539
|
-
<https://github.com/serradura/okf-gem>. This project is intended to be a safe,
|
|
540
|
-
welcoming space for collaboration, and contributors are expected to adhere to
|
|
541
|
-
the [code of conduct](CODE_OF_CONDUCT.md).
|
|
173
|
+
The [project README](https://github.com/serradura/okf-gem#readme) carries the
|
|
174
|
+
diagrams, the comparison with `CLAUDE.md`, agent auto-memory and wikis, and the
|
|
175
|
+
Claude Code plugin. The [docs](https://okfgem.com/docs/) are the manual. And the
|
|
176
|
+
repo documents *itself* in OKF — clone it and run `okf server .okf` to read this
|
|
177
|
+
gem's own knowledge as a graph.
|
|
542
178
|
|
|
543
179
|
## License
|
|
544
180
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
is authored by Google Cloud Platform and included under its own Apache-2.0
|
|
549
|
-
license, Copyright (c) Google LLC. See `NOTICE` and
|
|
181
|
+
Apache-2.0; see `LICENSE.txt`. The Open Knowledge Format specification bundled
|
|
182
|
+
with the skill is authored by Google Cloud Platform and included under its own
|
|
183
|
+
Apache-2.0 license, Copyright (c) Google LLC. See `NOTICE` and
|
|
550
184
|
`lib/okf/skill/reference/APACHE-2.0.txt`.
|
|
551
|
-
|
|
552
|
-
[okf-skills](https://github.com/scaccogatto/okf-skills) by Marco Boffo, a Python
|
|
553
|
-
OKF toolkit for Claude Code with a feature-rich interactive graph view, was an
|
|
554
|
-
early inspiration for this gem's Claude Code plugin and for the knowledge-as-code
|
|
555
|
-
comparison in [Why OKF](#why-okf). okf-gem takes a different shape: a Ruby-native
|
|
556
|
-
gem built around the `okf` CLI and an embeddable library.
|