okf-cli 0.4.8__tar.gz → 0.4.9__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.4.9/.last-update.json +4 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/PKG-INFO +27 -16
- {okf_cli-0.4.8 → okf_cli-0.4.9}/README.md +25 -15
- okf_cli-0.4.9/example/blank-line/no-blank.md +3 -0
- okf_cli-0.4.9/example/blank-line/with-blank.md +5 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/openwiki/architecture.md +1 -1
- {okf_cli-0.4.8 → okf_cli-0.4.9}/openwiki/domain-model.md +4 -4
- {okf_cli-0.4.8 → okf_cli-0.4.9}/openwiki/operations.md +2 -2
- {okf_cli-0.4.8 → okf_cli-0.4.9}/openwiki/testing.md +2 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/openwiki/workflows.md +1 -1
- {okf_cli-0.4.8 → okf_cli-0.4.9}/pyproject.toml +6 -2
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/api.py +1 -1
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/cli.py +2 -1
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/commands/bundle.py +10 -6
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/commands/list.py +4 -3
- okf_cli-0.4.9/src/okf/commands/show.py +29 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/commands/validate.py +6 -4
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/core.py +4 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/uv.lock +2 -0
- okf_cli-0.4.8/.last-update.json +0 -1
- okf_cli-0.4.8/src/okf/commands/show.py +0 -21
- {okf_cli-0.4.8 → okf_cli-0.4.9}/.github/workflows/test.yml +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/.gitignore +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/AGENTS.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/LICENSE +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/OKF_SPEC.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/.okfignore +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/README.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/datasets/sales.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/domain.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/loose/deep/no-heading.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/loose/no-desc.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/loose/no-title.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/playbooks/incident-response.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/playbooks/oncall-guide.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/smoke-ignore.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/tables/customers.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/tables/orders.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/tables/partitions/2026/q1/jan/january.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/example/tables/partitions/daily.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/openwiki/quickstart.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/skills/okf-cli-manual/SKILL.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/skills/writing-knowledge-base/SKILL.md +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/__init__.py +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/src/okf/commands/__init__.py +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/tests/test_api.py +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/tests/test_cli.py +0 -0
- {okf_cli-0.4.8 → okf_cli-0.4.9}/tests/test_core.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: okf-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.9
|
|
4
4
|
Summary: Open Knowledge Format tooling
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -26,6 +26,7 @@ License: MIT License
|
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Python: >=3.11
|
|
28
28
|
Requires-Dist: pyyaml>=6
|
|
29
|
+
Requires-Dist: rich>=15.0.0
|
|
29
30
|
Requires-Dist: typer>=0.15
|
|
30
31
|
Description-Content-Type: text/markdown
|
|
31
32
|
|
|
@@ -33,7 +34,7 @@ Description-Content-Type: text/markdown
|
|
|
33
34
|
|
|
34
35
|
Converts plain markdown into [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)-conformant knowledge bundles. Domain experts write the content, `okf bundle` generates frontmatter, type, timestamps, and index files.
|
|
35
36
|
|
|
36
|
-
Also validates bundles, lists concept IDs,
|
|
37
|
+
Also validates bundles, lists concept IDs, reads concepts by ID, and reports version.
|
|
37
38
|
|
|
38
39
|
## Install
|
|
39
40
|
|
|
@@ -46,8 +47,11 @@ uv tool install okf-cli
|
|
|
46
47
|
```bash
|
|
47
48
|
uv sync
|
|
48
49
|
uv run okf --help
|
|
50
|
+
uv run okf --version
|
|
49
51
|
```
|
|
50
52
|
|
|
53
|
+
Global options: `--version`, `--help`.
|
|
54
|
+
|
|
51
55
|
## Commands
|
|
52
56
|
|
|
53
57
|
### `okf bundle` — convert plain markdown to OKF bundle
|
|
@@ -59,14 +63,14 @@ okf bundle <input-dir> [output-dir] [--default-type <name>] [--force] [--strict]
|
|
|
59
63
|
| Argument | Description |
|
|
60
64
|
| ---------------- | ---------------------------------------------------------------------------- |
|
|
61
65
|
| `input-dir` | Directory of plain `.md` files |
|
|
62
|
-
| `output-dir` | Target directory (default: `
|
|
63
|
-
| `--default-type` | Type for root-level files (
|
|
66
|
+
| `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
|
|
67
|
+
| `--default-type` | Type for root-level files (default: input directory name) |
|
|
64
68
|
| `--force`, `-f` | Overwrite output directory if it exists |
|
|
65
|
-
| `--strict`
|
|
69
|
+
| `--strict` | Enforce strict OKF spec output: fail on broken local `.md` links and skip `AGENTS.md` generation |
|
|
66
70
|
|
|
67
71
|
```bash
|
|
68
|
-
okf bundle example --default-type reference
|
|
69
|
-
okf bundle example --default-type reference --force --strict
|
|
72
|
+
okf bundle example --default-type reference # → example_knowledge_base/
|
|
73
|
+
okf bundle example bundled --default-type reference --force --strict
|
|
70
74
|
```
|
|
71
75
|
|
|
72
76
|
**`.okfignore`**: put in `input-dir` root; one bundle-relative `.md` path per line. Exact match only (no glob).
|
|
@@ -82,7 +86,7 @@ okf list <directory>
|
|
|
82
86
|
Prints concept IDs (path without `.md`). Requires valid OKF bundle.
|
|
83
87
|
|
|
84
88
|
```bash
|
|
85
|
-
okf list
|
|
89
|
+
okf list example_knowledge_base/
|
|
86
90
|
# datasets/sales
|
|
87
91
|
# tables/orders
|
|
88
92
|
```
|
|
@@ -104,7 +108,7 @@ okf validate <directory>
|
|
|
104
108
|
Checks OKF v0.1 §9 conformance: frontmatter required, `type` required, reserved filenames follow spec structure, UTF-8 required.
|
|
105
109
|
|
|
106
110
|
```bash
|
|
107
|
-
okf validate
|
|
111
|
+
okf validate example_knowledge_base/
|
|
108
112
|
# 16 files: 16 ok
|
|
109
113
|
```
|
|
110
114
|
|
|
@@ -129,7 +133,7 @@ Files without strict format are bundled best-effort: title omitted if absent, de
|
|
|
129
133
|
| `index.md`, `log.md`, `README.md` skipped in `bundle` | Repo artifacts; not OKF concepts. `list`/`show`/`validate` only reserve `index.md` and `log.md`. |
|
|
130
134
|
| `.okfignore` entries skipped | Skip selected files without moving them. |
|
|
131
135
|
|
|
132
|
-
Root files
|
|
136
|
+
Root files use `--default-type`, defaulting to the input directory name. See [`example/`](example/) for sample structure.
|
|
133
137
|
|
|
134
138
|
## Output
|
|
135
139
|
|
|
@@ -157,13 +161,20 @@ Generated bundles conform to [OKF v0.1](OKF_SPEC.md) (§9): frontmatter required
|
|
|
157
161
|
```
|
|
158
162
|
okf-cli
|
|
159
163
|
├── .github/workflows/test.yml # CI
|
|
164
|
+
├── AGENTS.md # Contributor context for AI agents
|
|
160
165
|
├── OKF_SPEC.md # OKF specification
|
|
166
|
+
├── README.md # This file
|
|
167
|
+
├── openwiki/ # Contributor docs (architecture, workflows, etc.)
|
|
161
168
|
├── pyproject.toml # uv-managed Python project
|
|
169
|
+
├── skills/ # Optional skill definitions
|
|
170
|
+
├── uv.lock # uv lockfile
|
|
162
171
|
├── src/okf/
|
|
163
|
-
│ ├── cli.py
|
|
164
|
-
│ ├── api.py
|
|
165
|
-
│ ├── core.py
|
|
166
|
-
│ └── commands/
|
|
167
|
-
├── tests/
|
|
168
|
-
└── example/
|
|
172
|
+
│ ├── cli.py # Typer entrypoint
|
|
173
|
+
│ ├── api.py # Programmatic Python API
|
|
174
|
+
│ ├── core.py # Shared parsing/formatting
|
|
175
|
+
│ └── commands/ # bundle, list, show, validate
|
|
176
|
+
├── tests/ # pytest suite
|
|
177
|
+
└── example/ # Sample input markdown
|
|
169
178
|
```
|
|
179
|
+
|
|
180
|
+
For contributor guidance, see [`AGENTS.md`](AGENTS.md) and [`openwiki/quickstart.md`](openwiki/quickstart.md).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Converts plain markdown into [OKF](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md)-conformant knowledge bundles. Domain experts write the content, `okf bundle` generates frontmatter, type, timestamps, and index files.
|
|
4
4
|
|
|
5
|
-
Also validates bundles, lists concept IDs,
|
|
5
|
+
Also validates bundles, lists concept IDs, reads concepts by ID, and reports version.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -15,8 +15,11 @@ uv tool install okf-cli
|
|
|
15
15
|
```bash
|
|
16
16
|
uv sync
|
|
17
17
|
uv run okf --help
|
|
18
|
+
uv run okf --version
|
|
18
19
|
```
|
|
19
20
|
|
|
21
|
+
Global options: `--version`, `--help`.
|
|
22
|
+
|
|
20
23
|
## Commands
|
|
21
24
|
|
|
22
25
|
### `okf bundle` — convert plain markdown to OKF bundle
|
|
@@ -28,14 +31,14 @@ okf bundle <input-dir> [output-dir] [--default-type <name>] [--force] [--strict]
|
|
|
28
31
|
| Argument | Description |
|
|
29
32
|
| ---------------- | ---------------------------------------------------------------------------- |
|
|
30
33
|
| `input-dir` | Directory of plain `.md` files |
|
|
31
|
-
| `output-dir` | Target directory (default: `
|
|
32
|
-
| `--default-type` | Type for root-level files (
|
|
34
|
+
| `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
|
|
35
|
+
| `--default-type` | Type for root-level files (default: input directory name) |
|
|
33
36
|
| `--force`, `-f` | Overwrite output directory if it exists |
|
|
34
|
-
| `--strict`
|
|
37
|
+
| `--strict` | Enforce strict OKF spec output: fail on broken local `.md` links and skip `AGENTS.md` generation |
|
|
35
38
|
|
|
36
39
|
```bash
|
|
37
|
-
okf bundle example --default-type reference
|
|
38
|
-
okf bundle example --default-type reference --force --strict
|
|
40
|
+
okf bundle example --default-type reference # → example_knowledge_base/
|
|
41
|
+
okf bundle example bundled --default-type reference --force --strict
|
|
39
42
|
```
|
|
40
43
|
|
|
41
44
|
**`.okfignore`**: put in `input-dir` root; one bundle-relative `.md` path per line. Exact match only (no glob).
|
|
@@ -51,7 +54,7 @@ okf list <directory>
|
|
|
51
54
|
Prints concept IDs (path without `.md`). Requires valid OKF bundle.
|
|
52
55
|
|
|
53
56
|
```bash
|
|
54
|
-
okf list
|
|
57
|
+
okf list example_knowledge_base/
|
|
55
58
|
# datasets/sales
|
|
56
59
|
# tables/orders
|
|
57
60
|
```
|
|
@@ -73,7 +76,7 @@ okf validate <directory>
|
|
|
73
76
|
Checks OKF v0.1 §9 conformance: frontmatter required, `type` required, reserved filenames follow spec structure, UTF-8 required.
|
|
74
77
|
|
|
75
78
|
```bash
|
|
76
|
-
okf validate
|
|
79
|
+
okf validate example_knowledge_base/
|
|
77
80
|
# 16 files: 16 ok
|
|
78
81
|
```
|
|
79
82
|
|
|
@@ -98,7 +101,7 @@ Files without strict format are bundled best-effort: title omitted if absent, de
|
|
|
98
101
|
| `index.md`, `log.md`, `README.md` skipped in `bundle` | Repo artifacts; not OKF concepts. `list`/`show`/`validate` only reserve `index.md` and `log.md`. |
|
|
99
102
|
| `.okfignore` entries skipped | Skip selected files without moving them. |
|
|
100
103
|
|
|
101
|
-
Root files
|
|
104
|
+
Root files use `--default-type`, defaulting to the input directory name. See [`example/`](example/) for sample structure.
|
|
102
105
|
|
|
103
106
|
## Output
|
|
104
107
|
|
|
@@ -126,13 +129,20 @@ Generated bundles conform to [OKF v0.1](OKF_SPEC.md) (§9): frontmatter required
|
|
|
126
129
|
```
|
|
127
130
|
okf-cli
|
|
128
131
|
├── .github/workflows/test.yml # CI
|
|
132
|
+
├── AGENTS.md # Contributor context for AI agents
|
|
129
133
|
├── OKF_SPEC.md # OKF specification
|
|
134
|
+
├── README.md # This file
|
|
135
|
+
├── openwiki/ # Contributor docs (architecture, workflows, etc.)
|
|
130
136
|
├── pyproject.toml # uv-managed Python project
|
|
137
|
+
├── skills/ # Optional skill definitions
|
|
138
|
+
├── uv.lock # uv lockfile
|
|
131
139
|
├── src/okf/
|
|
132
|
-
│ ├── cli.py
|
|
133
|
-
│ ├── api.py
|
|
134
|
-
│ ├── core.py
|
|
135
|
-
│ └── commands/
|
|
136
|
-
├── tests/
|
|
137
|
-
└── example/
|
|
140
|
+
│ ├── cli.py # Typer entrypoint
|
|
141
|
+
│ ├── api.py # Programmatic Python API
|
|
142
|
+
│ ├── core.py # Shared parsing/formatting
|
|
143
|
+
│ └── commands/ # bundle, list, show, validate
|
|
144
|
+
├── tests/ # pytest suite
|
|
145
|
+
└── example/ # Sample input markdown
|
|
138
146
|
```
|
|
147
|
+
|
|
148
|
+
For contributor guidance, see [`AGENTS.md`](AGENTS.md) and [`openwiki/quickstart.md`](openwiki/quickstart.md).
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- **Core layer** (`src/okf/core.py`) — shared parsing, formatting, conformance helpers.
|
|
10
10
|
- **Command wrappers** (`src/okf/commands/`) — thin IO/error bridges from CLI args to API calls.
|
|
11
11
|
|
|
12
|
-
Why this split: the API layer is the canonical home for all logic. Commands handle only Typer argument parsing, error display, and exit codes. `core.py`
|
|
12
|
+
Why this split: the API layer is the canonical home for all logic. Commands handle only Typer argument parsing, error display, and exit codes. `core.py` holds pure parsing / formatting / conformance logic, but also instantiates shared rich `Console` singletons at import for output (used by `cli.py` and `commands/*`).
|
|
13
13
|
|
|
14
14
|
## Key modules
|
|
15
15
|
|
|
@@ -79,7 +79,7 @@ Source: `src/okf/core.py`.
|
|
|
79
79
|
- `--strict`: turns warnings into fatal exit and skips `AGENTS.md` generation.
|
|
80
80
|
- Generated `index.md` files count as valid link targets.
|
|
81
81
|
|
|
82
|
-
Source: `src/okf/
|
|
82
|
+
Source: `src/okf/api.py` (`_iter_links`, `_resolve_md_target`).
|
|
83
83
|
|
|
84
84
|
## `.okfignore` model (bundle-only)
|
|
85
85
|
|
|
@@ -89,7 +89,7 @@ Source: `src/okf/commands/bundle.py`.
|
|
|
89
89
|
- no glob/negation semantics
|
|
90
90
|
- non-UTF-8 `.okfignore` fails bundling
|
|
91
91
|
|
|
92
|
-
Source: `_load_okfignore` in `src/okf/
|
|
92
|
+
Source: `_load_okfignore` in `src/okf/api.py`; example file: `example/.okfignore`.
|
|
93
93
|
|
|
94
94
|
## Bundle output artifacts
|
|
95
95
|
|
|
@@ -99,7 +99,7 @@ Each bundle run produces:
|
|
|
99
99
|
- `index.md` per directory listing contents and subdirs
|
|
100
100
|
- `AGENTS.md` at output root: navigation guide for AI agents and humans (references `index.md`, explains frontmatter and cross-links); omitted in `--strict` mode
|
|
101
101
|
|
|
102
|
-
Source: `src/okf/
|
|
102
|
+
Source: `src/okf/api.py` (`_write_concept`, `_generate_indexes`, `bundle`).
|
|
103
103
|
|
|
104
104
|
## Conformance rules enforced
|
|
105
105
|
|
|
@@ -114,4 +114,4 @@ Source: `src/okf/commands/bundle.py`.
|
|
|
114
114
|
- `log.md` must not have frontmatter;
|
|
115
115
|
1. markdown files must be UTF-8.
|
|
116
116
|
|
|
117
|
-
Source: `src/okf/core.py`; behavior validated by `tests/
|
|
117
|
+
Source: `src/okf/core.py`; behavior validated by `tests/test_api.py` (`TestValidate`) and `tests/test_cli.py`.
|
|
@@ -14,8 +14,8 @@ Packaging and runtime metadata: `pyproject.toml`.
|
|
|
14
14
|
Key points:
|
|
15
15
|
|
|
16
16
|
- CLI script entrypoint: `okf = "okf.cli:app"`
|
|
17
|
-
- Python API: `from okf.api import bundle, list_concepts, show_concept, validate`
|
|
18
|
-
- Runtime deps: `typer`, `pyyaml`
|
|
17
|
+
- Python API: `from okf.api import bundle, convert_file, convert_content, list_concepts, show_concept, validate`
|
|
18
|
+
- Runtime deps: `typer`, `pyyaml`, `rich`
|
|
19
19
|
- Dev deps include `pytest`, `ruff`
|
|
20
20
|
|
|
21
21
|
## Day-to-day commands
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
- `TestShowConcept` — reading via `api.show_concept()`, path traversal guard
|
|
9
9
|
- `TestValidate` — conformance checks via `api.validate()`, all §9 rule variants
|
|
10
10
|
- `TestWorkflow` — cross-command pipeline (bundle → validate/list/show)
|
|
11
|
+
- `TestConvertFile` — single-file conversion via `api.convert_file()`, mtime timestamp
|
|
12
|
+
- `TestConvertContent` — raw markdown conversion via `api.convert_content()`, no timestamp
|
|
11
13
|
- Core unit tests: `tests/test_core.py`
|
|
12
14
|
- parsing helpers (`parse_md`, `parse_frontmatter`)
|
|
13
15
|
- frontmatter generation (`build_frontmatter`)
|
|
@@ -32,7 +32,7 @@ Important behavior:
|
|
|
32
32
|
- `--strict` enforces strict OKF spec output: fails on broken local `.md` links and skips `AGENTS.md` generation.
|
|
33
33
|
- `AGENTS.md` is generated at output root with navigation guidance (unless `--strict` is used).
|
|
34
34
|
|
|
35
|
-
Source: `src/okf/
|
|
35
|
+
Source: `src/okf/api.py`.
|
|
36
36
|
|
|
37
37
|
### 3) Validate output
|
|
38
38
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "okf-cli"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.9"
|
|
4
4
|
description = "Open Knowledge Format tooling"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
7
7
|
requires-python = ">=3.11"
|
|
8
|
-
dependencies = [
|
|
8
|
+
dependencies = [
|
|
9
|
+
"typer>=0.15",
|
|
10
|
+
"pyyaml>=6",
|
|
11
|
+
"rich>=15.0.0",
|
|
12
|
+
]
|
|
9
13
|
|
|
10
14
|
[project.scripts]
|
|
11
15
|
okf = "okf.cli:app"
|
|
@@ -495,7 +495,7 @@ def show_concept(bundle_dir: str | Path, concept_id: str) -> ConceptContent:
|
|
|
495
495
|
|
|
496
496
|
if not concept_path.is_file():
|
|
497
497
|
raise FileNotFoundError(
|
|
498
|
-
f"Concept '{concept_id}' not found
|
|
498
|
+
f"Concept '{concept_id}' not found"
|
|
499
499
|
)
|
|
500
500
|
|
|
501
501
|
raw = concept_path.read_text(encoding="utf-8")
|
|
@@ -8,6 +8,7 @@ from okf.commands.bundle import bundle
|
|
|
8
8
|
from okf.commands.list import cmd_list
|
|
9
9
|
from okf.commands.show import cmd_show
|
|
10
10
|
from okf.commands.validate import validate
|
|
11
|
+
from okf.core import console
|
|
11
12
|
|
|
12
13
|
app = typer.Typer(
|
|
13
14
|
name="okf",
|
|
@@ -18,7 +19,7 @@ app = typer.Typer(
|
|
|
18
19
|
|
|
19
20
|
def _version_callback(value: bool) -> None:
|
|
20
21
|
if value:
|
|
21
|
-
|
|
22
|
+
console.print(f"okf {_version('okf-cli')}")
|
|
22
23
|
raise typer.Exit()
|
|
23
24
|
|
|
24
25
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import typer
|
|
4
4
|
|
|
5
5
|
from okf import api
|
|
6
|
+
from okf.core import console, err_console
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def bundle(
|
|
@@ -39,22 +40,25 @@ def bundle(
|
|
|
39
40
|
strict=strict,
|
|
40
41
|
)
|
|
41
42
|
except FileNotFoundError as e:
|
|
42
|
-
|
|
43
|
+
err_console.print(f"Error: {e}", style="red")
|
|
43
44
|
raise typer.Exit(code=1)
|
|
44
45
|
except FileExistsError as e:
|
|
45
|
-
|
|
46
|
+
err_console.print(f"Error: {e}", style="red")
|
|
46
47
|
raise typer.Exit(code=1)
|
|
47
48
|
except ValueError as e:
|
|
48
|
-
|
|
49
|
+
err_console.print(f"Error: {e}", style="red")
|
|
49
50
|
raise typer.Exit(code=1)
|
|
50
51
|
|
|
51
52
|
for w in result.warnings:
|
|
52
|
-
|
|
53
|
+
err_console.print(f"Warning: {w}", style="yellow")
|
|
53
54
|
for e in result.errors:
|
|
54
|
-
|
|
55
|
+
err_console.print(f"Error: {e}", style="red")
|
|
55
56
|
|
|
56
57
|
if result.errors:
|
|
57
58
|
raise typer.Exit(code=1)
|
|
58
59
|
|
|
59
60
|
n = result.files_written
|
|
60
|
-
|
|
61
|
+
console.print(
|
|
62
|
+
f"Done. Converted {n} file{'s' if n != 1 else ''} → {result.output_dir}",
|
|
63
|
+
style="green",
|
|
64
|
+
)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import typer
|
|
4
4
|
|
|
5
5
|
from okf import api
|
|
6
|
+
from okf.core import console, err_console
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def cmd_list(
|
|
@@ -12,12 +13,12 @@ def cmd_list(
|
|
|
12
13
|
try:
|
|
13
14
|
cids = api.list_concepts(directory)
|
|
14
15
|
except (ValueError, NotADirectoryError) as e:
|
|
15
|
-
|
|
16
|
+
err_console.print(f"Error: {e}", style="red")
|
|
16
17
|
raise typer.Exit(code=1)
|
|
17
18
|
|
|
18
19
|
if not cids:
|
|
19
|
-
|
|
20
|
+
err_console.print("No concepts found", style="yellow")
|
|
20
21
|
raise typer.Exit(code=1)
|
|
21
22
|
|
|
22
23
|
for cid in cids:
|
|
23
|
-
|
|
24
|
+
console.print(cid, style="cyan")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""okf show command."""
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from okf import api
|
|
6
|
+
from okf.core import console, err_console
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def cmd_show(
|
|
10
|
+
directory: str = typer.Argument(..., help="Directory of the OKF bundle"),
|
|
11
|
+
concept_id: str = typer.Argument(
|
|
12
|
+
..., help="Concept ID to read (e.g. tables/orders)"
|
|
13
|
+
),
|
|
14
|
+
) -> None:
|
|
15
|
+
"""Print a concept's full contents by its concept ID."""
|
|
16
|
+
try:
|
|
17
|
+
result = api.show_concept(directory, concept_id)
|
|
18
|
+
except FileNotFoundError as e:
|
|
19
|
+
err_console.print(f"Error: {e}", style="red")
|
|
20
|
+
err_console.print(
|
|
21
|
+
f"Run `okf list {directory}` to see available concept IDs.",
|
|
22
|
+
style="yellow",
|
|
23
|
+
)
|
|
24
|
+
raise typer.Exit(code=1)
|
|
25
|
+
except (ValueError, NotADirectoryError) as e:
|
|
26
|
+
err_console.print(f"Error: {e}", style="red")
|
|
27
|
+
raise typer.Exit(code=1)
|
|
28
|
+
|
|
29
|
+
console.print(result.raw, end="", markup=False, highlight=False)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import typer
|
|
4
4
|
|
|
5
5
|
from okf import api
|
|
6
|
+
from okf.core import console, err_console
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def validate(
|
|
@@ -12,13 +13,13 @@ def validate(
|
|
|
12
13
|
try:
|
|
13
14
|
result = api.validate(directory)
|
|
14
15
|
except NotADirectoryError as e:
|
|
15
|
-
|
|
16
|
+
err_console.print(f"Error: {e}", style="red")
|
|
16
17
|
raise typer.Exit(code=1)
|
|
17
18
|
|
|
18
19
|
for w in result.warnings:
|
|
19
|
-
|
|
20
|
+
err_console.print(f"Warning: {w}", style="yellow")
|
|
20
21
|
for e in result.errors:
|
|
21
|
-
|
|
22
|
+
err_console.print(f"Error: {e}", style="red")
|
|
22
23
|
|
|
23
24
|
ok = result.total_files - len(result.errors)
|
|
24
25
|
parts = [f"{result.total_files} files: {ok} ok"]
|
|
@@ -26,7 +27,8 @@ def validate(
|
|
|
26
27
|
parts.append(f"{len(result.errors)} errors")
|
|
27
28
|
if result.warnings:
|
|
28
29
|
parts.append(f"{len(result.warnings)} warnings")
|
|
29
|
-
|
|
30
|
+
summary_color = "green" if not result.errors else "red"
|
|
31
|
+
console.print("\n" + ", ".join(parts), style=summary_color)
|
|
30
32
|
|
|
31
33
|
if result.errors:
|
|
32
34
|
raise typer.Exit(code=1)
|
|
@@ -5,6 +5,10 @@ from pathlib import Path
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
import yaml
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
console = Console()
|
|
11
|
+
err_console = Console(stderr=True)
|
|
8
12
|
|
|
9
13
|
RESERVED = frozenset({"index.md", "log.md", "readme.md"})
|
|
10
14
|
SPEC_RESERVED = frozenset({"index.md", "log.md", "agents.md"})
|
|
@@ -56,6 +56,7 @@ version = "0.4.8"
|
|
|
56
56
|
source = { editable = "." }
|
|
57
57
|
dependencies = [
|
|
58
58
|
{ name = "pyyaml" },
|
|
59
|
+
{ name = "rich" },
|
|
59
60
|
{ name = "typer" },
|
|
60
61
|
]
|
|
61
62
|
|
|
@@ -68,6 +69,7 @@ dev = [
|
|
|
68
69
|
[package.metadata]
|
|
69
70
|
requires-dist = [
|
|
70
71
|
{ name = "pyyaml", specifier = ">=6" },
|
|
72
|
+
{ name = "rich", specifier = ">=15.0.0" },
|
|
71
73
|
{ name = "typer", specifier = ">=0.15" },
|
|
72
74
|
]
|
|
73
75
|
|
okf_cli-0.4.8/.last-update.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"head": "b0a76b5d97d2d46ab19d4fc4149be3efb4dc0228", "timestamp": "2025-07-15T19:10:00Z"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"""okf show command."""
|
|
2
|
-
|
|
3
|
-
import typer
|
|
4
|
-
|
|
5
|
-
from okf import api
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def cmd_show(
|
|
9
|
-
directory: str = typer.Argument(..., help="Directory of the OKF bundle"),
|
|
10
|
-
concept_id: str = typer.Argument(
|
|
11
|
-
..., help="Concept ID to read (e.g. tables/orders)"
|
|
12
|
-
),
|
|
13
|
-
) -> None:
|
|
14
|
-
"""Print a concept's full contents by its concept ID."""
|
|
15
|
-
try:
|
|
16
|
-
result = api.show_concept(directory, concept_id)
|
|
17
|
-
except (ValueError, FileNotFoundError, NotADirectoryError) as e:
|
|
18
|
-
typer.echo(f"Error: {e}", err=True)
|
|
19
|
-
raise typer.Exit(code=1)
|
|
20
|
-
|
|
21
|
-
typer.echo(result.raw, nl=False)
|
|
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
|