okf-cli 0.5.1__tar.gz → 0.5.4__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 (49) hide show
  1. {okf_cli-0.5.1 → okf_cli-0.5.4}/AGENTS.md +1 -1
  2. {okf_cli-0.5.1 → okf_cli-0.5.4}/PKG-INFO +16 -12
  3. {okf_cli-0.5.1 → okf_cli-0.5.4}/README.md +15 -11
  4. okf_cli-0.5.4/example/blank-line/no-blank.md +4 -0
  5. {okf_cli-0.5.1 → okf_cli-0.5.4}/openwiki/architecture.md +5 -2
  6. {okf_cli-0.5.1 → okf_cli-0.5.4}/openwiki/quickstart.md +9 -3
  7. {okf_cli-0.5.1 → okf_cli-0.5.4}/openwiki/workflows.md +1 -1
  8. {okf_cli-0.5.1 → okf_cli-0.5.4}/pyproject.toml +2 -6
  9. okf_cli-0.5.4/skills/okf-cli/SKILL.md +196 -0
  10. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/api.py +64 -28
  11. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/commands/bundle.py +13 -1
  12. okf_cli-0.5.4/src/okf/commands/list.py +39 -0
  13. {okf_cli-0.5.1 → okf_cli-0.5.4}/tests/test_api.py +188 -0
  14. {okf_cli-0.5.1 → okf_cli-0.5.4}/tests/test_cli.py +115 -0
  15. {okf_cli-0.5.1 → okf_cli-0.5.4}/uv.lock +1 -1
  16. okf_cli-0.5.1/example/blank-line/no-blank.md +0 -3
  17. okf_cli-0.5.1/skills/okf-cli-manual/SKILL.md +0 -110
  18. okf_cli-0.5.1/src/okf/commands/list.py +0 -24
  19. {okf_cli-0.5.1 → okf_cli-0.5.4}/.github/workflows/test.yml +0 -0
  20. {okf_cli-0.5.1 → okf_cli-0.5.4}/.gitignore +0 -0
  21. {okf_cli-0.5.1 → okf_cli-0.5.4}/.last-update.json +0 -0
  22. {okf_cli-0.5.1 → okf_cli-0.5.4}/LICENSE +0 -0
  23. {okf_cli-0.5.1 → okf_cli-0.5.4}/OKF_SPEC.md +0 -0
  24. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/.okfignore +0 -0
  25. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/README.md +0 -0
  26. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/blank-line/with-blank.md +0 -0
  27. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/datasets/sales.md +0 -0
  28. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/domain.md +0 -0
  29. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/loose/deep/no-heading.md +0 -0
  30. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/loose/no-desc.md +0 -0
  31. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/loose/no-title.md +0 -0
  32. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/playbooks/incident-response.md +0 -0
  33. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/playbooks/oncall-guide.md +0 -0
  34. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/smoke-ignore.md +0 -0
  35. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/tables/customers.md +0 -0
  36. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/tables/orders.md +0 -0
  37. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/tables/partitions/2026/q1/jan/january.md +0 -0
  38. {okf_cli-0.5.1 → okf_cli-0.5.4}/example/tables/partitions/daily.md +0 -0
  39. {okf_cli-0.5.1 → okf_cli-0.5.4}/openwiki/domain-model.md +0 -0
  40. {okf_cli-0.5.1 → okf_cli-0.5.4}/openwiki/operations.md +0 -0
  41. {okf_cli-0.5.1 → okf_cli-0.5.4}/openwiki/testing.md +0 -0
  42. {okf_cli-0.5.1 → okf_cli-0.5.4}/skills/writing-knowledge-base/SKILL.md +0 -0
  43. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/__init__.py +0 -0
  44. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/cli.py +0 -0
  45. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/commands/__init__.py +0 -0
  46. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/commands/read.py +0 -0
  47. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/commands/validate.py +0 -0
  48. {okf_cli-0.5.1 → okf_cli-0.5.4}/src/okf/core.py +0 -0
  49. {okf_cli-0.5.1 → okf_cli-0.5.4}/tests/test_core.py +0 -0
@@ -45,7 +45,7 @@ okf-cli
45
45
  │ └── commands/
46
46
  │ ├── bundle.py # thin wrapper → api.bundle()
47
47
  │ ├── list.py # thin wrapper → api.list_concepts()
48
- │ ├── show.py # thin wrapper → api.show_concept()
48
+ │ ├── read.py # thin wrapper → api.show_concept()
49
49
  │ └── validate.py # thin wrapper → api.validate()
50
50
  └── tests/
51
51
  ├── test_api.py # API unit/integration tests
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: okf-cli
3
- Version: 0.5.1
3
+ Version: 0.5.4
4
4
  Summary: Open Knowledge Format tooling
5
5
  License: MIT License
6
6
 
@@ -34,7 +34,7 @@ Description-Content-Type: text/markdown
34
34
 
35
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.
36
36
 
37
- Also validates bundles, lists concept IDs, reads concepts by ID, and reports version.
37
+ Also validates bundles, lists concepts, reads concepts by ID, and reports version.
38
38
 
39
39
  ## Install
40
40
 
@@ -60,12 +60,12 @@ Global options: `--version`, `--help`.
60
60
  okf bundle <input-dir> [output-dir] [--default-type <name>] [--force] [--strict]
61
61
  ```
62
62
 
63
- | Argument | Description |
64
- | ---------------- | ---------------------------------------------------------------------------- |
65
- | `input-dir` | Directory of plain `.md` files |
66
- | `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
67
- | `--default-type` | Type for root-level files (default: input directory name) |
68
- | `--force`, `-f` | Overwrite output directory if it exists |
63
+ | Argument | Description |
64
+ | ---------------- | ------------------------------------------------------------------------------------------------ |
65
+ | `input-dir` | Directory of plain `.md` files |
66
+ | `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
67
+ | `--default-type` | Type for root-level files (default: input directory name) |
68
+ | `--force`, `-f` | Overwrite output directory if it exists |
69
69
  | `--strict` | Enforce strict OKF spec output: fail on broken local `.md` links and skip `AGENTS.md` generation |
70
70
 
71
71
  ```bash
