okf-generator 0.1.1__py3-none-any.whl
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/__init__.py +34 -0
- okf/cli.py +58 -0
- okf/generator.py +1626 -0
- okf/lookup.py +396 -0
- okf/pairs.py +746 -0
- okf_generator-0.1.1.dist-info/METADATA +320 -0
- okf_generator-0.1.1.dist-info/RECORD +10 -0
- okf_generator-0.1.1.dist-info/WHEEL +4 -0
- okf_generator-0.1.1.dist-info/entry_points.txt +2 -0
- okf_generator-0.1.1.dist-info/licenses/LICENSE +9 -0
okf/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""OKF — Open Knowledge Format toolkit for codebases.
|
|
2
|
+
|
|
3
|
+
Generate OKF v0.1 knowledge bundles from source code, look up concepts
|
|
4
|
+
for AI agent context injection, and convert bundles into LLM training pairs.
|
|
5
|
+
|
|
6
|
+
Quick start:
|
|
7
|
+
from okf.generator import scan_codebase, write_bundle
|
|
8
|
+
from okf.lookup import load_bundle, search
|
|
9
|
+
from okf.pairs import process_concept
|
|
10
|
+
|
|
11
|
+
CLI:
|
|
12
|
+
okf generate ./my_codebase ./okf_bundle
|
|
13
|
+
okf lookup WorldBankConnector
|
|
14
|
+
okf pairs ./okf_bundle ./train.jsonl
|
|
15
|
+
okf summarize ./okf_bundle
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
19
|
+
__author__ = "Umair Baig"
|
|
20
|
+
__license__ = "MIT"
|
|
21
|
+
|
|
22
|
+
# Public API surface
|
|
23
|
+
from okf.generator import scan_codebase, write_bundle, write_summary, Concept
|
|
24
|
+
from okf.lookup import load_bundle, search
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"scan_codebase",
|
|
28
|
+
"write_bundle",
|
|
29
|
+
"write_summary",
|
|
30
|
+
"load_bundle",
|
|
31
|
+
"search",
|
|
32
|
+
"Concept",
|
|
33
|
+
"__version__",
|
|
34
|
+
]
|
okf/cli.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""okf — unified CLI for the OKF toolkit.
|
|
2
|
+
|
|
3
|
+
Commands:
|
|
4
|
+
okf generate <source_dir> [output_dir] Generate OKF bundle from codebase
|
|
5
|
+
okf lookup <query> [options] Look up a concept in a bundle
|
|
6
|
+
okf pairs <bundle_dir> [output_file] Convert bundle to training pairs
|
|
7
|
+
okf summarize <bundle_dir> Regenerate SUMMARY.md only
|
|
8
|
+
|
|
9
|
+
Run `okf <command> --help` for per-command options.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
if len(sys.argv) < 2 or sys.argv[1] in {"-h", "--help"}:
|
|
17
|
+
print(__doc__)
|
|
18
|
+
print("Usage: okf <command> [args]")
|
|
19
|
+
print("")
|
|
20
|
+
print("Commands:")
|
|
21
|
+
print(" generate Generate OKF bundle from a codebase")
|
|
22
|
+
print(" lookup Look up concepts in a bundle")
|
|
23
|
+
print(" pairs Convert bundle to JSONL training pairs")
|
|
24
|
+
print(" summarize Regenerate SUMMARY.md from existing bundle")
|
|
25
|
+
sys.exit(0)
|
|
26
|
+
|
|
27
|
+
cmd, rest = sys.argv[1], sys.argv[2:]
|
|
28
|
+
sys.argv = [f"okf {cmd}"] + rest # rewrite argv for sub-parsers
|
|
29
|
+
|
|
30
|
+
if cmd == "generate":
|
|
31
|
+
# Handle --summarize flag routed here too
|
|
32
|
+
if rest and rest[0] == "--summarize":
|
|
33
|
+
sys.argv = ["okf generate", "--summarize"] + rest[1:]
|
|
34
|
+
from okf.generator import main as _main
|
|
35
|
+
_main()
|
|
36
|
+
|
|
37
|
+
elif cmd == "summarize":
|
|
38
|
+
# Sugar: `okf summarize <bundle>` → generator --summarize <bundle>
|
|
39
|
+
sys.argv = ["okf generate", "--summarize"] + rest
|
|
40
|
+
from okf.generator import main as _main
|
|
41
|
+
_main()
|
|
42
|
+
|
|
43
|
+
elif cmd == "lookup":
|
|
44
|
+
from okf.lookup import main as _main
|
|
45
|
+
_main()
|
|
46
|
+
|
|
47
|
+
elif cmd == "pairs":
|
|
48
|
+
from okf.pairs import main as _main
|
|
49
|
+
_main()
|
|
50
|
+
|
|
51
|
+
else:
|
|
52
|
+
print(f"Unknown command: {cmd!r}", file=sys.stderr)
|
|
53
|
+
print("Run `okf --help` for available commands.", file=sys.stderr)
|
|
54
|
+
sys.exit(1)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
main()
|