okf-cli 0.9.0__tar.gz → 0.9.1__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_cli-0.9.0 → okf_cli-0.9.1}/PKG-INFO +7 -7
- {okf_cli-0.9.0 → okf_cli-0.9.1}/README.md +6 -6
- {okf_cli-0.9.0 → okf_cli-0.9.1}/pyproject.toml +1 -1
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/serve_mcp.py +25 -16
- {okf_cli-0.9.0 → okf_cli-0.9.1}/tests/test_mcp.py +20 -8
- {okf_cli-0.9.0 → okf_cli-0.9.1}/uv.lock +1 -1
- {okf_cli-0.9.0 → okf_cli-0.9.1}/wiki/architecture.md +1 -1
- {okf_cli-0.9.0 → okf_cli-0.9.1}/wiki/quickstart.md +1 -1
- {okf_cli-0.9.0 → okf_cli-0.9.1}/wiki/testing.md +1 -1
- {okf_cli-0.9.0 → okf_cli-0.9.1}/.agents/skills/wiki/SKILL.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/.github/workflows/publish.yml +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/.github/workflows/test.yml +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/.gitignore +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/.last-update.json +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/AGENTS.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/LICENSE +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/SPEC/OKF_SPEC_V0_1.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/SPEC/OKF_SPEC_V0_2.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/.okfignore +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/README.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/blank-line/no-blank.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/blank-line/with-blank.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/computations/revenue.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/datasets/sales.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/domain.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/loose/deep/no-heading.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/loose/no-desc.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/loose/no-title.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/metrics/income-statement.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/playbooks/incident-response.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/playbooks/oncall-guide.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/references/revenue-recognition.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/smoke-ignore.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/tables/customers.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/tables/orders.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/tables/partitions/2026/q1/jan/january.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/example/tables/partitions/daily.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/skills/okf-cli/SKILL.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/skills/writing-knowledge-base/SKILL.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/__init__.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/api.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/cli.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/__init__.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/bundle.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/list.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/read.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/reindex.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/commands/validate.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/src/okf/core.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/tests/test_api.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/tests/test_cli.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/tests/test_core.py +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/wiki/domain-model.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/wiki/operations.md +0 -0
- {okf_cli-0.9.0 → okf_cli-0.9.1}/wiki/workflows.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: okf-cli
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.1
|
|
4
4
|
Summary: Open Knowledge Format tooling
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -103,12 +103,12 @@ okf serve-mcp my-bundle
|
|
|
103
103
|
|
|
104
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
105
|
|
|
106
|
-
| Tool
|
|
107
|
-
|
|
|
108
|
-
| `search(query, type, filters, limit)`
|
|
109
|
-
| `browse(path)`
|
|
110
|
-
| `read_concept(concept_id, section)`
|
|
111
|
-
| `list_concepts()`
|
|
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, include_frontmatter=false)` | Read a concept or section; optionally include YAML frontmatter; `links` resolves body links to concept IDs (`exists`) |
|
|
111
|
+
| `list_concepts()` | List every concept (prefer `search`/`browse` for large bundles) |
|
|
112
112
|
|
|
113
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:
|
|
114
114
|
|
|
@@ -69,12 +69,12 @@ okf serve-mcp my-bundle
|
|
|
69
69
|
|
|
70
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
71
|
|
|
72
|
-
| Tool
|
|
73
|
-
|
|
|
74
|
-
| `search(query, type, filters, limit)`
|
|
75
|
-
| `browse(path)`
|
|
76
|
-
| `read_concept(concept_id, section)`
|
|
77
|
-
| `list_concepts()`
|
|
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, include_frontmatter=false)` | Read a concept or section; optionally include YAML frontmatter; `links` resolves body links to concept IDs (`exists`) |
|
|
77
|
+
| `list_concepts()` | List every concept (prefer `search`/`browse` for large bundles) |
|
|
78
78
|
|
|
79
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
80
|
|
|
@@ -102,11 +102,17 @@ def _create_server(
|
|
|
102
102
|
return loaded.listdir(path)
|
|
103
103
|
|
|
104
104
|
@mcp.tool(annotations=read_only)
|
|
105
|
-
def read_concept(
|
|
105
|
+
def read_concept(
|
|
106
|
+
concept_id: str,
|
|
107
|
+
section: str | None = None,
|
|
108
|
+
include_frontmatter: bool = False,
|
|
109
|
+
) -> dict[str, Any]:
|
|
106
110
|
"""Read an OKF concept by its bundle-relative ID, e.g. tables/orders.
|
|
107
111
|
|
|
108
112
|
Set `section` to a heading (e.g. "Schema") to get only that section;
|
|
109
|
-
heading matching is case-insensitive. `
|
|
113
|
+
heading matching is case-insensitive. Set `include_frontmatter` to true
|
|
114
|
+
to include the concept's YAML frontmatter (false by default). `body`
|
|
115
|
+
holds the concept content. `links` lists the concepts
|
|
110
116
|
the returned body links to: `target` as written in the body, `id`
|
|
111
117
|
to pass to `read_concept`, and `exists` false when that concept is
|
|
112
118
|
not in the bundle. Only bundle-local links are reported; external
|
|
@@ -115,12 +121,14 @@ def _create_server(
|
|
|
115
121
|
"""
|
|
116
122
|
loaded.refresh()
|
|
117
123
|
concept = loaded.read(concept_id, section=section)
|
|
118
|
-
|
|
124
|
+
result = {
|
|
119
125
|
"id": concept.id,
|
|
120
|
-
"frontmatter": _jsonable(concept.frontmatter),
|
|
121
126
|
"body": concept.body,
|
|
122
127
|
"links": concept.links,
|
|
123
128
|
}
|
|
129
|
+
if include_frontmatter:
|
|
130
|
+
result["frontmatter"] = _jsonable(concept.frontmatter)
|
|
131
|
+
return result
|
|
124
132
|
|
|
125
133
|
return mcp
|
|
126
134
|
|
|
@@ -132,7 +140,8 @@ _TOOL_GUIDE = (
|
|
|
132
140
|
"suffix, e.g. tables/orders. To answer from the bundle: use `search` to "
|
|
133
141
|
"find concepts by words, IDs, tags or other frontmatter values; `browse` "
|
|
134
142
|
'to walk the directory tree from the root (""); `read_concept` to read '
|
|
135
|
-
"one concept, optionally only the section you need
|
|
143
|
+
"one concept, optionally only the section you need or its frontmatter "
|
|
144
|
+
"with `include_frontmatter=true` (false by default). Body links are "
|
|
136
145
|
"relative markdown paths; `read_concept` reports them with the concept "
|
|
137
146
|
"`id` to follow and an `exists` flag (false means the referenced concept "
|
|
138
147
|
"is not in this bundle). `list_concepts` returns the whole listing and "
|
|
@@ -148,6 +157,17 @@ _AGENTS_NOTE = (
|
|
|
148
157
|
)
|
|
149
158
|
|
|
150
159
|
|
|
160
|
+
def _jsonable(value: Any) -> Any:
|
|
161
|
+
"""Turn dates and timestamps into ISO strings for JSON transport."""
|
|
162
|
+
if isinstance(value, dict):
|
|
163
|
+
return {key: _jsonable(item) for key, item in value.items()}
|
|
164
|
+
if isinstance(value, list):
|
|
165
|
+
return [_jsonable(item) for item in value]
|
|
166
|
+
if isinstance(value, (date, datetime)):
|
|
167
|
+
return value.isoformat()
|
|
168
|
+
return value
|
|
169
|
+
|
|
170
|
+
|
|
151
171
|
def _instructions(bundle_dir: Path) -> str:
|
|
152
172
|
"""Fixed tool guide followed by the bundle's AGENTS.md, when present."""
|
|
153
173
|
try:
|
|
@@ -161,17 +181,6 @@ def _instructions(bundle_dir: Path) -> str:
|
|
|
161
181
|
return _TOOL_GUIDE
|
|
162
182
|
|
|
163
183
|
|
|
164
|
-
def _jsonable(value: Any) -> Any:
|
|
165
|
-
"""Turn dates and timestamps into ISO strings for JSON transport."""
|
|
166
|
-
if isinstance(value, dict):
|
|
167
|
-
return {key: _jsonable(item) for key, item in value.items()}
|
|
168
|
-
if isinstance(value, list):
|
|
169
|
-
return [_jsonable(item) for item in value]
|
|
170
|
-
if isinstance(value, (date, datetime)):
|
|
171
|
-
return value.isoformat()
|
|
172
|
-
return value
|
|
173
|
-
|
|
174
|
-
|
|
175
184
|
def serve_mcp(
|
|
176
185
|
directory: Path = typer.Argument(..., help="Directory of the OKF bundle"),
|
|
177
186
|
host: str = typer.Option(
|
|
@@ -56,11 +56,6 @@ def test_mcp_tools_list_and_read_concepts(tmp_path: Path):
|
|
|
56
56
|
assert concept.is_error is False
|
|
57
57
|
assert concept.structured_content == {
|
|
58
58
|
"id": "tables/orders",
|
|
59
|
-
"frontmatter": {
|
|
60
|
-
"type": "tables",
|
|
61
|
-
"title": "Orders",
|
|
62
|
-
"description": "Order records.",
|
|
63
|
-
},
|
|
64
59
|
"body": "Details about orders.\n",
|
|
65
60
|
"links": [],
|
|
66
61
|
}
|
|
@@ -167,9 +162,19 @@ def test_mcp_search_browse_and_read_section(tmp_path: Path):
|
|
|
167
162
|
section = await client.call_tool(
|
|
168
163
|
"read_concept", {"concept_id": "tables/orders", "section": "Schema"}
|
|
169
164
|
)
|
|
170
|
-
|
|
165
|
+
section_with_frontmatter = await client.call_tool(
|
|
166
|
+
"read_concept",
|
|
167
|
+
{
|
|
168
|
+
"concept_id": "tables/orders",
|
|
169
|
+
"section": "Schema",
|
|
170
|
+
"include_frontmatter": True,
|
|
171
|
+
},
|
|
172
|
+
)
|
|
173
|
+
return found, filtered, index, section, section_with_frontmatter
|
|
171
174
|
|
|
172
|
-
found, filtered, index, section = asyncio.run(
|
|
175
|
+
found, filtered, index, section, section_with_frontmatter = asyncio.run(
|
|
176
|
+
call_tools()
|
|
177
|
+
)
|
|
173
178
|
|
|
174
179
|
assert [e["id"] for e in found.structured_content["result"]] == ["tables/orders"]
|
|
175
180
|
# Only orders carries the "sales" tag in the fixture.
|
|
@@ -194,7 +199,14 @@ def test_mcp_search_browse_and_read_section(tmp_path: Path):
|
|
|
194
199
|
}
|
|
195
200
|
assert section.structured_content["body"] == "# Schema\n\n| order_id |\n"
|
|
196
201
|
assert section.structured_content["links"] == []
|
|
197
|
-
assert
|
|
202
|
+
assert "frontmatter" not in section.structured_content
|
|
203
|
+
assert section_with_frontmatter.structured_content["frontmatter"] == {
|
|
204
|
+
"type": "Table",
|
|
205
|
+
"title": "Orders",
|
|
206
|
+
"description": "Order records.",
|
|
207
|
+
"tags": ["sales"],
|
|
208
|
+
"stale_after": "2026-12-31",
|
|
209
|
+
}
|
|
198
210
|
|
|
199
211
|
|
|
200
212
|
def test_mcp_search_matches_dates(tmp_path: Path):
|
|
@@ -110,7 +110,7 @@ Reason: reading APIs should not return misleading data from broken bundles.
|
|
|
110
110
|
|
|
111
111
|
### `okf serve-mcp`
|
|
112
112
|
|
|
113
|
-
The command opens a `Bundle` once (refusing non-conformant bundles) and hands it to `_create_server`. Every tool (`list_concepts`, `search`, `browse`, `read_concept`) calls `refresh()` first, so files another process added, changed or removed are served on the next call. Tools are annotated `readOnlyHint`. `browse` returns `Bundle.listdir()` — bundle-relative concept IDs and directory paths agents can feed straight back to the tools. `read_concept` accepts `section` and returns the normalized `id
|
|
113
|
+
The command opens a `Bundle` once (refusing non-conformant bundles) and hands it to `_create_server`. Every tool (`list_concepts`, `search`, `browse`, `read_concept`) calls `refresh()` first, so files another process added, changed or removed are served on the next call. Tools are annotated `readOnlyHint`. `browse` returns `Bundle.listdir()` — bundle-relative concept IDs and directory paths agents can feed straight back to the tools. `read_concept` accepts `section` and the optional `include_frontmatter` flag (false by default); it returns the normalized `id`, body, and `links` resolved to concept IDs, and includes JSON-safe frontmatter only when requested. Server instructions are a fixed tool guide plus, when present, the bundle's `AGENTS.md` behind a note that maps its "read index.md" advice to `browse`. A bundle that breaks while served makes tool calls fail with a `ToolError` carrying the conformance message rather than serving stale data.
|
|
114
114
|
|
|
115
115
|
## Shared invariants
|
|
116
116
|
|
|
@@ -32,7 +32,7 @@ uv run okf serve-mcp out
|
|
|
32
32
|
# Default endpoint: http://127.0.0.1:8000/mcp
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
The server exposes read-only `search`, `browse` (concepts and subdirectories with bundle-relative IDs/paths), `read_concept` (whole concept or one `section`, with body links resolved to concept IDs and an `exists` flag) and `list_concepts` tools; every call re-reads files changed on disk since the last call, so a bundle can be regenerated while it is served. It binds to localhost by default. Pass `--token <secret>` to require an `Authorization: Bearer <secret>` header on MCP requests; without it requests are unauthenticated. Use HTTPS (for example, through a TLS-terminating proxy) when serving beyond localhost. The token is passed as a command-line argument and may appear in shell history or process listings.
|
|
35
|
+
The server exposes read-only `search`, `browse` (concepts and subdirectories with bundle-relative IDs/paths), `read_concept` (whole concept or one `section`, with body links resolved to concept IDs and an `exists` flag; set `include_frontmatter=true` to get YAML frontmatter, omitted by default) and `list_concepts` tools; every call re-reads files changed on disk since the last call, so a bundle can be regenerated while it is served. It binds to localhost by default. Pass `--token <secret>` to require an `Authorization: Bearer <secret>` header on MCP requests; without it requests are unauthenticated. Use HTTPS (for example, through a TLS-terminating proxy) when serving beyond localhost. The token is passed as a command-line argument and may appear in shell history or process listings.
|
|
36
36
|
|
|
37
37
|
## Python API
|
|
38
38
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
- CLI integration tests: `tests/test_cli.py`
|
|
27
27
|
- exit codes and error message formatting for all commands
|
|
28
28
|
- MCP integration tests: `tests/test_mcp.py`
|
|
29
|
-
- in-process MCP tool calls (`search`, date scalar matching, structured `browse`, `read_concept` with `section`, normalized `id` and resolved `links`, read-only annotations, files written after start), server instructions with/without `AGENTS.md` (and its index.md note), and `serve-mcp` Streamable HTTP launch configuration
|
|
29
|
+
- in-process MCP tool calls (`search`, date scalar matching, structured `browse`, `read_concept` with `section` and optional `include_frontmatter`, normalized `id` and resolved `links`, read-only annotations, files written after start), server instructions with/without `AGENTS.md` (and its index.md note), and `serve-mcp` Streamable HTTP launch configuration
|
|
30
30
|
- Typer-specific behavior (argument parsing, `--force`, `--strict`, `--dry-run`)
|
|
31
31
|
|
|
32
32
|
## Run tests
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|