From 824b4e7af8d6688166f2a2bc3f6875ed67300fd5 Mon Sep 17 00:00:00 2001 From: STEP35 Date: Sun, 26 Apr 2026 11:23:36 -0400 Subject: [PATCH] feat(knowledge-gap): add CLI entry point for monthly execution (Closes #172) - Adds main() with argparse for repo_path, --json, --output flags - Enables scheduled monthly execution via cron - Fixes to_dict() stats keys to use string values for JSON serialization --- scripts/knowledge_gap_identifier.py | 43 ++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/scripts/knowledge_gap_identifier.py b/scripts/knowledge_gap_identifier.py index 27cf750..c6f657a 100644 --- a/scripts/knowledge_gap_identifier.py +++ b/scripts/knowledge_gap_identifier.py @@ -75,7 +75,7 @@ class GapReport: return { "repo_path": self.repo_path, "total_gaps": len(self.gaps), - "stats": {k: len(v) for k, v in + "stats": {k.value: len(v) for k, v in {gt: [g for g in self.gaps if g.gap_type == gt] for gt in GapType}.items() if v}, "gaps": [ @@ -273,3 +273,44 @@ class KnowledgeGapIdentifier: )) return report + +def main() -> None: + import argparse + import json + import sys + parser = argparse.ArgumentParser( + description="Knowledge Gap Identifier — cross-reference code, docs, and tests to find gaps" + ) + parser.add_argument( + "repo_path", + nargs="?", + default=".", + help="Path to repository root (default: current directory)" + ) + parser.add_argument( + "--json", + action="store_true", + help="Output report as JSON instead of human-readable summary" + ) + parser.add_argument( + "-o", "--output", + help="Write report to file instead of stdout" + ) + args = parser.parse_args() + + report = KnowledgeGapIdentifier().analyze(args.repo_path) + + if args.json: + output = json.dumps(report.to_dict(), indent=2, default=str) + else: + output = report.summary() + + if args.output: + with open(args.output, "w") as fh: + print(output, file=fh) + else: + print(output) + + +if __name__ == "__main__": + main()