Lint the knowledge base for structural and semantic inconsistencies.
(ctx, fix)
| 1919 | ) |
| 1920 | @click.pass_context |
| 1921 | def lint(ctx, fix): |
| 1922 | """Lint the knowledge base for structural and semantic inconsistencies.""" |
| 1923 | kb_dir = _find_kb_dir(ctx.obj.get("kb_dir_override")) |
| 1924 | if kb_dir is None: |
| 1925 | click.echo("No knowledge base found. Run `openkb init` first.") |
| 1926 | return |
| 1927 | if fix: |
| 1928 | from openkb.lint import fix_broken_links |
| 1929 | |
| 1930 | with kb_ingest_lock(kb_dir / ".openkb"): |
| 1931 | files_changed, ghosts = fix_broken_links(kb_dir / "wiki") |
| 1932 | if files_changed: |
| 1933 | click.echo(f"Fixed {ghosts} wikilink(s) across {files_changed} file(s).") |
| 1934 | else: |
| 1935 | click.echo("Nothing to fix — all wikilinks resolve.") |
| 1936 | asyncio.run(run_lint(kb_dir)) |
| 1937 | |
| 1938 | |
| 1939 | @cli.command() |
nothing calls this directly
no test coverage detected