@@ -77,18 +77,22 @@ okf bundle example bundled --default-type reference --force --strict
77
77
 
78
78
  **Link checking**: scans body links to local `.md` targets. Missing or out-of-bundle links warn by default, fail with `--strict`.
79
79
 
80
- ### `okf list` — list concept IDs in a bundle
80
+ ### `okf list` — list concepts in a bundle
81
81
 
82
82
  ```
83
83
  okf list <directory>
84
84
  ```
85
85
 
86
- Prints concept IDs (path without `.md`). Requires valid OKF bundle.
86
+ Prints a table of concepts with ID, type, title, and description. Requires valid OKF bundle.
87
87
 
88
88
  ```bash
89
89
  okf list example_knowledge_base/
90
- # datasets/sales
91
- # tables/orders
90
+ # ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┓
91
+ # ┃ ID ┃ Type ┃ Title ┃ Description ┃
92
+ # ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━┩
93
+ # │ datasets/sales │ datasets │ Sales │ Sales data. │
94
+ # │ tables/orders │ tables │ Orders │ One row. │
95
+ # └────────────────┴──────────┴────────┴─────────────┘
92
96
  ```
93
97
 
94
98
  ### `okf read` — read a concept by ID
@@ -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, reads concepts by ID, and reports version.
5
+ Also validates bundles, lists concepts, reads concepts by ID, and reports version.
6
6
 
7
7
  ## Install
8
8
 
@@ -28,12 +28,12 @@ Global options: `--version`, `--help`.
28
28
  okf bundle <input-dir> [output-dir] [--default-type <name>] [--force] [--strict]
29
29
  ```
30
30
 
31
- | Argument | Description |
32
- | ---------------- | ---------------------------------------------------------------------------- |
33
- | `input-dir` | Directory of plain `.md` files |
34
- | `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
35
- | `--default-type` | Type for root-level files (default: input directory name) |
36
- | `--force`, `-f` | Overwrite output directory if it exists |
31
+ | Argument | Description |
32
+ | ---------------- | ------------------------------------------------------------------------------------------------ |
33
+ | `input-dir` | Directory of plain `.md` files |
34
+ | `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
35
+ | `--default-type` | Type for root-level files (default: input directory name) |
36
+ | `--force`, `-f` | Overwrite output directory if it exists |
37
37
  | `--strict` | Enforce strict OKF spec output: fail on broken local `.md` links and skip `AGENTS.md` generation |
38
38
 
39
39
  ```bash
@@ -45,18 +45,22 @@ okf bundle example bundled --default-type reference --force --strict
45
45
 
46
46
  **Link checking**: scans body links to local `.md` targets. Missing or out-of-bundle links warn by default, fail with `--strict`.
47
47
 
48
- ### `okf list` — list concept IDs in a bundle
48
+ ### `okf list` — list concepts in a bundle
49
49
 
50
50
  ```
51
51
  okf list <directory>
52
52
  ```
53
53
 
54
- Prints concept IDs (path without `.md`). Requires valid OKF bundle.
54
+ Prints a table of concepts with ID, type, title, and description. Requires valid OKF bundle.
55
55
 
56
56
  ```bash
57
57
  okf list example_knowledge_base/
58
- # datasets/sales
59
- # tables/orders
58
+ # ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┓
59
+ # ┃ ID ┃ Type ┃ Title ┃ Description ┃
60
+ # ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━┩
61
+ # │ datasets/sales │ datasets │ Sales │ Sales data. │
62
+ # │ tables/orders │ tables │ Orders │ One row. │
63
+ # └────────────────┴──────────┴────────┴─────────────┘
60
64
  ```
61
65
 
62
66
  ### `okf read` — read a concept by ID
@@ -0,0 +1,4 @@
1
+ # No Blank Line
2
+
3
+ > Description immediately follows the title with no blank line between.
4
+ > This file tests strict parsing when `# Title`, `> description`, and body are all adjacent.
@@ -23,6 +23,7 @@ Public functions and return types:
23
23
  | `convert_file(input_file, output_file, type_)` | `BundleResult` | Convert single markdown file to OKF concept (timestamp from mtime) |
24
24
  | `convert_content(content, output_file, type_)` | `BundleResult` | Convert raw markdown string to OKF concept (no timestamp) |
25
25
  | `list_concepts(bundle_dir)` | `list[str]` | Conformance-gated concept ID listing |
26
+ | `list_entries(bundle_dir)` | `list[dict]` | Conformance-gated concept metadata (id, type, title, description) |
26
27
  | `show_concept(bundle_dir, concept_id)` | `ConceptContent` | Conformance-gated concept read with path traversal guard |
27
28
  | `validate(bundle_dir)` | `ValidateResult` | Conformance check with `.ok` property |
28
29
 
@@ -59,9 +60,11 @@ Each file imports from `okf.api` and calls the corresponding function, translati
59
60
  1. Call `check_conformance` once.
60
61
  1. Return `ValidateResult` with file count, errors, and warnings.
61
62
 
62
- ### `okf list` and `okf read` (via `api.list_concepts()` / `api.show_concept()`)
63
+ ### `okf list` and `okf read` (via `api.list_entries()` / `api.show_concept()`)
63
64
 
64
- Both functions first run `check_conformance`. If directory is non-conformant, they raise `ValueError`.
65
+ `okf list` renders the metadata returned by `api.list_entries()` as a Rich table (ID, type, title, description). `okf read` looks up a single concept by ID via `api.show_concept()`.
66
+
67
+ Both reading paths first run `check_conformance`. If directory is non-conformant, they raise `ValueError`.
65
68
 
66
69
  Reason: reading APIs should not return misleading data from broken bundles.
67
70
 
@@ -5,7 +5,7 @@
5
5
  - CLI entrypoint: `src/okf/cli.py`
6
6
  - Programmatic Python API: `src/okf/api.py`
7
7
  - Shared parsing/conformance logic: `src/okf/core.py`
8
- - Commands (thin wrappers): `src/okf/commands/bundle.py`, `src/okf/commands/validate.py`, `src/okf/commands/list.py`, `src/okf/commands/show.py`
8
+ - Commands (thin wrappers): `src/okf/commands/bundle.py`, `src/okf/commands/validate.py`, `src/okf/commands/list.py`, `src/okf/commands/read.py`
9
9
 
