- tools/kblib.py: ladybug schema, embeddings, FTS+vector, hybrid RRF
- bin/kb/{index,search,get,stats,eval}: corpus indexing + deduction search
- bin/facts/{extract,audit}: 2-source evidence acquisition + gates
- serve/: async Go HTTP server (goroutines, bounded worker pool), TDD
- docker/ flattened to root: compose.yaml + Dockerfile (multi-stage Go)
- docker scripts -> bin/ shebang pattern (kb-watch, docker-entrypoint)
- bin/ci/semver + tools/semver.py: conventional-commit semver release
- ci.yml: go tests + shell checks; drop release-please (PR toggle blocked)
49 lines
1.5 KiB
Python
Executable File
49 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import lib
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
from mdleaves import leaves_to_json, read_markdown, to_all, walk_markdown # noqa: E402
|
|
from yamlout import to_yaml # noqa: E402
|
|
|
|
|
|
def main(argv: list[str]) -> int:
|
|
import argparse
|
|
p = argparse.ArgumentParser(description="md/import - split markdown corpus into leafs")
|
|
p.add_argument("root", nargs="?", default=".", help="directory to walk for .md files")
|
|
p.add_argument("--files", action="store", help="comma-separated file list")
|
|
p.add_argument("--json", action="store_true")
|
|
a = p.parse_args(argv)
|
|
|
|
paths: list[Path] = []
|
|
if a.files:
|
|
paths = [Path(f) for f in a.files.split(",")]
|
|
else:
|
|
root = Path(a.root)
|
|
if not root.exists():
|
|
print(f"md/import: no such path {root}", file=sys.stderr)
|
|
return 2
|
|
paths = [root] if root.is_file() else walk_markdown(root)
|
|
|
|
if not paths:
|
|
print("md/import: no markdown files", file=sys.stderr)
|
|
return 1
|
|
|
|
all_leafs: list[dict] = []
|
|
for path in paths:
|
|
try:
|
|
text = read_markdown(path)
|
|
except OSError as e:
|
|
print(f"md/import: {path}: {e}", file=sys.stderr)
|
|
continue
|
|
all_leafs.extend(to_all(text, path))
|
|
|
|
out = leaves_to_json(all_leafs)
|
|
print(out if a.json else to_yaml(__import__("json").loads(out)))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv[1:])) |