okf 1.4.0 → 1.5.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 +50 -0
- data/README.md +15 -15
- data/lib/okf/bundle/search.rb +155 -0
- data/lib/okf/bundle.rb +2 -2
- data/lib/okf/cli.rb +68 -4
- data/lib/okf/server/app.rb +29 -0
- data/lib/okf/server/graph/template.html.erb +256 -40
- data/lib/okf/skill/SKILL.md +17 -11
- data/lib/okf/skill/playbooks/consume.md +4 -2
- data/lib/okf/skill/playbooks/maintain.md +6 -4
- data/lib/okf/skill/playbooks/menu.md +10 -6
- data/lib/okf/skill/playbooks/search.md +42 -0
- data/lib/okf/skill/reference/authoring.md +2 -2
- data/lib/okf/skill/reference/cli.md +55 -17
- data/lib/okf/version.rb +1 -1
- data/lib/okf.rb +1 -0
- metadata +3 -26
- data/.okf/capabilities/agent-skill.md +0 -46
- data/.okf/capabilities/graph-server.md +0 -63
- data/.okf/capabilities/index.md +0 -20
- data/.okf/capabilities/library-api.md +0 -72
- data/.okf/capabilities/linter.md +0 -49
- data/.okf/capabilities/read-views.md +0 -84
- data/.okf/capabilities/validator.md +0 -40
- data/.okf/cli.md +0 -52
- data/.okf/design/core-shell-split.md +0 -58
- data/.okf/design/index.md +0 -10
- data/.okf/design/ruby-floor.md +0 -45
- data/.okf/design/runtime-dependencies.md +0 -44
- data/.okf/design/server-trust-boundary.md +0 -40
- data/.okf/format/citations.md +0 -33
- data/.okf/format/cross-links.md +0 -52
- data/.okf/format/frontmatter.md +0 -38
- data/.okf/format/index.md +0 -9
- data/.okf/format/okf-format.md +0 -43
- data/.okf/index.md +0 -18
- data/.okf/log.md +0 -10
- data/.okf/model/bundle.md +0 -38
- data/.okf/model/concept.md +0 -44
- data/.okf/model/graph.md +0 -44
- data/.okf/model/index.md +0 -8
- data/.okf/overview.md +0 -67
data/.okf/cli.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Component
|
|
3
|
-
title: The okf command-line front end
|
|
4
|
-
description: The only layer that parses argv, prints, writes files, and decides exit codes.
|
|
5
|
-
resource: lib/okf/cli.rb
|
|
6
|
-
tags: [cli, shell]
|
|
7
|
-
timestamp: 2026-07-12T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
`OKF::CLI` is the executable's front end and the single place where the gem
|
|
13
|
-
touches the outside world for a command: it parses `argv`, prints, writes files,
|
|
14
|
-
and chooses the exit code. Every library class beneath it just returns data — the
|
|
15
|
-
CLI is the [shell half](design/core-shell-split.md) of the architecture. Output
|
|
16
|
-
streams are injected (`out:`/`err:`) so the whole surface is driven in tests
|
|
17
|
-
without a real terminal or socket.
|
|
18
|
-
|
|
19
|
-
# Subcommands
|
|
20
|
-
|
|
21
|
-
Dispatch is a single `case` on the first argument. The verbs fall into three
|
|
22
|
-
groups:
|
|
23
|
-
|
|
24
|
-
| Group | Verbs | Notes |
|
|
25
|
-
|-------|-------|-------|
|
|
26
|
-
| Judge | `validate`, `lint`, `loose` | [validate](capabilities/validator.md) and [lint](capabilities/linter.md) answer different questions and stay separate. |
|
|
27
|
-
| Read | `index`, `catalog`, `files`, `types`, `tags`, `stats`, `graph` | the [browser views as text](capabilities/read-views.md), plus the `index` map. |
|
|
28
|
-
| Act | `server`, `skill` | boot the [graph server](capabilities/graph-server.md); install the [agent skill](capabilities/agent-skill.md). |
|
|
29
|
-
|
|
30
|
-
Plus `version` / `--version` / `-v` and `help` / `--help` / `-h`.
|
|
31
|
-
|
|
32
|
-
# Exit codes
|
|
33
|
-
|
|
34
|
-
The contract every verb keeps:
|
|
35
|
-
|
|
36
|
-
| Code | Meaning |
|
|
37
|
-
|------|---------|
|
|
38
|
-
| `0` | success — including a bundle with lint findings (`lint` is advisory) |
|
|
39
|
-
| `1` | a non-conformant bundle (`validate`) or a `lint --fail-on warn` threshold crossed |
|
|
40
|
-
| `2` | usage error — unknown command, missing directory, bad flag |
|
|
41
|
-
|
|
42
|
-
# Best-effort reads
|
|
43
|
-
|
|
44
|
-
`graph`, `server`, and the read views are best-effort under §9: a file with
|
|
45
|
-
invalid frontmatter is kept in `bundle.unparseable`, skipped, and *noted on
|
|
46
|
-
stderr* (so JSON on stdout stays clean) rather than aborting the whole command.
|
|
47
|
-
One bad file never breaks the rest. Run [validate](capabilities/validator.md) for
|
|
48
|
-
the details of what was skipped.
|
|
49
|
-
|
|
50
|
-
# Citations
|
|
51
|
-
|
|
52
|
-
[1] [lib/okf/cli.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/cli.rb) — the dispatch, option parsing, and printers.
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Constraint
|
|
3
|
-
title: The core/shell split
|
|
4
|
-
description: A pure functional core that never touches disk or stdio, and a thin shell that owns all I/O — enforced by a test.
|
|
5
|
-
resource: test/unit/boundary_test.rb
|
|
6
|
-
tags: [architecture, purity, testing, diagram]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
The gem is two halves. The **core** is pure — [`Concept`](../model/concept.md),
|
|
13
|
-
[`Bundle`](../model/bundle.md), [`Graph`](../model/graph.md), the
|
|
14
|
-
[validator](../capabilities/validator.md), the [linter](../capabilities/linter.md),
|
|
15
|
-
the [format layer](../format/) — logic that returns data and does no I/O. The
|
|
16
|
-
**shell** owns everything that touches the world: the on-disk handles
|
|
17
|
-
(`Concept::File`, `Bundle::{Reader,Writer,Folder}`), the
|
|
18
|
-
[server](../capabilities/graph-server.md), and the [CLI](../cli.md).
|
|
19
|
-
|
|
20
|
-
```mermaid
|
|
21
|
-
flowchart TB
|
|
22
|
-
subgraph shell ["Shell — the only layer that does I/O"]
|
|
23
|
-
CLI["CLI"]
|
|
24
|
-
Server["Server::App"]
|
|
25
|
-
RW["Reader · Writer · Folder"]
|
|
26
|
-
CF["Concept::File"]
|
|
27
|
-
end
|
|
28
|
-
subgraph core ["Core — pure: no File / Dir / stdio"]
|
|
29
|
-
Concept["Concept"]
|
|
30
|
-
Bundle["Bundle"]
|
|
31
|
-
Graph["Graph"]
|
|
32
|
-
VL["Validator · Linter"]
|
|
33
|
-
MD["Markdown layer"]
|
|
34
|
-
end
|
|
35
|
-
shell ==>|depends on| core
|
|
36
|
-
core -. "never — boundary_test.rb fails the build" .-> shell
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
# It is enforced, not just intended
|
|
40
|
-
|
|
41
|
-
`test/unit/boundary_test.rb` fails the build if a core file names a shell class or
|
|
42
|
-
reaches for `File` / `Dir` / `FileUtils` / stdio. The dependency rule is executable,
|
|
43
|
-
so the boundary cannot rot silently: **put new I/O in the shell, put new logic in
|
|
44
|
-
the core, pure.**
|
|
45
|
-
|
|
46
|
-
# Why it pays off
|
|
47
|
-
|
|
48
|
-
- **Testable without disk** — every feature runs against an in-memory
|
|
49
|
-
[bundle](../model/bundle.md), so the suite is fast and the 2.4 Docker check is
|
|
50
|
-
cheap.
|
|
51
|
-
- **Embeddable** — the [library API](../capabilities/library-api.md) exposes the
|
|
52
|
-
pure core to host apps that never want the gem's filesystem opinions.
|
|
53
|
-
- **Best-effort reads** — the reader collects unparseable files instead of
|
|
54
|
-
raising, so the pure graph still renders while the shell reports the skips.
|
|
55
|
-
|
|
56
|
-
# Citations
|
|
57
|
-
|
|
58
|
-
[1] [test/unit/boundary_test.rb](https://github.com/serradura/okf-gem/blob/main/test/unit/boundary_test.rb) — the boundary made executable.
|
data/.okf/design/index.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Design constraints
|
|
2
|
-
|
|
3
|
-
The enforced boundaries that keep the gem light, portable, and honest. These are
|
|
4
|
-
not style preferences — most are checked by a test or CI, and they explain *why*
|
|
5
|
-
the code looks the way it does.
|
|
6
|
-
|
|
7
|
-
* [Core/shell split](core-shell-split.md) - pure logic must never touch disk, stdio, or the shell layer; a test enforces it.
|
|
8
|
-
* [Ruby 2.4 floor](ruby-floor.md) - runs on the Ruby an OS already ships; newer APIs are banned.
|
|
9
|
-
* [Runtime dependencies](runtime-dependencies.md) - exactly `rack` and `webrick`, no ActiveSupport.
|
|
10
|
-
* [Server trust boundary](server-trust-boundary.md) - the served page sanitizes concept bodies and escapes inlined data; both XSS paths are closed.
|
data/.okf/design/ruby-floor.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Constraint
|
|
3
|
-
title: The Ruby 2.4 floor
|
|
4
|
-
description: The gem runs on every Ruby since 2.4 so it works on the interpreter an OS already ships.
|
|
5
|
-
tags: [ruby, compatibility, portability]
|
|
6
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Overview
|
|
10
|
-
|
|
11
|
-
`required_ruby_version >= 2.4.0`. The point is to run on the Ruby an operating
|
|
12
|
-
system already ships, without asking anyone to install a newer one — the same
|
|
13
|
-
floor as [rack](runtime-dependencies.md), the gem's core dependency. This is why
|
|
14
|
-
the gem stays deliberately light.
|
|
15
|
-
|
|
16
|
-
# The floor bans APIs RuboCop won't catch
|
|
17
|
-
|
|
18
|
-
RuboCop parses at 2.4 and catches syntax, but **not** newer standard-library
|
|
19
|
-
methods, so those are a manual discipline. A non-exhaustive list of what is off
|
|
20
|
-
limits:
|
|
21
|
-
|
|
22
|
-
- **2.5** — `delete_prefix`/`delete_suffix`, `transform_keys`, `Dir.children`,
|
|
23
|
-
`yield_self`;
|
|
24
|
-
- **2.6** — `to_h { }`, `then`, endless string slices `str[i..]`, `YAML.safe_load`
|
|
25
|
-
keyword args (allowed **only** inside the
|
|
26
|
-
[Frontmatter shim](../format/frontmatter.md));
|
|
27
|
-
- **2.7** — `filter_map`, `tally`, numbered block params;
|
|
28
|
-
- **3.x** — endless methods, hash shorthand.
|
|
29
|
-
|
|
30
|
-
These constraints apply to `test/` too, because the suite runs on 2.4 as well.
|
|
31
|
-
|
|
32
|
-
# The truth test
|
|
33
|
-
|
|
34
|
-
"Works on my Ruby" is not verification here. The floor is checked in CI across
|
|
35
|
-
every supported Ruby, and locally with:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
docker run --rm -v "$PWD":/app -w /app ruby:2.4 \
|
|
39
|
-
bash -c "bundle install && bundle exec rake test"
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
# Citations
|
|
43
|
-
|
|
44
|
-
[1] [okf.gemspec](https://github.com/serradura/okf-gem/blob/main/okf.gemspec) — `required_ruby_version = ">= 2.4.0"`.
|
|
45
|
-
[2] [AGENTS.md — Hard constraints](https://github.com/serradura/okf-gem/blob/main/AGENTS.md) — the banned-API list and the Docker truth test.
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Constraint
|
|
3
|
-
title: Exactly two runtime dependencies
|
|
4
|
-
description: The gem depends on rack and webrick only — no ActiveSupport, no build step, no JavaScript toolchain.
|
|
5
|
-
resource: okf.gemspec
|
|
6
|
-
tags: [dependencies, rack, portability]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
The runtime dependencies are exactly two, and adding a third is a design decision
|
|
13
|
-
to be challenged, not a convenience:
|
|
14
|
-
|
|
15
|
-
| Gem | Why |
|
|
16
|
-
|-----|-----|
|
|
17
|
-
| `rack` (`>= 2.2`) | the [server](../capabilities/graph-server.md) is a mountable Rack app |
|
|
18
|
-
| `webrick` (`>= 1.4`) | the default runner — unbundled from Ruby in 3.0, so it must be declared |
|
|
19
|
-
|
|
20
|
-
# No ActiveSupport, on purpose
|
|
21
|
-
|
|
22
|
-
The gem refuses the usual reach for ActiveSupport. Two small pieces exist
|
|
23
|
-
precisely so it is not needed:
|
|
24
|
-
|
|
25
|
-
- `OKF.blank?` — the emptiness check;
|
|
26
|
-
- `OKF::Markdown::Frontmatter.stringify_keys` — the key coercion, living in
|
|
27
|
-
[the one YAML gateway](../format/frontmatter.md).
|
|
28
|
-
|
|
29
|
-
# What the leanness buys
|
|
30
|
-
|
|
31
|
-
Together with the [Ruby 2.4 floor](ruby-floor.md), a two-dependency footprint is
|
|
32
|
-
what lets the gem run on the interpreter an OS already ships — no build step, no
|
|
33
|
-
bundler for the [served page](server-trust-boundary.md), no JavaScript toolchain.
|
|
34
|
-
Leanness is a feature of this gem, not an accident.
|
|
35
|
-
|
|
36
|
-
# A packaging note
|
|
37
|
-
|
|
38
|
-
`spec.files` comes from `git ls-files` minus `test/`, `bin/`, `.github/`, etc., so
|
|
39
|
-
a new top-level file ships in the gem unless the gemspec rejects it — check
|
|
40
|
-
`gem build` output when adding one.
|
|
41
|
-
|
|
42
|
-
# Citations
|
|
43
|
-
|
|
44
|
-
[1] [okf.gemspec](https://github.com/serradura/okf-gem/blob/main/okf.gemspec) — the two `add_dependency` lines and `spec.files`.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Constraint
|
|
3
|
-
title: The server trust boundary
|
|
4
|
-
description: The served page sanitizes each concept body before rendering and escapes inlined data, so both XSS paths into the page are closed.
|
|
5
|
-
resource: lib/okf/server/graph/template.html.erb
|
|
6
|
-
tags: [security, server, xss]
|
|
7
|
-
timestamp: 2026-07-12T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
The [graph server](../capabilities/graph-server.md) renders whatever bundle you
|
|
13
|
-
point it at, and a bundle is just files, so the page has to assume a body might
|
|
14
|
-
carry active content. Two defenses handle that — one for each path into the page.
|
|
15
|
-
|
|
16
|
-
# Where the boundary sits
|
|
17
|
-
|
|
18
|
-
There are two data paths into the page, and each carries its own guard:
|
|
19
|
-
|
|
20
|
-
| Path | Handling | Safe? |
|
|
21
|
-
| -------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
22
|
-
| Graph data **inlined** into the page | through `json_for_script`, which escapes `<` | yes — it cannot break out of its `<script>` |
|
|
23
|
-
| Concept bodies **fetched** on demand (`/node?id=`) | `marked` renders the Markdown, then `DOMPurify.sanitize` scrubs it before it reaches the DOM | yes — scripts, handlers, and `javascript:` URLs are stripped |
|
|
24
|
-
|
|
25
|
-
The [description](../format/cross-links.md) shown in the inspector takes a third
|
|
26
|
-
path and never needs the client's help: the server escapes it
|
|
27
|
-
(`OKF::Server::App#description_fragment`) before sending it, so it arrives inert.
|
|
28
|
-
|
|
29
|
-
# What sanitizing does not cover
|
|
30
|
-
|
|
31
|
-
DOMPurify removes the code, not the content. The page still fetches and shows the
|
|
32
|
-
links, images, and Mermaid diagrams a body names (Mermaid runs in its `strict`
|
|
33
|
-
mode), and it pulls Cytoscape, marked, and DOMPurify from a CDN. So the rule is no
|
|
34
|
-
longer _only serve bundles you trust_ — it is the ordinary care you would give any
|
|
35
|
-
document from a source you do not know.
|
|
36
|
-
|
|
37
|
-
# Citations
|
|
38
|
-
|
|
39
|
-
[1] [README.md — Server trust boundary](https://github.com/serradura/okf-gem/blob/main/README.md) — the two-defense summary.
|
|
40
|
-
[2] [lib/okf/server/graph/template.html.erb](https://github.com/serradura/okf-gem/blob/main/lib/okf/server/graph/template.html.erb) — `json_for_script` and the `DOMPurify.sanitize(marked.parse(...))` render.
|
data/.okf/format/citations.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Format
|
|
3
|
-
title: Citations (spec §8)
|
|
4
|
-
description: The provenance convention that ties empirical claims in a concept back to their sources.
|
|
5
|
-
resource: lib/okf/markdown/citations.rb
|
|
6
|
-
tags: [format, provenance, citations]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
A `# Citations` heading holds the external sources backing claims in a concept's
|
|
13
|
-
body. `OKF::Markdown::Citations` extracts them. Provenance is what separates
|
|
14
|
-
trustworthy knowledge from folklore: any external or empirical claim — a latency
|
|
15
|
-
number, an approval, a quota — should trace to a source here.
|
|
16
|
-
|
|
17
|
-
# Why it matters to the tooling
|
|
18
|
-
|
|
19
|
-
Citations are the input to the [linter](../capabilities/linter.md)'s
|
|
20
|
-
**provenance** category, which flags two failure modes:
|
|
21
|
-
|
|
22
|
-
- **uncited external claims** — a concept that asserts an external fact but cites
|
|
23
|
-
nothing;
|
|
24
|
-
- **broken citations** — a citation whose link no longer resolves.
|
|
25
|
-
|
|
26
|
-
Because the [validator](../capabilities/validator.md) is forbidden from rejecting
|
|
27
|
-
a bundle over provenance, these live entirely on the lint side — advisory signal
|
|
28
|
-
that a curator (or an agent) acts on, never a conformance failure.
|
|
29
|
-
|
|
30
|
-
# Citations
|
|
31
|
-
|
|
32
|
-
[1] [lib/okf/markdown/citations.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/markdown/citations.rb) — citation extraction.
|
|
33
|
-
[2] [SPEC.md §8](https://github.com/serradura/okf-gem/blob/main/lib/okf/skill/reference/SPEC.md) — the citations convention.
|
data/.okf/format/cross-links.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Format
|
|
3
|
-
title: Cross-links (spec §5)
|
|
4
|
-
description: Plain Markdown links between concepts that become the knowledge graph's directed edges.
|
|
5
|
-
resource: lib/okf/markdown/links.rb
|
|
6
|
-
tags: [format, links, graph, diagram]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
A cross-link is an ordinary Markdown link from one concept's body to another
|
|
13
|
-
concept file. `OKF::Markdown::Links` extracts them, and that is the whole edge
|
|
14
|
-
mechanism: the [graph](../model/graph.md) is *emergent* — you never declare it,
|
|
15
|
-
it arises from the links you write. Good linking is good knowledge modelling.
|
|
16
|
-
|
|
17
|
-
```mermaid
|
|
18
|
-
flowchart LR
|
|
19
|
-
orders["orders.md"] -->|prose link| customers["customers.md"]
|
|
20
|
-
orders -->|prose link| refunds["refunds.md"]
|
|
21
|
-
refunds -->|prose link| customers
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Files are the nodes; the Markdown links in their bodies are the directed edges.
|
|
25
|
-
Nobody declared this graph — it fell out of three files linking each other.
|
|
26
|
-
|
|
27
|
-
# Untyped on purpose
|
|
28
|
-
|
|
29
|
-
A Markdown link asserts only "these two relate." The *kind* of relationship —
|
|
30
|
-
depends-on, supersedes, derived-from — lives in the **prose around the link**,
|
|
31
|
-
never in a made-up typed-edge syntax. Both a human and an agent already
|
|
32
|
-
understand a Markdown link, which is the point of the [dual audience](../overview.md).
|
|
33
|
-
|
|
34
|
-
# What counts as an edge
|
|
35
|
-
|
|
36
|
-
- **Bundle-relative links** (e.g. `/model/graph.md`) resolve to another concept
|
|
37
|
-
and become a directed edge. Absolute bundle-relative targets are preferred so
|
|
38
|
-
links survive file moves.
|
|
39
|
-
- **External links** — `http(s)://`, `mailto:` — are surfaced separately and are
|
|
40
|
-
*not* graph edges.
|
|
41
|
-
- A link to a concept that does not exist yet is **not an error** (§5.3): it is
|
|
42
|
-
not-yet-written knowledge, which consumers MUST tolerate and the
|
|
43
|
-
[linter](../capabilities/linter.md) surfaces as backlog demand.
|
|
44
|
-
|
|
45
|
-
The [graph server](../capabilities/graph-server.md) draws these edges; a
|
|
46
|
-
degree-0 concept (no links in or out) is a *loose* file the
|
|
47
|
-
[read views](../capabilities/read-views.md) flag.
|
|
48
|
-
|
|
49
|
-
# Citations
|
|
50
|
-
|
|
51
|
-
[1] [lib/okf/markdown/links.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/markdown/links.rb) — link extraction.
|
|
52
|
-
[2] [SPEC.md §5](https://github.com/serradura/okf-gem/blob/main/lib/okf/skill/reference/SPEC.md) — cross-links and tolerance of broken targets.
|
data/.okf/format/frontmatter.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Format
|
|
3
|
-
title: Frontmatter (spec §4)
|
|
4
|
-
description: The YAML header on every concept, parsed through the gem's single, hardened YAML gateway.
|
|
5
|
-
resource: lib/okf/markdown/frontmatter.rb
|
|
6
|
-
tags: [format, yaml, frontmatter]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
Every [concept](../model/concept.md) opens with a YAML frontmatter block delimited
|
|
13
|
-
by `---` lines. `OKF::Markdown::Frontmatter` parses it and is the inverse of
|
|
14
|
-
`Concept#to_markdown`. The only **required** key is
|
|
15
|
-
[`type`](../format/okf-format.md); `title`, `description`, `resource`, `tags`, and
|
|
16
|
-
`timestamp` are recommended, and producers may add any other keys — consumers
|
|
17
|
-
preserve unknown keys and never reject a document for having them.
|
|
18
|
-
|
|
19
|
-
# The one YAML gateway
|
|
20
|
-
|
|
21
|
-
All YAML in the gem flows through this one class. That is a deliberate security
|
|
22
|
-
and portability boundary, not an accident of layering:
|
|
23
|
-
|
|
24
|
-
- it uses `safe_load` — permitting `Date`/`Time`, forbidding aliases — so a
|
|
25
|
-
bundle can never execute arbitrary Ruby on load;
|
|
26
|
-
- it carries the Psych `<3.1` positional-argument shim, so the gem parses
|
|
27
|
-
identically on the old Ruby versions the [2.4 floor](../design/ruby-floor.md)
|
|
28
|
-
targets;
|
|
29
|
-
- `stringify_keys` lives here so the gem needs no ActiveSupport (see
|
|
30
|
-
[runtime dependencies](../design/runtime-dependencies.md)).
|
|
31
|
-
|
|
32
|
-
The rule is enforced by convention: `YAML.safe_load` / `YAML.load` appear
|
|
33
|
-
**nowhere else** in the codebase.
|
|
34
|
-
|
|
35
|
-
# Citations
|
|
36
|
-
|
|
37
|
-
[1] [lib/okf/markdown/frontmatter.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/markdown/frontmatter.rb) — the parser and the Psych shim.
|
|
38
|
-
[2] [SPEC.md §4](https://github.com/serradura/okf-gem/blob/main/lib/okf/skill/reference/SPEC.md) — concept documents and frontmatter.
|
data/.okf/format/index.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# The format
|
|
2
|
-
|
|
3
|
-
What Open Knowledge Format v0.1 is — the substrate the gem reads, validates, and
|
|
4
|
-
serves. The gem operates on this format; it does not extend it.
|
|
5
|
-
|
|
6
|
-
* [OKF v0.1](okf-format.md) - portable knowledge as a directory of Markdown + YAML frontmatter files.
|
|
7
|
-
* [Frontmatter](frontmatter.md) - the YAML header on every concept (spec §4) and the gem's one YAML gateway.
|
|
8
|
-
* [Cross-links](cross-links.md) - plain Markdown links that become the knowledge graph's edges (spec §5).
|
|
9
|
-
* [Citations](citations.md) - the provenance convention that keeps a bundle trustworthy (spec §8).
|
data/.okf/format/okf-format.md
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Format
|
|
3
|
-
title: Open Knowledge Format v0.1
|
|
4
|
-
description: Portable knowledge as a directory of Markdown files with YAML frontmatter that humans and agents both read.
|
|
5
|
-
resource: lib/okf/skill/reference/SPEC.md
|
|
6
|
-
tags: [okf, format, conformance]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
OKF is a bundle: a directory of UTF-8 Markdown files. Each non-reserved file is
|
|
13
|
-
one **concept** with two parts — a [YAML frontmatter block](frontmatter.md) and a
|
|
14
|
-
Markdown body. Knowledge is the files; the graph is
|
|
15
|
-
[how they link](cross-links.md). There is no schema registry, no runtime, no
|
|
16
|
-
SDK — the format is minimal on purpose, and the gem is what gives it leverage.
|
|
17
|
-
|
|
18
|
-
# Reserved files
|
|
19
|
-
|
|
20
|
-
Two filenames are reserved and are never concepts:
|
|
21
|
-
|
|
22
|
-
| File | Role | Constraint |
|
|
23
|
-
|------|------|------------|
|
|
24
|
-
| `index.md` | a directory listing for progressive disclosure | carries **no** frontmatter — except the bundle-root `index.md`, which may carry *only* `okf_version` |
|
|
25
|
-
| `log.md` | a dated change history, newest first | date headings are ISO `YYYY-MM-DD` |
|
|
26
|
-
|
|
27
|
-
# §9 conformance is narrow and tolerant
|
|
28
|
-
|
|
29
|
-
The spec makes only three conditions **hard**, and the
|
|
30
|
-
[validator](../capabilities/validator.md) fails a bundle on any of them:
|
|
31
|
-
|
|
32
|
-
1. **§9.1** — every non-reserved `.md` file has a parseable frontmatter block;
|
|
33
|
-
2. **§9.2** — every such block has a **non-empty `type`**;
|
|
34
|
-
3. **§9.3** — every reserved file present is well-formed.
|
|
35
|
-
|
|
36
|
-
Everything else is soft guidance a consumer MUST tolerate: missing optional
|
|
37
|
-
fields, unknown [`type`](../model/concept.md) values, and **broken cross-links**.
|
|
38
|
-
Judging those is the [linter](../capabilities/linter.md)'s job, held separate on
|
|
39
|
-
purpose.
|
|
40
|
-
|
|
41
|
-
# Citations
|
|
42
|
-
|
|
43
|
-
[1] [SPEC.md](https://github.com/serradura/okf-gem/blob/main/lib/okf/skill/reference/SPEC.md) — the OKF v0.1 specification, authored by Google Cloud Platform, redistributed under Apache 2.0.
|
data/.okf/index.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
okf_version: "0.1"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# okf-gem capabilities
|
|
6
|
-
|
|
7
|
-
What the `okf` gem does over an Open Knowledge Format v0.1 bundle: read it,
|
|
8
|
-
validate it, lint it, serve it, and let an agent author it. Start here.
|
|
9
|
-
|
|
10
|
-
* [Overview](overview.md) - the gem at a glance: the five capabilities and the design ethos behind them.
|
|
11
|
-
* [Command line](cli.md) - the `okf` executable — the one layer that parses argv, prints, and exits.
|
|
12
|
-
|
|
13
|
-
# Areas
|
|
14
|
-
|
|
15
|
-
* [The format](format/) - what OKF v0.1 is — the Markdown + YAML frontmatter the gem operates on.
|
|
16
|
-
* [The model](model/) - the pure in-memory data structures: concept, bundle, graph.
|
|
17
|
-
* [Capabilities](capabilities/) - the five things the gem does: validate, lint, serve, the library, the skill.
|
|
18
|
-
* [Design constraints](design/) - the enforced boundaries that keep the gem light and honest.
|
data/.okf/log.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Update Log
|
|
2
|
-
|
|
3
|
-
## 2026-07-12
|
|
4
|
-
* **Sync**: caught the bundle up with the gem at 1.1.0 — the [graph server](capabilities/graph-server.md) now sanitizes each fetched body with DOMPurify before rendering, so the [server trust boundary](design/server-trust-boundary.md) closes the on-demand render path (its [design listing](design/) reworded to match), and the [library API](capabilities/library-api.md) notes that `require "okf"` loads the library alone now that the CLI and skill load on demand.
|
|
5
|
-
* **Sync**: caught the bundle up with the CLI at 1.0.0 — documented the new `index` command (the §6 progressive-disclosure map, the read view that sees the reserved `index.md` layer), compact-by-default JSON with `--pretty`, and `--fields`/`--except` projection on the list views, in [read views](capabilities/read-views.md) plus the `index`-verb enumerations in the [CLI](cli.md), the [overview](overview.md), and the [capabilities](capabilities/) index listing.
|
|
6
|
-
|
|
7
|
-
## 2026-07-11
|
|
8
|
-
* **Creation**: seeded the bundle documenting okf-gem's capabilities at version 0.1.0 — the [overview](overview.md), the [CLI](cli.md), and the [format](format/), [model](model/), [capabilities](capabilities/), and [design](design/) areas.
|
|
9
|
-
* **Update**: added Mermaid diagrams (tagged `diagram`) to five concepts — [overview](overview.md), the [core/shell split](design/core-shell-split.md), the [graph server](capabilities/graph-server.md), the [library API](capabilities/library-api.md), and [cross-links](format/cross-links.md).
|
|
10
|
-
* **Sync**: caught the bundle up with the CLI — documented the new `types` command, the cross-view `--type`/`--area`/`--tag` filters, and `tags --by type|area` in [read views](capabilities/read-views.md), the [CLI](cli.md) front end, the [graph](model/graph.md) indexes, and the [capabilities](capabilities/) index listing.
|
data/.okf/model/bundle.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Component
|
|
3
|
-
title: OKF::Bundle
|
|
4
|
-
description: The pure in-memory collection of concepts that validate, lint, and graph run over.
|
|
5
|
-
resource: lib/okf/bundle.rb
|
|
6
|
-
tags: [model, bundle, pure]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
`OKF::Bundle` is a set of [concepts](concept.md) held together in memory, with no
|
|
13
|
-
disk involved. It is the object the three judging capabilities operate on:
|
|
14
|
-
`#validate`, `#lint`, and `#graph` each hand the bundle to a dedicated pure
|
|
15
|
-
class and return a result. A bundle also carries the reserved files
|
|
16
|
-
(`index.md`, `log.md`) and — importantly — an `unparseable` list.
|
|
17
|
-
|
|
18
|
-
# Best-effort by construction
|
|
19
|
-
|
|
20
|
-
When a bundle is built from disk, files that fail to parse do not vanish and do
|
|
21
|
-
not abort the build: they are collected in `bundle.unparseable`. That is what
|
|
22
|
-
lets [graph](graph.md), the [server](../capabilities/graph-server.md), and the
|
|
23
|
-
[read views](../capabilities/read-views.md) render everything that *is* valid
|
|
24
|
-
while the [CLI](../cli.md) notes the skips on stderr — §9's best-effort posture,
|
|
25
|
-
made structural.
|
|
26
|
-
|
|
27
|
-
# Build it from data, not only from files
|
|
28
|
-
|
|
29
|
-
Because the bundle is pure, an embedding application can construct concepts
|
|
30
|
-
straight from its own records — no Markdown round-trip — and still get validate,
|
|
31
|
-
lint, and graph for free. This is the surface the
|
|
32
|
-
[library API](../capabilities/library-api.md) exposes to, say, a Rails store that
|
|
33
|
-
already holds knowledge as rows. It also feeds the shared `#catalog`, the data
|
|
34
|
-
behind every read view.
|
|
35
|
-
|
|
36
|
-
# Citations
|
|
37
|
-
|
|
38
|
-
[1] [lib/okf/bundle.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/bundle.rb) — the in-memory collection and its `#validate` / `#lint` / `#graph` entry points.
|
data/.okf/model/concept.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Component
|
|
3
|
-
title: OKF::Concept
|
|
4
|
-
description: The pure in-memory model of a single OKF file — frontmatter, body, and a stable id.
|
|
5
|
-
resource: lib/okf/concept.rb
|
|
6
|
-
tags: [model, concept, pure]
|
|
7
|
-
timestamp: 2026-07-11T12:00:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
`OKF::Concept` is the atomic node: a `path`, a parsed
|
|
13
|
-
[`frontmatter`](../format/frontmatter.md) hash, and a Markdown `body`. It is
|
|
14
|
-
[pure](../design/core-shell-split.md) — it holds no file handle and does no I/O.
|
|
15
|
-
The on-disk counterpart is `OKF::Concept::File`, part of the
|
|
16
|
-
[library API](../capabilities/library-api.md).
|
|
17
|
-
|
|
18
|
-
# The id is the concept's identity
|
|
19
|
-
|
|
20
|
-
`#id` is the `path` minus `.md` (e.g. `model/graph.md` → `model/graph`). That id
|
|
21
|
-
is the concept's **stable identifier** across the whole system — it is the graph
|
|
22
|
-
node key, the link target, and the thing you name a concept for. Name a file for
|
|
23
|
-
what it *is*, not where it sits, because the id follows the path.
|
|
24
|
-
|
|
25
|
-
# What it derives from its own content
|
|
26
|
-
|
|
27
|
-
The concept parses its body on demand into the structural facts the rest of the
|
|
28
|
-
gem consumes:
|
|
29
|
-
|
|
30
|
-
- `#type`, `#title`, `#description`, `#resource`, `#tags`, `#timestamp` — typed
|
|
31
|
-
reads over the frontmatter;
|
|
32
|
-
- `#links` — the bundle-relative [cross-links](../format/cross-links.md) (edges);
|
|
33
|
-
- `#external_links` — URLs and `mailto:` (not edges);
|
|
34
|
-
- `#citations` — the [`# Citations`](../format/citations.md) entries;
|
|
35
|
-
- `#to_markdown` — the inverse of the frontmatter parser;
|
|
36
|
-
- `#lint` — the concept-scoped [lint](../capabilities/linter.md) checks in isolation.
|
|
37
|
-
|
|
38
|
-
A concept never decides conformance alone; a [bundle](bundle.md) does, because
|
|
39
|
-
some checks (duplicate titles, missing link targets) are only meaningful across
|
|
40
|
-
the set.
|
|
41
|
-
|
|
42
|
-
# Citations
|
|
43
|
-
|
|
44
|
-
[1] [lib/okf/concept.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/concept.rb) — the pure concept model.
|
data/.okf/model/graph.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: Component
|
|
3
|
-
title: OKF::Bundle::Graph
|
|
4
|
-
description: The in-memory knowledge graph — concepts as nodes, cross-links as directed edges, with type and tag indexes.
|
|
5
|
-
resource: lib/okf/bundle/graph.rb
|
|
6
|
-
tags: [model, graph, pure]
|
|
7
|
-
timestamp: 2026-07-11T21:40:00Z
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Overview
|
|
11
|
-
|
|
12
|
-
`OKF::Bundle::Graph` turns a [bundle](bundle.md) into nodes and edges:
|
|
13
|
-
[concepts](concept.md) become nodes keyed by id, and bundle-relative
|
|
14
|
-
[cross-links](../format/cross-links.md) become directed edges. It is pure — it
|
|
15
|
-
carries no presentation concerns; sizing and colour belong to a renderer like
|
|
16
|
-
the [graph server](../capabilities/graph-server.md).
|
|
17
|
-
|
|
18
|
-
# Fidelity is a build option
|
|
19
|
-
|
|
20
|
-
The same graph ships at three weights, so a client downloads only what it needs
|
|
21
|
-
and fetches the rest on demand:
|
|
22
|
-
|
|
23
|
-
| Build | Node payload |
|
|
24
|
-
|-------|--------------|
|
|
25
|
-
| default (`body: true`) | id, type, title, description, tags, **body** |
|
|
26
|
-
| `body: false` | everything but the body |
|
|
27
|
-
| `minimal: true` | just id and title — the leanest payload to draw |
|
|
28
|
-
|
|
29
|
-
# Indexes come free at every weight
|
|
30
|
-
|
|
31
|
-
Regardless of node fidelity, the graph exposes two inverted indexes computed from
|
|
32
|
-
every concept:
|
|
33
|
-
|
|
34
|
-
- `type_index` — `{ type => [id, …] }`, so even a minimal client can colour nodes
|
|
35
|
-
by [`type`](concept.md);
|
|
36
|
-
- `tag_index` — `{ tag => [id, …] }`, so it can filter by tag.
|
|
37
|
-
|
|
38
|
-
Those indexes, plus `unlinked_ids` (degree-0 nodes), are what the
|
|
39
|
-
[read views](../capabilities/read-views.md) — `types`, `tags`, `stats`, `loose`
|
|
40
|
-
— are built from, and what their `--type`/`--area`/`--tag` filters match against.
|
|
41
|
-
|
|
42
|
-
# Citations
|
|
43
|
-
|
|
44
|
-
[1] [lib/okf/bundle/graph.rb](https://github.com/serradura/okf-gem/blob/main/lib/okf/bundle/graph.rb) — graph construction and the type/tag indexes.
|
data/.okf/model/index.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# The model
|
|
2
|
-
|
|
3
|
-
The pure, in-memory data structures the gem builds a bundle out of — no disk, no
|
|
4
|
-
stdio. Everything else reads or renders these.
|
|
5
|
-
|
|
6
|
-
* [Concept](concept.md) - one file's worth of knowledge: frontmatter plus body, with a stable id.
|
|
7
|
-
* [Bundle](bundle.md) - a collection of concepts you validate, lint, and graph.
|
|
8
|
-
* [Graph](graph.md) - concepts as nodes, cross-links as edges, plus type and tag indexes.
|