10
10
  ## Start in 5 minutes
11
11
 
@@ -19,14 +19,19 @@ uv run okf validate example_knowledge_base
19
19
  uv run okf list example_knowledge_base
20
20
  uv run okf read example_knowledge_base tables/customers
21
21
  uv run okf bundle example --default-type reference --force --strict
22
+ uv run okf bundle example --default-type reference --dry-run
22
23
  ```
23
24
 
24
25
  ### Python API
25
26
 
26
27
  ```python
27
28
  from okf.api import (
28
- bundle, convert_file, convert_content,
29
- list_concepts, show_concept, validate,
29
+ bundle,
30
+ convert_file,
31
+ convert_content,
32
+ list_concepts,
33
+ show_concept,
34
+ validate,
30
35
  )
31
36
 
32
37
  # Full directory bundle
@@ -51,6 +56,7 @@ Why this sequence:
51
56
  1. `validate` checks OKF conformance gate used by readers.
52
57
  1. `list`/`show` operate only on conformant bundles.
53
58
  1. `--strict` catches broken local `.md` references at bundle time and skips `AGENTS.md` generation.
59
+ 1. `--dry-run` validates the source and reports warnings/errors without writing any files.
54
60
 
55
61
  ## OpenWiki map
56
62
 
@@ -51,7 +51,7 @@ uv run okf list <output-dir>
51
51
  uv run okf read <output-dir> <concept-id>
52
52
  ```
53
53
 
54
- `list` returns concept IDs; `show` prints full concept markdown.
54
+ `list` prints a table of concepts (ID, type, title, description); `read` prints full concept markdown.
55
55
 
56
56
  ## Contributor workflow
57
57
 
@@ -1,15 +1,11 @@
1
1
  [project]
2
2
  name = "okf-cli"
3
- version = "0.5.1"
3
+ version = "0.5.4"
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 = [
9
- "typer>=0.15",
10
- "pyyaml>=6",
11
- "rich>=15.0.0",
12
- ]
8
+ dependencies = ["typer>=0.15", "pyyaml>=6", "rich>=15.0.0"]
13
9
 
14
10
  [project.scripts]
15
11
  okf = "okf.cli:app"
@@ -0,0 +1,196 @@
1
+ ---
2
+ name: okf-cli
3
+ description: >
4
+ User manual and reference for the okf CLI tool (Open Knowledge Format).
5
+ Use for questions about bundling plain markdown into OKF knowledge bases,
6
+ validating OKF bundles, listing concepts, reading concepts, CLI options,
7
+ and end-user workflows. Not for okf-cli source development.
8
+ license: MIT
9
+ ---
10
+
11
+ # okf CLI User Manual
12
+
13
+ `okf` converts plain markdown directories into **Open Knowledge Format (OKF)** bundles — structured knowledge bases with YAML frontmatter, auto-generated indexes, and cross-link support.
14
+
15
+ ## Installation
16
+
17
+ Requires Python 3.11+ and `uv`:
18
+
19
+ ```bash
20
+ uv tool install okf-cli
21
+ okf --version
22
+ ```
23
+
24
+ Upgrade:
25
+
26
+ ```bash
27
+ uv tool upgrade okf-cli
28
+ ```
29
+
30
+ ## CLI overview
31
+
32
+ ```bash
33
+ okf [OPTIONS] COMMAND [ARGS]...
34
+ ```
35
+
36
+ Global options:
37
+
38
+ | Option | Description |
39
+ | ---------------------- | ---------------------------------------- |
40
+ | `--version` | Show version and exit |
41
+ | `--install-completion` | Install completion for the current shell |
42
+ | `--show-completion` | Print completion script to copy |
43
+ | `--help` | Show help |
44
+
45
+ ## Commands
46
+
47
+ ### `okf bundle`
48
+
49
+ Convert a directory of plain markdown into an OKF bundle.
50
+
51
+ ```bash
52
+ okf bundle <input-dir> [output-dir] [OPTIONS]
53
+ ```
54
+
55
+ Arguments:
56
+
57
+ | Argument | Description |
58
+ | ------------ | -------------------------------------------------------- |
59
+ | `input-dir` | Source directory of plain markdown files |
60
+ | `output-dir` | Target directory (default: `<input-dir>_knowledge_base`) |
61
+
62
+ Options:
63
+
64
+ | Option | Description |
65
+ | ----------------------- | ----------------------------------------------------------------- |
66
+ | `--default-type <type>` | Concept type for root-level files (default: input directory name) |
67
+ | `--force`, `-f` | Overwrite output directory if it exists |
68
+ | `--strict` | Fail on broken local `.md` links and skip `AGENTS.md` generation |
69
+
70
+ Examples:
71
+
72
+ ```bash
73
+ okf bundle my-docs --default-type reference
74
+ okf bundle my-docs out --default-type reference --force
75
+ okf bundle my-docs --default-type reference --strict
76
+ ```
77
+
78
+ Behavior:
79
+
80
+ - Skips `index.md`, `log.md`, `README.md` during input scanning.
81
+ - Reads `.okfignore` in the input root for exact bundle-relative paths to skip.
82
+ - Generates `index.md` in every directory containing concepts or subdirectories.
83
+ - Generates `AGENTS.md` at bundle root with navigation guidance (skipped with `--strict`).
84
+ - Warns about broken local `.md` links; `--strict` turns warnings into fatal errors.
85
+
86
+ ### `okf validate`
87
+
88
+ Check whether a directory conforms to the OKF specification.
89
+
90
+ ```bash
91
+ okf validate <directory>
92
+ ```
93
+
94
+ Reports errors and warnings per file. Exits non-zero on conformance failures.
95
+
96
+ ### `okf list`
97
+
98
+ List all concept IDs in a conformant OKF bundle.
99
+
100
+ ```bash
101
+ okf list <directory>
102
+ ```
103
+
104
+ Concept IDs are bundle-relative paths without the `.md` suffix, e.g. `tables/orders`.
105
+
106
+ ### `okf read`
107
+
108
+ Print a concept's full contents by concept ID.
109
+
110
+ ```bash
111
+ okf read <directory> <concept-id>
112
+ ```
113
+
114
+ Example:
115
+
116
+ ```bash
117
+ okf read my-docs_knowledge_base tables/orders
118
+ ```
119
+
120
+ ## Plain markdown input format
121
+
122
+ Best-quality input uses strict shape:
123
+
124
+ ```markdown
125
+ # Clear Concept Title
126
+
127
+ > One-sentence summary of this concept.
128
+
129
+ Body content with useful context, structure, examples, or schema.
130
+ ```
131
+
132
+ Lenient fallback exists for imperfect files, but metadata quality may be lower.
133
+
134
+ Rules:
135
+
136
+ - First line: `# Title`
137
+ - Next block: `>` description (concise, factual)
138
+ - Directory name becomes the concept `type`: `tables/orders.md` → type `tables`
139
+ - Root-level files use `--default-type`, or the input directory name if omitted
140
+ - Do not add frontmatter to source files — `okf bundle` generates it
141
+ - Avoid creating `index.md`, `log.md`, or `README.md` as source concepts (reserved)
142
+
143
+ ## Typical workflow
144
+
145
+ ```bash
146
+ # 1. Bundle
147
+ okf bundle my-notes --default-type reference --force
148
+
149
+ # 2. Validate
150
+ okf validate my-notes_knowledge_base
151
+
152
+ # 3. Explore
153
+ okf list my-notes_knowledge_base
154
+ okf read my-notes_knowledge_base some/concept
155
+ ```
156
+
157
+ ## `.okfignore`
158
+
159
+ Place in the input root to exclude markdown files. Syntax:
160
+
161
+ ```text
162
+ # comments and blank lines allowed
163
+ private-notes.md
164
+ drafts/old-post.md
165
+ ```
166
+
167
+ Entries are exact bundle-relative paths. No glob or negation support.
168
+
169
+ ## Reserved filenames
170
+
171
+ These files are never treated as concepts:
172
+
173
+ - `index.md` — generated directory listings
174
+ - `log.md` — changelog / activity log
175
+ - `agents.md` — agent navigation guidance (generated)
176
+ - `README.md` — skipped only during bundling input
177
+
178
+ ## Strict mode
179
+
180
+ Use `--strict` when you want:
181
+
182
+ - Broken local `.md` links to fail the bundle
183
+ - No `AGENTS.md` generated
184
+
185
+ Example:
186
+
187
+ ```bash
188
+ okf bundle my-docs --default-type reference --strict
189
+ ```
190
+
191
+ ## Tips
192
+
193
+ - Always run `okf validate` before consuming a bundle with `list` or `read`; those commands refuse non-conformant bundles.
194
+ - Use `--force` when regenerating bundles; output directories are not overwritten by default.
195
+ - Root-level markdown files get their `type` from the input directory name unless `--default-type` is set.
196
+ - Subdirectory markdown files get their `type` from the subdirectory name.
@@ -265,6 +265,7 @@ def bundle(
265
265
  default_type: str | None = None,
266
266
  force: bool = False,
267
267
  strict: bool = False,
268
+ dry_run: bool = False,
268
269
  ) -> BundleResult:
