okf-cli 0.8.1__tar.gz → 0.9.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.
Files changed (59) hide show
  1. {okf_cli-0.8.1 → okf_cli-0.9.0}/AGENTS.md +2 -2
  2. {okf_cli-0.8.1 → okf_cli-0.9.0}/PKG-INFO +74 -21
  3. okf_cli-0.9.0/README.md +132 -0
  4. {okf_cli-0.8.1 → okf_cli-0.9.0}/pyproject.toml +1 -1
  5. {okf_cli-0.8.1 → okf_cli-0.9.0}/skills/okf-cli/SKILL.md +24 -0
  6. okf_cli-0.9.0/src/okf/api.py +1415 -0
  7. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/cli.py +2 -0
  8. okf_cli-0.9.0/src/okf/commands/reindex.py +29 -0
  9. okf_cli-0.9.0/src/okf/commands/serve_mcp.py +213 -0
  10. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/core.py +68 -29
  11. {okf_cli-0.8.1 → okf_cli-0.9.0}/tests/test_api.py +441 -0
  12. {okf_cli-0.8.1 → okf_cli-0.9.0}/tests/test_cli.py +42 -0
  13. okf_cli-0.9.0/tests/test_mcp.py +297 -0
  14. {okf_cli-0.8.1 → okf_cli-0.9.0}/uv.lock +1 -1
  15. {okf_cli-0.8.1 → okf_cli-0.9.0}/wiki/architecture.md +43 -25
  16. {okf_cli-0.8.1 → okf_cli-0.9.0}/wiki/domain-model.md +10 -4
  17. {okf_cli-0.8.1 → okf_cli-0.9.0}/wiki/operations.md +1 -1
  18. {okf_cli-0.8.1 → okf_cli-0.9.0}/wiki/quickstart.md +16 -4
  19. {okf_cli-0.8.1 → okf_cli-0.9.0}/wiki/testing.md +10 -3
  20. {okf_cli-0.8.1 → okf_cli-0.9.0}/wiki/workflows.md +41 -8
  21. okf_cli-0.8.1/README.md +0 -79
  22. okf_cli-0.8.1/src/okf/api.py +0 -780
  23. okf_cli-0.8.1/src/okf/commands/serve_mcp.py +0 -97
  24. okf_cli-0.8.1/tests/test_mcp.py +0 -133
  25. {okf_cli-0.8.1 → okf_cli-0.9.0}/.agents/skills/wiki/SKILL.md +0 -0
  26. {okf_cli-0.8.1 → okf_cli-0.9.0}/.github/workflows/publish.yml +0 -0
  27. {okf_cli-0.8.1 → okf_cli-0.9.0}/.github/workflows/test.yml +0 -0
  28. {okf_cli-0.8.1 → okf_cli-0.9.0}/.gitignore +0 -0
  29. {okf_cli-0.8.1 → okf_cli-0.9.0}/.last-update.json +0 -0
  30. {okf_cli-0.8.1 → okf_cli-0.9.0}/LICENSE +0 -0
  31. {okf_cli-0.8.1 → okf_cli-0.9.0}/SPEC/OKF_SPEC_V0_1.md +0 -0
  32. {okf_cli-0.8.1 → okf_cli-0.9.0}/SPEC/OKF_SPEC_V0_2.md +0 -0
  33. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/.okfignore +0 -0
  34. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/README.md +0 -0
  35. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/blank-line/no-blank.md +0 -0
  36. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/blank-line/with-blank.md +0 -0
  37. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/computations/revenue.md +0 -0
  38. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/datasets/sales.md +0 -0
  39. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/domain.md +0 -0
  40. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/loose/deep/no-heading.md +0 -0
  41. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/loose/no-desc.md +0 -0
  42. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/loose/no-title.md +0 -0
  43. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/metrics/income-statement.md +0 -0
  44. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/playbooks/incident-response.md +0 -0
  45. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/playbooks/oncall-guide.md +0 -0
  46. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/references/revenue-recognition.md +0 -0
  47. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/smoke-ignore.md +0 -0
  48. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/tables/customers.md +0 -0
  49. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/tables/orders.md +0 -0
  50. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/tables/partitions/2026/q1/jan/january.md +0 -0
  51. {okf_cli-0.8.1 → okf_cli-0.9.0}/example/tables/partitions/daily.md +0 -0
  52. {okf_cli-0.8.1 → okf_cli-0.9.0}/skills/writing-knowledge-base/SKILL.md +0 -0
  53. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/__init__.py +0 -0
  54. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/commands/__init__.py +0 -0
  55. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/commands/bundle.py +0 -0
  56. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/commands/list.py +0 -0
  57. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/commands/read.py +0 -0
  58. {okf_cli-0.8.1 → okf_cli-0.9.0}/src/okf/commands/validate.py +0 -0
  59. {okf_cli-0.8.1 → okf_cli-0.9.0}/tests/test_core.py +0 -0
