| 526 | |
| 527 | |
| 528 | def build_parser() -> argparse.ArgumentParser: |
| 529 | parser = argparse.ArgumentParser(description="AFML docs hierarchy authoring loop") |
| 530 | sub = parser.add_subparsers(dest="command", required=True) |
| 531 | |
| 532 | p_init = sub.add_parser("init", help="Generate state + writing prompts") |
| 533 | p_init.set_defaults(func=cmd_init) |
| 534 | |
| 535 | p_status = sub.add_parser("status", help="Show progress") |
| 536 | p_status.set_defaults(func=cmd_status) |
| 537 | |
| 538 | p_next = sub.add_parser("next", help="Claim next pending section") |
| 539 | p_next.add_argument("--print-prompt", action="store_true", help="Print prompt body") |
| 540 | p_next.set_defaults(func=cmd_next) |
| 541 | |
| 542 | p_done = sub.add_parser("done", help="Mark section done") |
| 543 | p_done.add_argument("section_id") |
| 544 | p_done.add_argument("--note", default="", help="Optional completion note") |
| 545 | p_done.set_defaults(func=cmd_done) |
| 546 | |
| 547 | p_reset = sub.add_parser("reset", help="Reset section to pending") |
| 548 | p_reset.add_argument("section_id") |
| 549 | p_reset.set_defaults(func=cmd_reset) |
| 550 | |
| 551 | p_export = sub.add_parser("export", help="Export state into docs-site data for UI rendering") |
| 552 | p_export.set_defaults(func=cmd_export) |
| 553 | |
| 554 | p_evidence = sub.add_parser("evidence", help="Run MCP retrieval loop and persist per-section evidence") |
| 555 | p_evidence.add_argument("--top-k", type=int, default=5, help="Top K hits for afml_search") |
| 556 | p_evidence.add_argument("--top-k-context", type=int, default=3, help="Top K hits for afml_get_context") |
| 557 | p_evidence.add_argument("--window", type=int, default=1, help="Neighbor chunk window for afml_get_context") |
| 558 | p_evidence.add_argument("--keep-hits", type=int, default=3, help="Number of hits to persist per section") |
| 559 | p_evidence.add_argument("--only-pending", action="store_true", help="Process only sections still pending") |
| 560 | p_evidence.add_argument("--mark-done", action="store_true", help="Mark processed sections done") |
| 561 | p_evidence.set_defaults(func=cmd_evidence) |
| 562 | |
| 563 | return parser |
| 564 | |
| 565 | |
| 566 | def main() -> int: |