269
270
  """Convert plain markdown into an OKF-conformant knowledge bundle.
270
271
 
@@ -275,6 +276,8 @@ def bundle(
275
276
  force: Overwrite output directory if it exists.
276
277
  strict: Enforce strict OKF spec output: fail on broken local .md
277
278
  links and skip AGENTS.md generation.
279
+ dry_run: Validate and report what would be written without creating
280
+ or modifying any files or directories.
278
281
 
279
282
  Returns:
280
283
  BundleResult with counts, warnings, and errors.
@@ -294,12 +297,14 @@ def bundle(
294
297
  raise ValueError("Input and output directories must be different")
295
298
 
296
299
  if dst.exists():
297
- if not force:
300
+ if not dry_run and not force:
298
301
  raise FileExistsError(
299
302
  f"Output directory '{dst}' exists. Use --force to overwrite."
300
303
  )
301
- shutil.rmtree(dst)
302
- warnings.append(f"Removed existing '{dst}'")
304
+ if force:
305
+ if not dry_run:
306
+ shutil.rmtree(dst)
307
+ warnings.append(f"Removed existing '{dst}'")
303
308
 
304
309
  try:
305
310
  ignored = _load_okfignore(src)
@@ -372,7 +377,6 @@ def bundle(
372
377
  for f in md_files:
373
378
  rel = f.relative_to(src)
374
379
  out_file = dst / rel
375
- out_file.parent.mkdir(parents=True, exist_ok=True)
376
380
 
377
381
  if rel.parent == Path("."):
378
382
  type_name = default_type or src.name
@@ -383,19 +387,22 @@ def bundle(
383
387
  title, description, body = parse_md(text)
384
388
  ts = datetime.fromtimestamp(f.stat().st_mtime, tz=UTC).isoformat()
385
389
 
386
- try:
387
- _write_concept(title, description, body, out_file, type_name, ts)
388
- except ValueError as e:
389
- errors.append(f"{rel}: {e}")
390
- return BundleResult(len(processed), dst, warnings, errors)
390
+ if not dry_run:
391
+ out_file.parent.mkdir(parents=True, exist_ok=True)
392
+ try:
393
+ _write_concept(title, description, body, out_file, type_name, ts)
394
+ except ValueError as e:
395
+ errors.append(f"{rel}: {e}")
396
+ return BundleResult(len(processed), dst, warnings, errors)
391
397
  processed.append(
392
398
  (rel, {"title": title, "description": description, "type": type_name})
393
399
  )
394
400
 
395
- _generate_indexes(processed, dst)
401
+ if not dry_run:
402
+ _generate_indexes(processed, dst)
396
403
 
397
404
  # Write AGENTS.md (skipped in strict mode)
398
- if not strict:
405
+ if not dry_run and not strict:
399
406
  (dst / "AGENTS.md").write_text(
400
407
  f"# Knowledge Base: {dst.name}\n\n"
401
408
  f"You are in an OKF (Open Knowledge Format) knowledge base called "
@@ -428,6 +435,27 @@ def bundle(
428
435
  )
429
436
 
430
437
 
438
+ def _iter_concept_files(dir_path: Path):
439
+ """Yield (concept_id, file_path) for every concept in a bundle.
440
+
441
+ Validates the directory and conformance before iterating. Skips
442
+ spec-reserved filenames such as ``index.md`` and ``log.md``.
443
+ """
444
+ if not dir_path.is_dir():
445
+ raise NotADirectoryError(f"'{dir_path}' is not a directory")
446
+
447
+ errors, _warnings = check_conformance(dir_path)
448
+ if errors:
449
+ raise ValueError("not an OKF-conformant bundle:\n" + "\n".join(errors))
450
+
451
+ for f in sorted(dir_path.rglob("*.md")):
452
+ if f.name.lower() in SPEC_RESERVED:
453
+ continue
454
+ rel = f.relative_to(dir_path)
455
+ cid = str(rel.parent / rel.stem) if rel.parent != Path(".") else rel.stem
456
+ yield cid, f
457
+
458
+
431
459
  def list_concepts(bundle_dir: str | Path) -> list[str]:
432
460
  """List all concept IDs in an OKF-conformant bundle.