@@ -21,8 +21,8 @@ Python 3.11+, **uv**, **typer**, **pyyaml**, **rich**, **pytest**, **ruff**, **h
21
21
  - `src/okf/cli.py` — Typer entrypoint and command registration
22
22
  - `src/okf/api.py` — programmatic API; all business logic lives here
23
23
  - `src/okf/core.py` — shared parsing, formatting, and conformance helpers
24
- - `src/okf/commands/` — thin CLI wrappers (`bundle`, `list`, `read`, `validate`)
25
- - `tests/` — `test_api.py`, `test_cli.py`, `test_core.py`
24
+ - `src/okf/commands/` — thin CLI wrappers (`bundle`, `list`, `read`, `reindex`, `validate`, `serve_mcp`)
25
+ - `tests/` — `test_api.py`, `test_cli.py`, `test_core.py`, `test_mcp.py`
26
26
  - `wiki/` — architecture, workflows, domain model, operations, testing notes
27
27
  - `.github/workflows/test.yml` — CI (pytest + ruff on Python 3.11)
28
28
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: okf-cli
3
- Version: 0.8.1
3
+ Version: 0.9.0
4
4
  Summary: Open Knowledge Format tooling
5
5
  License: MIT License
6
6
 
@@ -42,14 +42,46 @@ Convert plain markdown directories into [OKF](https://github.com/GoogleCloudPlat
42
42
  uv tool install okf-cli
43
43
  ```
44
44
 
45
- ### Dev quickstart
45
+ This installs the `okf` command. To include the optional MCP server support at the same time, install with the `mcp` extra instead:
46
46
 
47
47
  ```bash
48
- uv sync
49
- uv run okf --help
50
- uv run okf --version
48
+ uv tool install 'okf-cli[mcp]'
51
49
  ```
52
50
 
51
+ (If you already installed without it, reinstall with `uv tool install --force 'okf-cli[mcp]'`.)
52
+
53
+ Check the installation:
54
+
55
+ ```bash
56
+ okf --help
57
+ okf --version
58
+ ```
59
+
60
+ ## Quick example
61
+
62
+ Try it on a scratch directory:
63
+
64
+ ```bash
65
+ mkdir okf-demo
66
+ printf '# Customers\n\n> Master table of customers.\n\nOne row per customer.\n' > okf-demo/customers.md
67
+
68
+ okf bundle okf-demo
69
+ okf validate okf-demo_knowledge_base
70
+ okf list okf-demo_knowledge_base
71
+ okf read okf-demo_knowledge_base customers
72
+ ```
73
+
74
+ Your real usage will point at your own markdown directories instead:
75
+
76
+ ```bash
77
+ okf bundle my-notes
78
+ okf validate my-notes_knowledge_base
79
+ okf list my-notes_knowledge_base
80
+ okf read my-notes_knowledge_base <concept-id>
81
+ ```
82
+
83
+ Run `okf <command> --help` for options such as `--default-type`, `--force`, `--strict`, and `--dry-run`. (Without an explicit output directory, `okf bundle <input-dir>` writes to `<input-dir>_knowledge_base` in the current directory.)
84
+
53
85
  ## Commands
54
86
 
55
87
  | Command | Purpose |
@@ -58,23 +90,30 @@ uv run okf --version
58
90
  | `okf validate <directory>` | Check OKF v0.2 §11 conformance |
59
91
  | `okf list <directory>` | List concepts (ID, type, title, description) |
60
92
  | `okf read <directory> <concept-id>` | Print a concept by ID |
93
+ | `okf reindex <directory>` | Rebuild every `index.md` from the concepts |
61
94
  | `okf serve-mcp <directory>` | Serve a conformant bundle over MCP HTTP |
62
95
 
63
- Run `okf <command> --help` for options such as `--default-type`, `--force`, `--strict`, and `--dry-run`.
64
-
65
96
  ### MCP server
66
97
 
67
- Install the optional MCP dependency, then serve a conformant bundle over Streamable HTTP:
98
+ Install the optional MCP dependency (if you installed with `uv tool install okf-cli`, reinstall with `--force 'okf-cli[mcp]'` as shown above), then serve a conformant bundle over Streamable HTTP:
68
99
 
69
100
  ```bash
70
- uv sync --extra mcp
71
- uv run okf serve-mcp example_knowledge_base
101
+ okf serve-mcp my-bundle
72
102
  ```
73
103
 
74
- The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address; `--host 0.0.0.0` listens on all IPv4 interfaces. The server exposes read-only `list_concepts` and `read_concept` tools. Add `--token <secret>` to require the matching `Authorization: Bearer <secret>` header on MCP requests; without it, requests are unauthenticated. For example:
104
+ The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address; `--host 0.0.0.0` listens on all IPv4 interfaces. The server exposes read-only tools:
105
+
106
+ | Tool | Purpose |
107
+ | ------------------------------------- | ------------------------------------------------------------------------------------------ |
108
+ | `search(query, type, filters, limit)` | Find concepts by words in the ID, title, description, tags or any other frontmatter value |
109
+ | `browse(path)` | List a directory's concepts and subdirectories with bundle-relative IDs and paths |
110
+ | `read_concept(concept_id, section)` | Read a concept, or only one section; `links` resolves body links to concept IDs (`exists`) |
111
+ | `list_concepts()` | List every concept (prefer `search`/`browse` for large bundles) |
112
+
113
+ Every call re-reads files changed on disk since the previous call, so a bundle can be regenerated while it is served. The server instructions describe the tools and append the bundle's `AGENTS.md` when present. Add `--token <secret>` to require the matching `Authorization: Bearer <secret>` header on MCP requests; without it, requests are unauthenticated. For example:
75
114
 
76
115
  ```bash
77
- uv run okf serve-mcp example_knowledge_base --token "$OKF_MCP_TOKEN"
116
+ okf serve-mcp my-bundle --token "$OKF_MCP_TOKEN"
78
117
  ```
79
118
 
80
119
  Use HTTPS (typically through a TLS-terminating proxy) when serving beyond localhost. The token is a command-line argument and may be visible in shell history or process listings; use this option only on a trusted network, and do not treat it as a replacement for TLS.
@@ -92,22 +131,36 @@ mcp.example.com {
92
131
  Start the MCP server with authentication enabled:
93
132
 
94
133
  ```bash
95
- uv run okf serve-mcp example_knowledge_base --token "$OKF_MCP_TOKEN"
134
+ okf serve-mcp my-bundle --token "$OKF_MCP_TOKEN"
96
135
  ```
97
136
 
98
137
  Clients connect to `https://mcp.example.com/mcp` and send `Authorization: Bearer <token>`. Keep port `8000` private; Caddy should be the public entry point. Caddy can provision HTTPS automatically when the domain points to the server and is reachable on the required ports.
99
138
 
100
- ## Quick example
139
+ ## Python library
101
140
 
102
- ```bash
103
- uv run okf bundle example --default-type reference --force
104
- uv run okf validate example_knowledge_base
105
- uv run okf list example_knowledge_base
106
- uv run okf read example_knowledge_base tables/customers
141
+ `src/okf/api.py` is usable directly as a library:
142
+
143
+ ```python
144
+ from okf.api import Bundle, bundle, reindex, validate, write_concept
145
+
146
+ result = bundle("example", "out", default_type="reference", force=True)
147
+ assert validate("out").ok
148
+
149
+ # Programs that generate concepts themselves keep every frontmatter key as given.
150
+ write_concept(
151
+ "out", "tables/invoices", {"type": "tables", "title": "Invoices"}, "Body."
152
+ )
153
+
154
+ # Rebuild index.md files after concepts were added or removed directly.
155
+ reindex("out") # also: `okf reindex out`; stale indexes are emptied, never deleted
156
+
157
+ # Repeated reads: load once, then search and read from memory.
158
+ kb = Bundle.open("out")
159
+ kb.search("customer", type_="tables")
160
+ kb.read("tables/customers", section="Schema").body
107
161
  ```
108
162
 
109
163
  ## Documentation
110
164
 
111
- - Detailed user and contributor docs: [wiki/quickstart.md](wiki/quickstart.md)
112
- - Agent contributor context: [AGENTS.md](AGENTS.md)
113
165
  - OKF v0.2 specification: [SPEC/OKF_SPEC_V0_2.md](SPEC/OKF_SPEC_V0_2.md)
166
+ - Development and contributor docs: [wiki/quickstart.md](wiki/quickstart.md) and [AGENTS.md](AGENTS.md)
@@ -0,0 +1,132 @@
1
+ # okf-cli — Open Knowledge Format tooling
2
+
3
+ Convert plain markdown directories into [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)-conformant knowledge bundles. `okf bundle` generates YAML frontmatter, concept types, provenance, and per-directory `index.md` files; `okf validate`, `okf list`, and `okf read` consume the resulting bundle.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ uv tool install okf-cli
9
+ ```
10
+
11
+ This installs the `okf` command. To include the optional MCP server support at the same time, install with the `mcp` extra instead:
12
+
13
+ ```bash
14
+ uv tool install 'okf-cli[mcp]'
15
+ ```
16
+
17
+ (If you already installed without it, reinstall with `uv tool install --force 'okf-cli[mcp]'`.)
18
+
19
+ Check the installation:
20
+
21
+ ```bash
22
+ okf --help
23
+ okf --version
24
+ ```
25
+
26
+ ## Quick example
27
+
28
+ Try it on a scratch directory:
29
+
30
+ ```bash
31
+ mkdir okf-demo
32
+ printf '# Customers\n\n> Master table of customers.\n\nOne row per customer.\n' > okf-demo/customers.md
33
+
34
+ okf bundle okf-demo
35
+ okf validate okf-demo_knowledge_base
36
+ okf list okf-demo_knowledge_base
37
+ okf read okf-demo_knowledge_base customers
38
+ ```
39
+
40
+ Your real usage will point at your own markdown directories instead:
41
+
42
+ ```bash
43
+ okf bundle my-notes
44
+ okf validate my-notes_knowledge_base
45
+ okf list my-notes_knowledge_base
46
+ okf read my-notes_knowledge_base <concept-id>
47
+ ```
48
+
49
+ Run `okf <command> --help` for options such as `--default-type`, `--force`, `--strict`, and `--dry-run`. (Without an explicit output directory, `okf bundle <input-dir>` writes to `<input-dir>_knowledge_base` in the current directory.)
50
+
51
+ ## Commands
52
+
53
+ | Command | Purpose |
54
+ | ------------------------------------- | -------------------------------------------- |
55
+ | `okf bundle <input-dir> [output-dir]` | Convert markdown into an OKF bundle |
56
+ | `okf validate <directory>` | Check OKF v0.2 §11 conformance |
57
+ | `okf list <directory>` | List concepts (ID, type, title, description) |
58
+ | `okf read <directory> <concept-id>` | Print a concept by ID |
59
+ | `okf reindex <directory>` | Rebuild every `index.md` from the concepts |
60
+ | `okf serve-mcp <directory>` | Serve a conformant bundle over MCP HTTP |
61
+
62
+ ### MCP server
63
+
64
+ Install the optional MCP dependency (if you installed with `uv tool install okf-cli`, reinstall with `--force 'okf-cli[mcp]'` as shown above), then serve a conformant bundle over Streamable HTTP:
65
+
66
+ ```bash
67
+ okf serve-mcp my-bundle
68
+ ```
69
+
70
+ The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address; `--host 0.0.0.0` listens on all IPv4 interfaces. The server exposes read-only tools:
71
+
72
+ | Tool | Purpose |
73
+ | ------------------------------------- | ------------------------------------------------------------------------------------------ |
74
+ | `search(query, type, filters, limit)` | Find concepts by words in the ID, title, description, tags or any other frontmatter value |
75
+ | `browse(path)` | List a directory's concepts and subdirectories with bundle-relative IDs and paths |
76
+ | `read_concept(concept_id, section)` | Read a concept, or only one section; `links` resolves body links to concept IDs (`exists`) |
77
+ | `list_concepts()` | List every concept (prefer `search`/`browse` for large bundles) |
78
+
79
+ Every call re-reads files changed on disk since the previous call, so a bundle can be regenerated while it is served. The server instructions describe the tools and append the bundle's `AGENTS.md` when present. Add `--token <secret>` to require the matching `Authorization: Bearer <secret>` header on MCP requests; without it, requests are unauthenticated. For example:
80
+
81
+ ```bash
82
+ okf serve-mcp my-bundle --token "$OKF_MCP_TOKEN"
83
+ ```
84
+
85
+ Use HTTPS (typically through a TLS-terminating proxy) when serving beyond localhost. The token is a command-line argument and may be visible in shell history or process listings; use this option only on a trusted network, and do not treat it as a replacement for TLS.
86
+
87
+ #### HTTPS with Caddy
88
+
89
+ When Caddy runs on the same machine, leave the MCP server bound to its default `127.0.0.1` address and let Caddy handle public HTTPS:
90
+
91
+ ```caddyfile
92
+ mcp.example.com {
93
+ reverse_proxy 127.0.0.1:8000
94
+ }
95
+ ```
96
+
97
+ Start the MCP server with authentication enabled:
98
+
99
+ ```bash
100
+ okf serve-mcp my-bundle --token "$OKF_MCP_TOKEN"
101
+ ```
102
+
103
+ Clients connect to `https://mcp.example.com/mcp` and send `Authorization: Bearer <token>`. Keep port `8000` private; Caddy should be the public entry point. Caddy can provision HTTPS automatically when the domain points to the server and is reachable on the required ports.
104
+
105
+ ## Python library
106
+
107
+ `src/okf/api.py` is usable directly as a library:
108
+
109
+ ```python
110
+ from okf.api import Bundle, bundle, reindex, validate, write_concept
111
+
112
+ result = bundle("example", "out", default_type="reference", force=True)
113
+ assert validate("out").ok
114
+
115
+ # Programs that generate concepts themselves keep every frontmatter key as given.
116
+ write_concept(
117
+ "out", "tables/invoices", {"type": "tables", "title": "Invoices"}, "Body."
118
+ )
119
+
120
+ # Rebuild index.md files after concepts were added or removed directly.
121
+ reindex("out") # also: `okf reindex out`; stale indexes are emptied, never deleted
122
+
123
+ # Repeated reads: load once, then search and read from memory.
124
+ kb = Bundle.open("out")
125
+ kb.search("customer", type_="tables")
126
+ kb.read("tables/customers", section="Schema").body
127
+ ```
128
+
129
+ ## Documentation
130
+
131
+ - OKF v0.2 specification: [SPEC/OKF_SPEC_V0_2.md](SPEC/OKF_SPEC_V0_2.md)
132
+ - Development and contributor docs: [wiki/quickstart.md](wiki/quickstart.md) and [AGENTS.md](AGENTS.md)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "okf-cli"
3
- version = "0.8.1"
3
+ version = "0.9.0"
4
4
  description = "Open Knowledge Format tooling"
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -117,6 +117,30 @@ Example:
117
117
  okf read my-docs_knowledge_base tables/orders
118
118
  ```
119
119
 
120
+ ### `okf reindex`
121
+
122
+ Rebuild every `index.md` in a conformant bundle from the concept files on disk.
123
+ Use it after concepts were added, changed or removed directly (by hand or by a
124
+ program using `okf.api.write_concept`) instead of through `okf bundle`.
125
+
126
+ ```bash
127
+ okf reindex <directory>
128
+ ```
129
+
130
+ Existing `index.md` files are rewritten from scratch; an index left with no
131
+ concepts is emptied (never deleted) and reported as a warning. The bundle-root
132
+ `okf_version` is kept.
133
+
134
+ ### `okf serve-mcp`
135
+
136
+ Serve a conformant bundle to MCP clients over Streamable HTTP (needs the `mcp`
137
+ extra). Tools: `search`, `browse`, `read_concept` (optionally one section),
138
+ `list_concepts`. Files changed on disk are picked up on the next call.
139
+
140
+ ```bash
141
+ okf serve-mcp <directory> [--host 127.0.0.1] [--port 8000] [--token <secret>]
142
+ ```
143
+
120
144
  ## Plain markdown input format
121
145
 
122
146
  Best-quality input uses strict shape: