okf-cli 0.5.4__tar.gz → 0.5.5__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.5.4 → okf_cli-0.5.5}/.github/workflows/test.yml +2 -0
- okf_cli-0.5.5/.last-update.json +1 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/AGENTS.md +2 -2
- {okf_cli-0.5.4 → okf_cli-0.5.5}/PKG-INFO +1 -1
- {okf_cli-0.5.4 → okf_cli-0.5.5}/openwiki/architecture.md +12 -11
- {okf_cli-0.5.4 → okf_cli-0.5.5}/openwiki/testing.md +6 -4
- {okf_cli-0.5.4 → okf_cli-0.5.5}/openwiki/workflows.md +4 -3
- {okf_cli-0.5.4 → okf_cli-0.5.5}/pyproject.toml +1 -1
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/api.py +15 -6
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/commands/bundle.py +2 -2
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/commands/list.py +3 -3
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/commands/validate.py +4 -3
- {okf_cli-0.5.4 → okf_cli-0.5.5}/tests/test_api.py +6 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/tests/test_cli.py +1 -6
- {okf_cli-0.5.4 → okf_cli-0.5.5}/uv.lock +1 -1
- okf_cli-0.5.4/.last-update.json +0 -4
- {okf_cli-0.5.4 → okf_cli-0.5.5}/.gitignore +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/LICENSE +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/OKF_SPEC.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/README.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/.okfignore +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/README.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/blank-line/no-blank.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/blank-line/with-blank.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/datasets/sales.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/domain.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/loose/deep/no-heading.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/loose/no-desc.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/loose/no-title.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/playbooks/incident-response.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/playbooks/oncall-guide.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/smoke-ignore.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/tables/customers.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/tables/orders.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/tables/partitions/2026/q1/jan/january.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/example/tables/partitions/daily.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/openwiki/domain-model.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/openwiki/operations.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/openwiki/quickstart.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/skills/okf-cli/SKILL.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/skills/writing-knowledge-base/SKILL.md +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/__init__.py +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/cli.py +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/commands/__init__.py +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/commands/read.py +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/src/okf/core.py +0 -0
- {okf_cli-0.5.4 → okf_cli-0.5.5}/tests/test_core.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"head": "661f7ac9042711e133fd4c8fe4e806e1f2d81b13", "timestamp": "2026-07-26T08:13:49Z"}
|
|
@@ -44,7 +44,7 @@ okf-cli
|
|
|
44
44
|
│ ├── core.py # shared parsing/formatting/conformance
|
|
45
45
|
│ └── commands/
|
|
46
46
|
│ ├── bundle.py # thin wrapper → api.bundle()
|
|
47
|
-
│ ├── list.py # thin wrapper → api.
|
|
47
|
+
│ ├── list.py # thin wrapper → api.list_entries()
|
|
48
48
|
│ ├── read.py # thin wrapper → api.show_concept()
|
|
49
49
|
│ └── validate.py # thin wrapper → api.validate()
|
|
50
50
|
└── tests/
|
|
@@ -72,7 +72,7 @@ uv run okf validate bundled
|
|
|
72
72
|
|
|
73
73
|
### Modify conformance behavior
|
|
74
74
|
|
|
75
|
-
Update `check_conformance()` in `src/okf/core.py`, then ensure `validate`, `list`, and `
|
|
75
|
+
Update `check_conformance()` in `src/okf/core.py`, then ensure `validate`, `list`, and `read` all behave consistently.
|
|
76
76
|
|
|
77
77
|
## Style guidelines
|
|
78
78
|
|
|
@@ -17,15 +17,15 @@ Why this split: the API layer is the canonical home for all logic. Commands hand
|
|
|
17
17
|
|
|
18
18
|
Public functions and return types:
|
|
19
19
|
|
|
20
|
-
| Function
|
|
21
|
-
|
|
|
22
|
-
| `bundle(input_dir, output_dir,
|
|
23
|
-
| `convert_file(input_file, output_file, type_)`
|
|
24
|
-
| `convert_content(content, output_file, type_)`
|
|
25
|
-
| `list_concepts(bundle_dir)`
|
|
26
|
-
| `list_entries(bundle_dir)`
|
|
27
|
-
| `show_concept(bundle_dir, concept_id)`
|
|
28
|
-
| `validate(bundle_dir)`
|
|
20
|
+
| Function | Returns | Key behavior |
|
|
21
|
+
| ------------------------------------------------------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
22
|
+
| `bundle(input_dir, output_dir, *, default_type, force, strict, dry_run)` | `BundleResult` | Full bundle pipeline with link checking, `.okfignore`, `AGENTS.md` generation; `dry_run` validates and reports without writing |
|
|
23
|
+
| `convert_file(input_file, output_file, type_)` | `BundleResult` | Convert single markdown file to OKF concept (timestamp from mtime) |
|
|
24
|
+
| `convert_content(content, output_file, type_)` | `BundleResult` | Convert raw markdown string to OKF concept (no timestamp) |
|
|
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) |
|
|
27
|
+
| `show_concept(bundle_dir, concept_id)` | `ConceptContent` | Conformance-gated concept read with path traversal guard |
|
|
28
|
+
| `validate(bundle_dir)` | `ValidateResult` | Conformance check with `.ok` property |
|
|
29
29
|
|
|
30
30
|
Internal helpers (not public API): `_iter_links`, `_resolve_md_target`, `_load_okfignore`, `_generate_indexes`, `_write_concept`.
|
|
31
31
|
|
|
@@ -49,7 +49,8 @@ Each file imports from `okf.api` and calls the corresponding function, translati
|
|
|
49
49
|
1. Read source directory + optional `.okfignore` (`_load_okfignore`).
|
|
50
50
|
1. Walk `*.md`, skipping reserved names and ignored paths.
|
|
51
51
|
1. Parse each markdown file via `parse_md` (strict first, lenient fallback).
|
|
52
|
-
1. Scan markdown body links via `_iter_links` / `_resolve_md_target` — warns on missing or out-of-bundle targets; `--strict` makes these fatal.
|
|
52
|
+
1. Scan markdown body links via `_iter_links` / `_resolve_md_target` — warns on missing or out-of-bundle targets; `--strict` makes these fatal (even during `--dry-run`).
|
|
53
|
+
1. If `dry_run=True`, skip all writes: no concept files, no `index.md` files, and no `AGENTS.md`. The result still reports planned `files_written` and any warnings/errors.
|
|
53
54
|
1. Build YAML frontmatter via `build_frontmatter`.
|
|
54
55
|
1. Write transformed files and generate `index.md` per directory.
|
|
55
56
|
1. Write `AGENTS.md` at output root with navigation guidance for the knowledge base (skipped when `--strict` is used).
|
|
@@ -82,7 +83,7 @@ Source: `src/okf/core.py` (constants), `src/okf/api.py` (enforcement).
|
|
|
82
83
|
|
|
83
84
|
Major behavior shifts:
|
|
84
85
|
|
|
85
|
-
- project started bundling-focused, then added `validate`/`list`/`
|
|
86
|
+
- project started bundling-focused, then added `validate`/`list`/`read` workflow;
|
|
86
87
|
- frontmatter parsing/conformance matured to real YAML parsing and shared conformance gating;
|
|
87
88
|
- markdown parsing in bundling became lenient to tolerate imperfect source docs;
|
|
88
89
|
- `.okfignore` added to allow selective exclusions without moving/deleting source files;
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
- API unit/integration tests: `tests/test_api.py`
|
|
6
6
|
- `TestBundle` — bundling via `api.bundle()`, link checking, `.okfignore`, lenient parsing, `AGENTS.md` generation
|
|
7
7
|
- `TestListConcepts` — listing via `api.list_concepts()`, reserved file handling
|
|
8
|
+
- `TestListEntries` — listing metadata via `api.list_entries()` (ID, type, title, description)
|
|
8
9
|
- `TestShowConcept` — reading via `api.show_concept()`, path traversal guard
|
|
9
10
|
- `TestValidate` — conformance checks via `api.validate()`, all §9 rule variants
|
|
10
|
-
- `TestWorkflow` — cross-command pipeline (bundle → validate/list/
|
|
11
|
+
- `TestWorkflow` — cross-command pipeline (bundle → validate/list/read)
|
|
11
12
|
- `TestConvertFile` — single-file conversion via `api.convert_file()`, mtime timestamp
|
|
12
13
|
- `TestConvertContent` — raw markdown conversion via `api.convert_content()`, no timestamp
|
|
13
14
|
- Core unit tests: `tests/test_core.py`
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
- conformance engine (`check_conformance`)
|
|
17
18
|
- CLI integration tests: `tests/test_cli.py`
|
|
18
19
|
- exit codes and error message formatting for all commands
|
|
19
|
-
- Typer-specific behavior (argument parsing, `--force`, `--strict`)
|
|
20
|
+
- Typer-specific behavior (argument parsing, `--force`, `--strict`, `--dry-run`)
|
|
20
21
|
|
|
21
22
|
## Run tests
|
|
22
23
|
|
|
@@ -70,8 +71,9 @@ uv run pytest -q
|
|
|
70
71
|
- Lenient parsing fallback when strict markdown format is missing.
|
|
71
72
|
- Reserved filename differences between bundling and spec conformance.
|
|
72
73
|
- Root `index.md` special allowance for `okf_version` only.
|
|
73
|
-
- `list`/`
|
|
74
|
-
- `
|
|
74
|
+
- `list`/`read` hard failure on non-conformant bundles.
|
|
75
|
+
- `read` path traversal guard.
|
|
75
76
|
- Link checking: `_resolve_md_target` path resolution, `--strict` fatal mode, missing/out-of-bundle targets.
|
|
77
|
+
- `--dry-run`: no files written, warnings still reported, `--force` does not delete existing output.
|
|
76
78
|
|
|
77
79
|
Primary evidence: `tests/test_api.py`, `tests/test_core.py`, `tests/test_cli.py`.
|
|
@@ -19,7 +19,7 @@ Lenient fallback exists for imperfect files, but strict shape gives better metad
|
|
|
19
19
|
### 2) Bundle to OKF
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
uv run okf bundle <input-dir> [output-dir] [--default-type <type>] [--force] [--strict]
|
|
22
|
+
uv run okf bundle <input-dir> [output-dir] [--default-type <type>] [--force] [--strict] [--dry-run]
|
|
23
23
|
# output-dir defaults to <input-dir>_knowledge_base
|
|
24
24
|
# --default-type defaults to input directory name
|
|
25
25
|
```
|
|
@@ -30,7 +30,8 @@ Important behavior:
|
|
|
30
30
|
- Reserved filenames skipped during bundling (`index.md`, `log.md`, `README.md`).
|
|
31
31
|
- `.okfignore` in input root can skip exact bundle-relative paths.
|
|
32
32
|
- `--strict` enforces strict OKF spec output: fails on broken local `.md` links and skips `AGENTS.md` generation.
|
|
33
|
-
- `
|
|
33
|
+
- `--dry-run` validates the source and reports warnings/errors without writing files or directories; existing output is left untouched even if `--force` is passed.
|
|
34
|
+
- `AGENTS.md` is generated at output root with navigation guidance (unless `--strict` or `--dry-run` is used).
|
|
34
35
|
|
|
35
36
|
Source: `src/okf/api.py`.
|
|
36
37
|
|
|
@@ -61,7 +62,7 @@ Start files:
|
|
|
61
62
|
|
|
62
63
|
- `src/okf/core.py`
|
|
63
64
|
- `tests/test_core.py`
|
|
64
|
-
- `tests/test_api.py` (validate/list/
|
|
65
|
+
- `tests/test_api.py` (validate/list/read tests)
|
|
65
66
|
|
|
66
67
|
Why: `check_conformance` and parsing helpers are shared dependencies across the API layer.
|
|
67
68
|
|
|
@@ -296,6 +296,13 @@ def bundle(
|
|
|
296
296
|
if src.resolve() == dst.resolve():
|
|
297
297
|
raise ValueError("Input and output directories must be different")
|
|
298
298
|
|
|
299
|
+
try:
|
|
300
|
+
dst.resolve().relative_to(src.resolve())
|
|
301
|
+
except ValueError:
|
|
302
|
+
pass
|
|
303
|
+
else:
|
|
304
|
+
raise ValueError("Output directory must not be inside input directory")
|
|
305
|
+
|
|
299
306
|
if dst.exists():
|
|
300
307
|
if not dry_run and not force:
|
|
301
308
|
raise FileExistsError(
|
|
@@ -488,12 +495,14 @@ def list_entries(bundle_dir: str | Path) -> list[dict[str, str]]:
|
|
|
488
495
|
entries: list[dict[str, str]] = []
|
|
489
496
|
for cid, f in _iter_concept_files(Path(bundle_dir)):
|
|
490
497
|
fm = parse_frontmatter(f.read_text(encoding="utf-8")) or {}
|
|
491
|
-
entries.append(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
498
|
+
entries.append(
|
|
499
|
+
{
|
|
500
|
+
"id": cid,
|
|
501
|
+
"type": str(fm.get("type", "")),
|
|
502
|
+
"title": str(fm.get("title", "")),
|
|
503
|
+
"description": str(fm.get("description", "")),
|
|
504
|
+
}
|
|
505
|
+
)
|
|
497
506
|
|
|
498
507
|
return entries
|
|
499
508
|
|
|
@@ -57,8 +57,8 @@ def bundle(
|
|
|
57
57
|
|
|
58
58
|
for w in result.warnings:
|
|
59
59
|
err_console.print(f"Warning: {w}", style="yellow")
|
|
60
|
-
for
|
|
61
|
-
err_console.print(f"Error: {
|
|
60
|
+
for error in result.errors:
|
|
61
|
+
err_console.print(f"Error: {error}", style="red")
|
|
62
62
|
|
|
63
63
|
if result.errors:
|
|
64
64
|
raise typer.Exit(code=1)
|
|
@@ -32,8 +32,8 @@ def cmd_list(
|
|
|
32
32
|
)
|
|
33
33
|
table.columns[0].no_wrap = True
|
|
34
34
|
|
|
35
|
-
for
|
|
36
|
-
title =
|
|
37
|
-
table.add_row(
|
|
35
|
+
for entry in entries:
|
|
36
|
+
title = entry["title"] if entry["title"] else Path(entry["id"]).stem
|
|
37
|
+
table.add_row(entry["id"], entry["type"], title, entry["description"])
|
|
38
38
|
|
|
39
39
|
console.print(table)
|
|
@@ -18,10 +18,11 @@ def validate(
|
|
|
18
18
|
|
|
19
19
|
for w in result.warnings:
|
|
20
20
|
err_console.print(f"Warning: {w}", style="yellow")
|
|
21
|
-
for
|
|
22
|
-
err_console.print(f"Error: {
|
|
21
|
+
for error in result.errors:
|
|
22
|
+
err_console.print(f"Error: {error}", style="red")
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
bad_files = len({error.split(":", 1)[0] for error in result.errors})
|
|
25
|
+
ok = result.total_files - bad_files
|
|
25
26
|
parts = [f"{result.total_files} files: {ok} ok"]
|
|
26
27
|
if result.errors:
|
|
27
28
|
parts.append(f"{len(result.errors)} errors")
|
|
@@ -226,6 +226,12 @@ class TestBundle:
|
|
|
226
226
|
with pytest.raises(ValueError, match="different"):
|
|
227
227
|
bundle(src, src)
|
|
228
228
|
|
|
229
|
+
def test_output_inside_input(self, tmp_path: Path):
|
|
230
|
+
src = tmp_path / "src"
|
|
231
|
+
src.mkdir()
|
|
232
|
+
with pytest.raises(ValueError, match="inside input"):
|
|
233
|
+
bundle(src, src / "out")
|
|
234
|
+
|
|
229
235
|
def test_empty_dir(self, tmp_path: Path):
|
|
230
236
|
src = tmp_path / "src"
|
|
231
237
|
src.mkdir()
|
|
@@ -253,12 +253,7 @@ def test_list_falls_back_to_stem_for_missing_title(tmp_path: Path):
|
|
|
253
253
|
_write(
|
|
254
254
|
d,
|
|
255
255
|
{
|
|
256
|
-
"tables/bad.md": (
|
|
257
|
-
"---\n"
|
|
258
|
-
"type: tables\n"
|
|
259
|
-
"---\n\n"
|
|
260
|
-
"Body."
|
|
261
|
-
),
|
|
256
|
+
"tables/bad.md": ("---\ntype: tables\n---\n\nBody."),
|
|
262
257
|
},
|
|
263
258
|
)
|
|
264
259
|
|
okf_cli-0.5.4/.last-update.json
DELETED
|
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
|