433
461
 
@@ -440,24 +468,34 @@ def list_concepts(bundle_dir: str | Path) -> list[str]:
440
468
  Raises:
441
469
  ValueError: If the directory is not a valid OKF bundle.
442
470
  """
443
- dir_path = Path(bundle_dir)
471
+ return [cid for cid, _f in _iter_concept_files(Path(bundle_dir))]
444
472
 
445
- if not dir_path.is_dir():
446
- raise NotADirectoryError(f"'{dir_path}' is not a directory")
447
473
 
448
- errors, _warnings = check_conformance(dir_path)
449
- if errors:
450
- raise ValueError("not an OKF-conformant bundle:\n" + "\n".join(errors))
474
+ def list_entries(bundle_dir: str | Path) -> list[dict[str, str]]:
475
+ """List all concepts with their frontmatter metadata.
451
476
 
452
- cids: list[str] = []
453
- for f in sorted(dir_path.rglob("*.md")):
454
- if f.name.lower() in SPEC_RESERVED:
455
- continue
456
- rel = f.relative_to(dir_path)
457
- cid = str(rel.parent / rel.stem) if rel.parent != Path(".") else rel.stem
458
- cids.append(cid)
477
+ Args:
478
+ bundle_dir: Path to an OKF bundle directory.
459
479
 
