okf-toolkit 0.1.0__tar.gz
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.
- okf-toolkit-0.1.0/LICENSE +201 -0
- okf-toolkit-0.1.0/PKG-INFO +211 -0
- okf-toolkit-0.1.0/README.md +189 -0
- okf-toolkit-0.1.0/okf.py +869 -0
- okf-toolkit-0.1.0/okf_toolkit.egg-info/PKG-INFO +211 -0
- okf-toolkit-0.1.0/okf_toolkit.egg-info/SOURCES.txt +11 -0
- okf-toolkit-0.1.0/okf_toolkit.egg-info/dependency_links.txt +1 -0
- okf-toolkit-0.1.0/okf_toolkit.egg-info/entry_points.txt +2 -0
- okf-toolkit-0.1.0/okf_toolkit.egg-info/requires.txt +1 -0
- okf-toolkit-0.1.0/okf_toolkit.egg-info/top_level.txt +1 -0
- okf-toolkit-0.1.0/setup.cfg +4 -0
- okf-toolkit-0.1.0/setup.py +38 -0
- okf-toolkit-0.1.0/tests/test_okf.py +379 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2026] [okf-toolkit contributors]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: okf-toolkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI toolkit for working with Google's Open Knowledge Format (OKF)
|
|
5
|
+
Home-page: https://github.com/akdira/okf-toolkit
|
|
6
|
+
License: Apache 2.0
|
|
7
|
+
Project-URL: Homepage, https://www.akdira.id
|
|
8
|
+
Project-URL: Source, https://github.com/akdira/okf-toolkit
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Information Technology
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
18
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# okf-toolkit
|
|
24
|
+
|
|
25
|
+
**CLI toolkit for working with Google's Open Knowledge Format (OKF)**
|
|
26
|
+
|
|
27
|
+
okf-toolkit is a command-line tool for creating, validating, traversing, and maintaining knowledge bases stored in the Open Knowledge Format (OKF). OKF is a vendor-neutral, human-and-agent-friendly format announced by Google Cloud on June 12, 2026. It represents knowledge as a directory tree of plain-text markdown files with YAML frontmatter, making knowledge bases portable, version-controllable, and accessible to both humans and AI agents.
|
|
28
|
+
|
|
29
|
+
## What is OKF?
|
|
30
|
+
|
|
31
|
+
The Open Knowledge Format is a specification for organizing structured and unstructured knowledge in a file-system-based bundle. Each unit of knowledge — a "concept" — lives in its own `.md` file with YAML frontmatter that provides typed metadata. Key principles:
|
|
32
|
+
|
|
33
|
+
- **Simplicity:** Everything is markdown. No databases, no proprietary schemas.
|
|
34
|
+
- **Portability:** A bundle is a directory tree. Copy it, commit it to Git, distribute it via any channel.
|
|
35
|
+
- **Agent-friendly:** Typed frontmatter and clear linking make it trivial for AI agents to traverse, understand, and augment knowledge bases.
|
|
36
|
+
- **Extensibility:** Producers can add any extra frontmatter keys; consumers tolerate unknown ones.
|
|
37
|
+
- **UTF-8 throughout:** No encoding guesswork.
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
okf-toolkit provides everything you need to work with OKF bundles:
|
|
42
|
+
|
|
43
|
+
| Command | Description |
|
|
44
|
+
|-------------|----------------------------------------------------------------------------|
|
|
45
|
+
| `okf init` | Scaffold a new OKF bundle directory with index.md and log.md |
|
|
46
|
+
| `okf new` | Interactively create a new concept with guided frontmatter prompts |
|
|
47
|
+
| `okf validate` | Validate bundle structure: required fields, reserved names, UTF-8, links |
|
|
48
|
+
| `okf list` | List all concepts with their type and description |
|
|
49
|
+
| `okf show` | Display a concept's full frontmatter and body content |
|
|
50
|
+
| `okf index` | Auto-generate or refresh index.md files from concept frontmatter |
|
|
51
|
+
| `okf search`| Full-text substring search across all concept bodies |
|
|
52
|
+
| `okf graph` | Output the link graph as Mermaid or ASCII for visualization |
|
|
53
|
+
| `okf stats` | Bundle statistics: concept count, type breakdown, tag cloud, link counts |
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Clone the repository
|
|
59
|
+
git clone https://github.com/openclaw/okf-toolkit.git
|
|
60
|
+
cd okf-toolkit
|
|
61
|
+
|
|
62
|
+
# Install the dependency
|
|
63
|
+
pip install pyyaml>=6.0
|
|
64
|
+
|
|
65
|
+
# (optional) Install as a package
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Python 3.10 or newer is required. Only `pyyaml` is needed beyond the standard library.
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Initialize a new bundle
|
|
75
|
+
okf init my-knowledge-base
|
|
76
|
+
|
|
77
|
+
# Navigate into it
|
|
78
|
+
cd my-knowledge-base
|
|
79
|
+
|
|
80
|
+
# Create a concept interactively
|
|
81
|
+
okf new . tables/user-sessions
|
|
82
|
+
|
|
83
|
+
# Validate the bundle
|
|
84
|
+
okf validate .
|
|
85
|
+
|
|
86
|
+
# List all concepts
|
|
87
|
+
okf list .
|
|
88
|
+
|
|
89
|
+
# Search across concepts
|
|
90
|
+
okf search . user
|
|
91
|
+
|
|
92
|
+
# Generate index.md files from frontmatter
|
|
93
|
+
okf index .
|
|
94
|
+
|
|
95
|
+
# Show the link graph
|
|
96
|
+
okf graph .
|
|
97
|
+
|
|
98
|
+
# Get bundle statistics
|
|
99
|
+
okf stats .
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Usage Examples
|
|
103
|
+
|
|
104
|
+
### Creating a New Knowledge Base
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
okf init docs/knowledge-base
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This creates:
|
|
111
|
+
```
|
|
112
|
+
docs/knowledge-base/
|
|
113
|
+
├── index.md # Directory listing (auto-editable)
|
|
114
|
+
└── log.md # Update history
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Adding a Concept
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
okf new docs/knowledge-base api/checkout-endpoint
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
You'll be prompted for:
|
|
124
|
+
- `type` (required) — e.g., "API Endpoint", "BigQuery Table", "Playbook"
|
|
125
|
+
- `title` (optional)
|
|
126
|
+
- `description` (optional)
|
|
127
|
+
- `resource` (optional URI)
|
|
128
|
+
- `tags` (optional, comma-separated)
|
|
129
|
+
|
|
130
|
+
The tool generates a markdown file with proper YAML frontmatter and a template body.
|
|
131
|
+
|
|
132
|
+
### Validating a Bundle
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
okf validate docs/knowledge-base
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Checks every `.md` file for:
|
|
139
|
+
- Valid UTF-8 encoding
|
|
140
|
+
- Reserved filename violations (`index.md` and `log.md` must not have a `type` field)
|
|
141
|
+
- Required frontmatter fields (`type`)
|
|
142
|
+
- YAML parseability
|
|
143
|
+
- Broken markdown cross-links (reported as warnings)
|
|
144
|
+
- Type correctness for `tags` (must be a list) and `timestamp` (must be a string)
|
|
145
|
+
|
|
146
|
+
Exits with code 1 if any errors found, 0 otherwise.
|
|
147
|
+
|
|
148
|
+
### Searching Across Concepts
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
okf search docs/knowledge-base revenue
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Performs case-insensitive substring matching across all concept files (excluding `index.md` and `log.md`). Shows the matching file, its type, and a highlighted snippet around the match.
|
|
155
|
+
|
|
156
|
+
### Generating Index Files
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
okf index docs/knowledge-base
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Walks every directory containing concepts and generates or updates an `index.md` with properly formatted links, titles, types, and descriptions pulled from frontmatter. Skips directories where nothing has changed.
|
|
163
|
+
|
|
164
|
+
### Visualizing the Link Graph
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Mermaid format (default) — paste into GitHub-flavored markdown
|
|
168
|
+
okf graph docs/knowledge-base
|
|
169
|
+
|
|
170
|
+
# ASCII format for terminal inspection
|
|
171
|
+
okf graph docs/knowledge-base --format ascii
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Why OKF Matters for AI Agents
|
|
175
|
+
|
|
176
|
+
AI agents that work with knowledge bases face two fundamental challenges: understanding the structure of the knowledge, and knowing how to add to it. OKF addresses both:
|
|
177
|
+
|
|
178
|
+
1. **Typed frontmatter gives agents semantic understanding.** When an agent encounters a concept file, the `type` field immediately tells it what kind of thing this is — a table, a metric, a playbook, a reference. This reduces hallucination and improves retrieval accuracy.
|
|
179
|
+
|
|
180
|
+
2. **Clear linking creates a traversable graph.** Agents can follow markdown links between concepts just like humans do, building a graph of related knowledge.
|
|
181
|
+
|
|
182
|
+
3. **The format is append-friendly.** An agent that discovers new knowledge can create a new `.md` file with proper frontmatter using the same tools a human would.
|
|
183
|
+
|
|
184
|
+
4. **Version control works out of the box.** Git tracks every change to every concept. Agents can see what changed, when, and why.
|
|
185
|
+
|
|
186
|
+
5. **No lock-in.** Unlike a proprietary knowledge graph or database, OKF bundles are plain files. Any tool — AI or otherwise — that can read markdown and YAML can work with OKF.
|
|
187
|
+
|
|
188
|
+
## Contributing
|
|
189
|
+
|
|
190
|
+
Contributions are welcome! Here's how to get started:
|
|
191
|
+
|
|
192
|
+
1. **Read the AGENTS.md** file in the repository root — it contains detailed instructions for AI agents and human contributors alike.
|
|
193
|
+
2. **Open an issue** to discuss your proposed change before writing code.
|
|
194
|
+
3. **Fork the repository** and create a feature branch.
|
|
195
|
+
4. **Write tests** for any new functionality. Tests live in `tests/` and use Python's `unittest` framework.
|
|
196
|
+
5. **Ensure existing tests pass** with `python3 -m unittest tests/test_okf.py -v`.
|
|
197
|
+
6. **Submit a pull request** with a clear description of what and why.
|
|
198
|
+
|
|
199
|
+
Conventions:
|
|
200
|
+
- Python 3.10+ only, stdlib-first approach
|
|
201
|
+
- `pyyaml` is the sole external dependency — keep it that way
|
|
202
|
+
- New CLI commands should follow the existing pattern (see `cmd_*` functions in `okf.py`)
|
|
203
|
+
- Keep ANSI color helpers in the `_color` / `green`/`red`/etc. functions
|
|
204
|
+
|
|
205
|
+
## Credits
|
|
206
|
+
|
|
207
|
+
Created and maintained by [akdira](https://www.akdira.id).
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
Apache 2.0. See [LICENSE](LICENSE) for the full text.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# okf-toolkit
|
|
2
|
+
|
|
3
|
+
**CLI toolkit for working with Google's Open Knowledge Format (OKF)**
|
|
4
|
+
|
|
5
|
+
okf-toolkit is a command-line tool for creating, validating, traversing, and maintaining knowledge bases stored in the Open Knowledge Format (OKF). OKF is a vendor-neutral, human-and-agent-friendly format announced by Google Cloud on June 12, 2026. It represents knowledge as a directory tree of plain-text markdown files with YAML frontmatter, making knowledge bases portable, version-controllable, and accessible to both humans and AI agents.
|
|
6
|
+
|
|
7
|
+
## What is OKF?
|
|
8
|
+
|
|
9
|
+
The Open Knowledge Format is a specification for organizing structured and unstructured knowledge in a file-system-based bundle. Each unit of knowledge — a "concept" — lives in its own `.md` file with YAML frontmatter that provides typed metadata. Key principles:
|
|
10
|
+
|
|
11
|
+
- **Simplicity:** Everything is markdown. No databases, no proprietary schemas.
|
|
12
|
+
- **Portability:** A bundle is a directory tree. Copy it, commit it to Git, distribute it via any channel.
|
|
13
|
+
- **Agent-friendly:** Typed frontmatter and clear linking make it trivial for AI agents to traverse, understand, and augment knowledge bases.
|
|
14
|
+
- **Extensibility:** Producers can add any extra frontmatter keys; consumers tolerate unknown ones.
|
|
15
|
+
- **UTF-8 throughout:** No encoding guesswork.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
okf-toolkit provides everything you need to work with OKF bundles:
|
|
20
|
+
|
|
21
|
+
| Command | Description |
|
|
22
|
+
|-------------|----------------------------------------------------------------------------|
|
|
23
|
+
| `okf init` | Scaffold a new OKF bundle directory with index.md and log.md |
|
|
24
|
+
| `okf new` | Interactively create a new concept with guided frontmatter prompts |
|
|
25
|
+
| `okf validate` | Validate bundle structure: required fields, reserved names, UTF-8, links |
|
|
26
|
+
| `okf list` | List all concepts with their type and description |
|
|
27
|
+
| `okf show` | Display a concept's full frontmatter and body content |
|
|
28
|
+
| `okf index` | Auto-generate or refresh index.md files from concept frontmatter |
|
|
29
|
+
| `okf search`| Full-text substring search across all concept bodies |
|
|
30
|
+
| `okf graph` | Output the link graph as Mermaid or ASCII for visualization |
|
|
31
|
+
| `okf stats` | Bundle statistics: concept count, type breakdown, tag cloud, link counts |
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Clone the repository
|
|
37
|
+
git clone https://github.com/openclaw/okf-toolkit.git
|
|
38
|
+
cd okf-toolkit
|
|
39
|
+
|
|
40
|
+
# Install the dependency
|
|
41
|
+
pip install pyyaml>=6.0
|
|
42
|
+
|
|
43
|
+
# (optional) Install as a package
|
|
44
|
+
pip install -e .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Python 3.10 or newer is required. Only `pyyaml` is needed beyond the standard library.
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Initialize a new bundle
|
|
53
|
+
okf init my-knowledge-base
|
|
54
|
+
|
|
55
|
+
# Navigate into it
|
|
56
|
+
cd my-knowledge-base
|
|
57
|
+
|
|
58
|
+
# Create a concept interactively
|
|
59
|
+
okf new . tables/user-sessions
|
|
60
|
+
|
|
61
|
+
# Validate the bundle
|
|
62
|
+
okf validate .
|
|
63
|
+
|
|
64
|
+
# List all concepts
|
|
65
|
+
okf list .
|
|
66
|
+
|
|
67
|
+
# Search across concepts
|
|
68
|
+
okf search . user
|
|
69
|
+
|
|
70
|
+
# Generate index.md files from frontmatter
|
|
71
|
+
okf index .
|
|
72
|
+
|
|
73
|
+
# Show the link graph
|
|
74
|
+
okf graph .
|
|
75
|
+
|
|
76
|
+
# Get bundle statistics
|
|
77
|
+
okf stats .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage Examples
|
|
81
|
+
|
|
82
|
+
### Creating a New Knowledge Base
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
okf init docs/knowledge-base
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
This creates:
|
|
89
|
+
```
|
|
90
|
+
docs/knowledge-base/
|
|
91
|
+
├── index.md # Directory listing (auto-editable)
|
|
92
|
+
└── log.md # Update history
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Adding a Concept
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
okf new docs/knowledge-base api/checkout-endpoint
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
You'll be prompted for:
|
|
102
|
+
- `type` (required) — e.g., "API Endpoint", "BigQuery Table", "Playbook"
|
|
103
|
+
- `title` (optional)
|
|
104
|
+
- `description` (optional)
|
|
105
|
+
- `resource` (optional URI)
|
|
106
|
+
- `tags` (optional, comma-separated)
|
|
107
|
+
|
|
108
|
+
The tool generates a markdown file with proper YAML frontmatter and a template body.
|
|
109
|
+
|
|
110
|
+
### Validating a Bundle
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
okf validate docs/knowledge-base
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Checks every `.md` file for:
|
|
117
|
+
- Valid UTF-8 encoding
|
|
118
|
+
- Reserved filename violations (`index.md` and `log.md` must not have a `type` field)
|
|
119
|
+
- Required frontmatter fields (`type`)
|
|
120
|
+
- YAML parseability
|
|
121
|
+
- Broken markdown cross-links (reported as warnings)
|
|
122
|
+
- Type correctness for `tags` (must be a list) and `timestamp` (must be a string)
|
|
123
|
+
|
|
124
|
+
Exits with code 1 if any errors found, 0 otherwise.
|
|
125
|
+
|
|
126
|
+
### Searching Across Concepts
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
okf search docs/knowledge-base revenue
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Performs case-insensitive substring matching across all concept files (excluding `index.md` and `log.md`). Shows the matching file, its type, and a highlighted snippet around the match.
|
|
133
|
+
|
|
134
|
+
### Generating Index Files
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
okf index docs/knowledge-base
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Walks every directory containing concepts and generates or updates an `index.md` with properly formatted links, titles, types, and descriptions pulled from frontmatter. Skips directories where nothing has changed.
|
|
141
|
+
|
|
142
|
+
### Visualizing the Link Graph
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Mermaid format (default) — paste into GitHub-flavored markdown
|
|
146
|
+
okf graph docs/knowledge-base
|
|
147
|
+
|
|
148
|
+
# ASCII format for terminal inspection
|
|
149
|
+
okf graph docs/knowledge-base --format ascii
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Why OKF Matters for AI Agents
|
|
153
|
+
|
|
154
|
+
AI agents that work with knowledge bases face two fundamental challenges: understanding the structure of the knowledge, and knowing how to add to it. OKF addresses both:
|
|
155
|
+
|
|
156
|
+
1. **Typed frontmatter gives agents semantic understanding.** When an agent encounters a concept file, the `type` field immediately tells it what kind of thing this is — a table, a metric, a playbook, a reference. This reduces hallucination and improves retrieval accuracy.
|
|
157
|
+
|
|
158
|
+
2. **Clear linking creates a traversable graph.** Agents can follow markdown links between concepts just like humans do, building a graph of related knowledge.
|
|
159
|
+
|
|
160
|
+
3. **The format is append-friendly.** An agent that discovers new knowledge can create a new `.md` file with proper frontmatter using the same tools a human would.
|
|
161
|
+
|
|
162
|
+
4. **Version control works out of the box.** Git tracks every change to every concept. Agents can see what changed, when, and why.
|
|
163
|
+
|
|
164
|
+
5. **No lock-in.** Unlike a proprietary knowledge graph or database, OKF bundles are plain files. Any tool — AI or otherwise — that can read markdown and YAML can work with OKF.
|
|
165
|
+
|
|
166
|
+
## Contributing
|
|
167
|
+
|
|
168
|
+
Contributions are welcome! Here's how to get started:
|
|
169
|
+
|
|
170
|
+
1. **Read the AGENTS.md** file in the repository root — it contains detailed instructions for AI agents and human contributors alike.
|
|
171
|
+
2. **Open an issue** to discuss your proposed change before writing code.
|
|
172
|
+
3. **Fork the repository** and create a feature branch.
|
|
173
|
+
4. **Write tests** for any new functionality. Tests live in `tests/` and use Python's `unittest` framework.
|
|
174
|
+
5. **Ensure existing tests pass** with `python3 -m unittest tests/test_okf.py -v`.
|
|
175
|
+
6. **Submit a pull request** with a clear description of what and why.
|
|
176
|
+
|
|
177
|
+
Conventions:
|
|
178
|
+
- Python 3.10+ only, stdlib-first approach
|
|
179
|
+
- `pyyaml` is the sole external dependency — keep it that way
|
|
180
|
+
- New CLI commands should follow the existing pattern (see `cmd_*` functions in `okf.py`)
|
|
181
|
+
- Keep ANSI color helpers in the `_color` / `green`/`red`/etc. functions
|
|
182
|
+
|
|
183
|
+
## Credits
|
|
184
|
+
|
|
185
|
+
Created and maintained by [akdira](https://www.akdira.id).
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
Apache 2.0. See [LICENSE](LICENSE) for the full text.
|