460
- return cids
480
+ Returns:
481
+ Sorted list of dicts with keys ``id``, ``type``, ``title``,
482
+ ``description``. ``title`` and ``description`` are empty strings
483
+ when absent from frontmatter.
484
+
485
+ Raises:
486
+ ValueError: If the directory is not a valid OKF bundle.
487
+ """
488
+ entries: list[dict[str, str]] = []
489
+ for cid, f in _iter_concept_files(Path(bundle_dir)):
490
+ fm = parse_frontmatter(f.read_text(encoding="utf-8")) or {}
491
+ entries.append({
492
+ "id": cid,
493
+ "type": str(fm.get("type", "")),
494
+ "title": str(fm.get("title", "")),
495
+ "description": str(fm.get("description", "")),
496
+ })
497
+
498
+ return entries
461
499
 
462
500
 
463
501
  def show_concept(bundle_dir: str | Path, concept_id: str) -> ConceptContent:
@@ -494,9 +532,7 @@ def show_concept(bundle_dir: str | Path, concept_id: str) -> ConceptContent:
494
532
  raise ValueError(f"'{concept_id}' is a reserved filename, not a concept")
495
533
 
496
534
  if not concept_path.is_file():
497
- raise FileNotFoundError(
498
- f"Concept '{concept_id}' not found"
499
- )
535
+ raise FileNotFoundError(f"Concept '{concept_id}' not found")
500
536
 
501
537
  raw = concept_path.read_text(encoding="utf-8")
502
538
  fm = parse_frontmatter(raw)
@@ -29,6 +29,11 @@ def bundle(
29
29
  "and skip AGENTS.md generation"
30
30
  ),
31
31
  ),
32
+ dry_run: bool = typer.Option(
33
+ False,
34
+ "--dry-run",
35
+ help="Validate and show warnings without writing any files",
36
+ ),
32
37
  ) -> None:
33
38
  """Convert plain markdown into an OKF-conformant knowledge bundle."""
34
39
  try:
@@ -38,6 +43,7 @@ def bundle(
38
43
  default_type=default_type,
39
44
  force=force,
40
45
  strict=strict,
46
+ dry_run=dry_run,
41
47
  )
42
48
  except FileNotFoundError as e:
43
49
  err_console.print(f"Error: {e}", style="red")
@@ -58,7 +64,13 @@ def bundle(
58
64
  raise typer.Exit(code=1)
59
65
 
60
66
  n = result.files_written
67
+ if dry_run:
68
+ verb = "Would convert"
69
+ prefix = "Dry run."
70
+ else:
71
+ verb = "Converted"
72
+ prefix = "Done."
61
73
  console.print(
62
- f"Done. Converted {n} file{'s' if n != 1 else ''} → {result.output_dir}",
74
+ f"{prefix} {verb} {n} file{'s' if n != 1 else ''} → {result.output_dir}",
63
75
  style="green",
64
76
  )
@@ -0,0 +1,39 @@
1
+ """okf list command."""
2
+
3
+ from pathlib import Path
4
+
5
+ import typer
6
+ from rich.table import Table
7
+
8
+ from okf import api
9
+ from okf.core import console, err_console
10
+
11
+
12
+ def cmd_list(
13
+ directory: str = typer.Argument(..., help="Directory of the OKF bundle"),
14
+ ) -> None:
15
+ """List concepts in a table with ID, type, title, and description."""
16
+ try:
17
+ entries = api.list_entries(directory)
18
+ except (ValueError, NotADirectoryError) as e:
19
+ err_console.print(f"Error: {e}", style="red")
20
+ raise typer.Exit(code=1)
21
+
22
+ if not entries:
23
+ err_console.print("No concepts found", style="yellow")
24
+ raise typer.Exit(code=1)
25
+
26
+ table = Table(
27
+ "ID",
28
+ "Type",
29
+ "Title",
30
+ "Description",
31
+ caption="Use the ID column with: okf read <bundle> <id>",
32
+ )
33
+ table.columns[0].no_wrap = True
34
+
35
+ for e in entries:
36
+ title = e["title"] if e["title"] else Path(e["id"]).stem
37
+ table.add_row(e["id"], e["type"], title, e["description"])
38
+
39
+ console.print(table)
@@ -13,6 +13,7 @@ from okf.api import (
13
13
  convert_content,
14
14
  convert_file,
15
15
  list_concepts,
16
+ list_entries,
16
17
  show_concept,
17
18
  validate,
18
19
  )
@@ -458,6 +459,84 @@ class TestBundle:
458
459
  assert "[bad](bad.md)" in index
459
460
  assert "[](" not in index
460
461
 
462
+ def test_dry_run_no_writes(self, tmp_path: Path):
463
+ src = tmp_path / "src"
464
+ dst = tmp_path / "out"
465
+ src.mkdir()
466
+ _write(
467
+ src,
468
+ {
469
+ "tables/orders.md": "# Orders\n\n> One row.\n\nBody.",
470
+ "tables/customers.md": "# Customers\n\n> All.\n\nBody.",
471
+ },
472
+ )
473
+
474
+ result = bundle(src, dst, dry_run=True)
475
+
476
+ assert result.files_written == 2
477
+ assert result.errors == []
478
+ assert not dst.exists()
479
+
480
+ def test_dry_run_reports_warnings(self, tmp_path: Path):
481
+ src = tmp_path / "src"
482
+ dst = tmp_path / "out"
483
+ src.mkdir()
484
+ _write(
485
+ src,
486
+ {"tables/orders.md": "# Orders\n\n> One row.\n\nSee [C](customers.md)."},
487
+ )
488
+
489
+ result = bundle(src, dst, dry_run=True)
490
+
491
+ assert result.files_written == 1
492
+ assert any("not found in bundle" in w for w in result.warnings)
493
+ assert not dst.exists()
494
+
495
+ def test_dry_run_force_does_not_delete_existing(self, tmp_path: Path):
496
+ src = tmp_path / "src"
497
+ dst = tmp_path / "out"
498
+ src.mkdir()
499
+ dst.mkdir()
500
+ (dst / "old.txt").write_text("preserve me")
501
+ _write(src, {"tables/a.md": "# A\n\n> Desc.\n"})
502
+
503
+ result = bundle(src, dst, force=True, dry_run=True)
504
+
505
+ assert result.files_written == 1
506
+ assert any("Removed existing" in w for w in result.warnings)
507
+ assert (dst / "old.txt").exists()
508
+ assert (dst / "old.txt").read_text() == "preserve me"
509
+
510
+ def test_dry_run_no_force_when_output_exists(self, tmp_path: Path):
511
+ src = tmp_path / "src"
512
+ dst = tmp_path / "out"
513
+ src.mkdir()
514
+ dst.mkdir()
515
+ (dst / "old.txt").write_text("preserve me")
516
+ _write(src, {"tables/a.md": "# A\n\n> Desc.\n"})
517
+
518
+ result = bundle(src, dst, dry_run=True)
519
+
520
+ assert result.files_written == 1
521
+ assert result.errors == []
522
+ assert not any("Removed existing" in w for w in result.warnings)
523
+ assert (dst / "old.txt").exists()
524
+
525
+ def test_dry_run_strict_still_fails(self, tmp_path: Path):
526
+ src = tmp_path / "src"
527
+ dst = tmp_path / "out"
528
+ src.mkdir()
529
+ _write(
530
+ src,
531
+ {"tables/orders.md": "# Orders\n\n> One row.\n\nSee [C](customers.md)."},
532
+ )
533
+
534
+ result = bundle(src, dst, strict=True, dry_run=True)
535
+
536
+ assert result.files_written == 0
537
+ assert any("strict link check failed" in e.lower() for e in result.errors)
538
+ assert not dst.exists()
539
+
461
540
 
462
541
  # ---------------------------------------------------------------------------
463
542
  # list_concepts()
@@ -561,6 +640,115 @@ class TestListConcepts:
561
640
  list_concepts(tmp_path / "nope")
562
641
 
563
642
 
643
+ # ---------------------------------------------------------------------------
644
+ # list_entries()
645
+ # ---------------------------------------------------------------------------
646
+
647
+
648
+ class TestListEntries:
649
+ def test_lists_with_metadata(self, tmp_path: Path):
650
+ src = tmp_path / "src"
651
+ dst = tmp_path / "out"
652
+ src.mkdir()
653
+ _write(
654
+ src,
655
+ {
656
+ "tables/orders.md": "# Orders\n\n> Customer orders.\n\nBody.",
657
+ "datasets/sales.md": "# Sales\n\n> Sales dataset.\n\nBody.",
658
+ },
659
+ )
660
+ bundle(src, dst)
661
+
662
+ entries = list_entries(dst)
663
+
664
+ assert isinstance(entries, list)
665
+ assert all(isinstance(e, dict) for e in entries)
666
+ keys = ("id", "type", "title", "description")
667
+ assert all(k in e for e in entries for k in keys)
668
+ assert {"tables/orders", "datasets/sales"} == {e["id"] for e in entries}
669
+
670
+ def test_entries_have_types(self, tmp_path: Path):
671
+ src = tmp_path / "src"
672
+ dst = tmp_path / "out"
673
+ src.mkdir()
674
+ _write(
675
+ src,
676
+ {
677
+ "tables/a.md": "# A\n\n> Desc.\n\nBody.",
678
+ "playbooks/b.md": "# B\n\n> Playbook.\n\nBody.",
679
+ },
680
+ )
681
+ bundle(src, dst)
682
+
683
+ entries = list_entries(dst)
684
+ by_id = {e["id"]: e for e in entries}
685
+
686
+ assert by_id["tables/a"]["type"] == "tables"
687
+ assert by_id["playbooks/b"]["type"] == "playbooks"
688
+
689
+ def test_missing_title_shows_empty(self, tmp_path: Path):
690
+ src = tmp_path / "src"
691
+ dst = tmp_path / "out"
692
+ src.mkdir()
693
+ _write(src, {"tables/bad.md": "No heading.\n> Desc.\n"})
694
+ bundle(src, dst)
695
+
696
+ entries = list_entries(dst)
697
+ assert entries[0]["title"] == ""
698
+
699
+ def test_missing_description_shows_empty(self, tmp_path: Path):
700
+ # Construct a bundle manually so description is truly absent.
701
+ d = tmp_path / "bundle"
702
+ d.mkdir()
703
+ (d / "tables").mkdir()
704
+ (d / "tables" / "minimal.md").write_text(
705
+ "---\ntype: tables\ntitle: Minimal\n---\n\nJust body."
706
+ )
707
+
708
+ entries = list_entries(d)
709
+ assert entries[0]["description"] == ""
710
+
711
+ def test_excludes_reserved(self, tmp_path: Path):
712
+ src = tmp_path / "src"
713
+ dst = tmp_path / "out"
714
+ src.mkdir()
715
+ _write(src, {"tables/a.md": "# A\n\n> Desc.\n"})
716
+ bundle(src, dst)
717
+
718
+ entries = list_entries(dst)
719
+ ids = {e["id"] for e in entries}
720
+ assert "index" not in ids
721
+
722
+ def test_sorted_order(self, tmp_path: Path):
723
+ src = tmp_path / "src"
724
+ dst = tmp_path / "out"
725
+ src.mkdir()
726
+ _write(
727
+ src,
728
+ {
729
+ "tables/orders.md": "# Orders\n\n> One row.\n",
730
+ "playbooks/incident.md": "# Incident\n\n> Playbook.\n",
731
+ },
732
+ )
733
+ bundle(src, dst)
734
+
735
+ entries = list_entries(dst)
736
+ ids = [e["id"] for e in entries]
737
+ assert ids == sorted(ids)
738
+
739
+ def test_not_conformant(self, tmp_path: Path):
740
+ d = tmp_path / "raw"
741
+ d.mkdir()
742
+ _write(d, {"plain.md": "# Title\n\n> Desc.\n\nBody."})
743
+
744
+ with pytest.raises(ValueError, match="not an OKF-conformant"):
745
+ list_entries(d)
746
+
747
+ def test_not_a_dir(self, tmp_path: Path):
748
+ with pytest.raises(NotADirectoryError):
749
+ list_entries(tmp_path / "nope")
750
+
751
+
564
752
  # ---------------------------------------------------------------------------
565
753
  # show_concept()
566
754
  # ---------------------------------------------------------------------------
@@ -87,6 +87,64 @@ def test_bundle_strict_shows_error(tmp_path: Path):
87
87
  assert not (dst / "AGENTS.md").exists()
88
88
 
89
89
 
90
+ def test_bundle_dry_run_no_writes(tmp_path: Path):
91
+ src = tmp_path / "src"
92
+ dst = tmp_path / "out"
93
+ src.mkdir()
94
+ _write(src, {"tables/a.md": "# A\n\n> Desc.\n"})
95
+
96
+ result = runner.invoke(app, ["bundle", str(src), str(dst), "--dry-run"])
97
+ assert result.exit_code == 0
98
+ assert "Dry run" in result.output
99
+ assert "Would convert" in result.output
100
+ assert not dst.exists()
101
+
102
+
103
+ def test_bundle_dry_run_existing_output_no_force(tmp_path: Path):
104
+ src = tmp_path / "src"
105
+ dst = tmp_path / "out"
106
+ src.mkdir()
107
+ dst.mkdir()
108
+ _write(src, {"tables/a.md": "# A\n\n> Desc.\n"})
109
+
110
+ result = runner.invoke(app, ["bundle", str(src), str(dst), "--dry-run"])
111
+ assert result.exit_code == 0
112
+ assert "Dry run" in result.output
113
+ assert "--force" not in result.output
114
+ assert dst.exists()
115
+
116
+
117
+ def test_bundle_dry_run_shows_warnings(tmp_path: Path):
118
+ src = tmp_path / "src"
119
+ dst = tmp_path / "out"
120
+ src.mkdir()
121
+ _write(
122
+ src,
123
+ {"tables/orders.md": "# Orders\n\n> One row.\n\nSee [C](customers.md)."},
124
+ )
125
+
126
+ result = runner.invoke(app, ["bundle", str(src), str(dst), "--dry-run"])
127
+ assert result.exit_code == 0
128
+ normalized = " ".join(result.output.split())
129
+ assert "not found in bundle" in normalized
130
+ assert not dst.exists()
131
+
132
+
133
+ def test_bundle_dry_run_strict_exits_on_error(tmp_path: Path):
134
+ src = tmp_path / "src"
135
+ dst = tmp_path / "out"
136
+ src.mkdir()
137
+ _write(
138
+ src,
139
+ {"tables/orders.md": "# Orders\n\n> One row.\n\nSee [C](customers.md)."},
140
+ )
141
+
142
+ result = runner.invoke(app, ["bundle", str(src), str(dst), "--dry-run", "--strict"])
143
+ assert result.exit_code == 1
144
+ assert "strict link check failed" in result.output
145
+ assert not dst.exists()
146
+
147
+
90
148
  # ---------------------------------------------------------------------------
91
149
  # validate — exit codes & error messages
92
150
  # ---------------------------------------------------------------------------
@@ -152,6 +210,63 @@ def test_list_empty_shows_message(tmp_path: Path):
152
210
  assert "No concepts found" in result.output
153
211
 
154
212
 
213
+ def test_list_shows_table(tmp_path: Path):
214
+ d = tmp_path / "bundle"
215
+ d.mkdir()
216
+ _write(
217
+ d,
218
+ {
219
+ "tables/orders.md": (
220
+ "---\n"
221
+ "type: tables\n"
222
+ "title: Orders\n"
223
+ "description: Customer orders.\n"
224
+ "---\n\n"
225
+ "Body."
226
+ ),
227
+ "datasets/sales.md": (
228
+ "---\n"
229
+ "type: datasets\n"
230
+ "title: Sales\n"
231
+ "description: Sales data.\n"
232
+ "---\n\n"
233
+ "Body."
234
+ ),
235
+ },
236
+ )
237
+
238
+ result = runner.invoke(app, ["list", str(d)])
239
+ assert result.exit_code == 0
240
+ assert "Type" in result.output
241
+ assert "Title" in result.output
242
+ assert "Description" in result.output
243
+ assert "ID" in result.output
244
+ assert "Orders" in result.output
245
+ assert "Customer orders." in result.output
246
+ assert "tables/orders" in result.output
247
+ assert "okf read" in result.output
248
+
249
+
250
+ def test_list_falls_back_to_stem_for_missing_title(tmp_path: Path):
251
+ d = tmp_path / "bundle"
252
+ d.mkdir()
253
+ _write(
254
+ d,
255
+ {
256
+ "tables/bad.md": (
257
+ "---\n"
258
+ "type: tables\n"
259
+ "---\n\n"
260
+ "Body."
261
+ ),
262
+ },
263
+ )
264
+
265
+ result = runner.invoke(app, ["list", str(d)])
266
+ assert result.exit_code == 0
267
+ assert "bad" in result.output
268
+
269
+
155
270
  # ---------------------------------------------------------------------------
156
271
  # read — exit codes & error messages
157
272
  # ---------------------------------------------------------------------------
@@ -52,7 +52,7 @@ wheels = [
52
52
 
53
53
  [[package]]
54
54
  name = "okf-cli"
55
- version = "0.5.0"
55
+ version = "0.5.4"
56
56
  source = { editable = "." }
57
57
  dependencies = [
58
58
  { name = "pyyaml" },
@@ -1,3 +0,0 @@
1
- # No Blank Line
2
- > Description immediately follows the title with no blank line between.
3
- This file tests strict parsing when `# Title`, `> description`, and body are all adjacent.
@@ -1,110 +0,0 @@
1
- ---
2
- name: okf-cli-manual
3
- description: Install and use okf-cli to convert plain markdown into OKF-conformant knowledge bundles, list concept IDs, inspect concepts, and validate bundles. Use when the user asks to "bundle markdown", "create OKF bundle", "validate OKF", "list concepts", or work with okf-cli.
4
- license: MIT
5
- ---
6
-
7
- # okf-cli Manual
8
-
9
- Install and use okf-cli for working with Open Knowledge Format (OKF)
10
-
11
- ## Install
12
-
13
- ```bash
14
- uv tool install okf-cli
15
- okf --version
16
- ```
17
-
18
- Upgrade:
19
-
20
- ```bash
21
- uv tool upgrade okf-cli
22
- ```
23
-
24
- ## Commands
25
-
26
- ### `okf bundle` — convert plain markdown to OKF bundle
27
-
28
- ```
29
- okf bundle <input-dir> [output-dir] [--default-type <type>] [--force] [--strict-links]
30
- ```
31
-
32
- | Argument | Description |
33
- | ---------------- | ---------------------------------------------------------------------------- |
34
- | `input-dir` | Directory of plain `.md` files |
35
- | `output-dir` | Target directory (default: `bundled`) |
36
- | `--default-type` | Type for root-level files — skip root files if omitted |
37
- | `--force`, `-f` | Overwrite output directory if it exists |
38
- | `--strict-links` | Fail if local markdown links point outside bundle or to missing `.md` target |
39
-
40
- ```bash
41
- okf bundle my-docs bundled --default-type reference
42
- okf bundle my-docs bundled --default-type reference --force
43
- okf bundle my-docs bundled --default-type reference --strict-links
44
- ```
45
-
46
- `.okfignore` — place in `input-dir` root, one bundle-relative path per line:
47
-
48
- ```
49
- # skip these files
50
- smoke-ignore.md
51
- tables/orders.md
52
- ```
53
-
54
- ### `okf list` — list concept IDs in a bundle
55
-
56
- ```
57
- okf list <directory>
58
- ```
59
-
60
- Prints concept IDs (path with `.md` stripped). Reserved files (`index.md`, `log.md`) excluded.
61
-
62
- ```bash
63
- okf list bundled/
64
- # datasets/sales
65
- # tables/orders
66
- # tables/customers
67
- ```
68
-
69
- ### `okf show` — print a concept by ID
70
-
71
- ```
72
- okf show <directory> <concept-id>
73
- ```
74
-
75
- ```bash
76
- okf show bundled/ tables/orders
77
- ```
78
-
79
- ### `okf validate` — check OKF conformance
80
-
81
- ```
82
- okf validate <directory>
83
- ```
84
-
85
- Validates per OKF §9: frontmatter present, `type` non-empty, reserved filenames follow structure.
86
-
87
- ```bash
88
- okf validate bundled/
89
- ```
90
-
91
- ## Input format for `bundle`
92
-
93
- Each `.md` file should follow this structure:
94
-
95
- ```markdown
96
- # Clear Concept Title
97
-
98
- > One-sentence summary of this concept.
99
-
100
- Body content with useful context, structure, examples, or schema.
101
- ```
102
-
103
- Rules:
104
-
105
- - First line: `# Title`
106
- - Second block: `>` description (concise, factual)
107
- - Directory name becomes the concept `type`: `tables/orders.md` → type `tables`
108
- - Root-level files require `--default-type`
109
- - Do not add frontmatter to source files — `okf bundle` generates it
110
- - Avoid creating `index.md`, `log.md`, or `README.md` as source concepts (reserved by spec)
@@ -1,24 +0,0 @@
1
- """okf list command."""
2
-
3
- import typer
4
-
5
- from okf import api
6
- from okf.core import console, err_console
7
-
8
-
9
- def cmd_list(
10
- directory: str = typer.Argument(..., help="Directory of the OKF bundle"),
11
- ) -> None:
12
- """List all concept IDs in an OKF bundle."""
13
- try:
14
- cids = api.list_concepts(directory)
15
- except (ValueError, NotADirectoryError) as e:
16
- err_console.print(f"Error: {e}", style="red")
17
- raise typer.Exit(code=1)
18
-
19
- if not cids:
20
- err_console.print("No concepts found", style="yellow")
21
- raise typer.Exit(code=1)
22
-
23
- for cid in cids:
24
- console.print(cid, style="cyan")
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