Xilp000 Script Scanner
src.xil_pipeline.XILP000_script_scanner
Pre-flight scanner for production scripts.
Reads a raw markdown script, applies the same two-pass normalization that XILP001 uses, then scans every ALL-CAPS candidate line and reports which speakers and sections are recognized vs. unknown — before any parsing state machine runs.
Use this to catch missing KNOWN_SPEAKERS or SECTION_MAP entries before they cause silent failures in XILP001.
Usage:
python XILP000_script_scanner.py "scripts/<script>.md"
python XILP000_script_scanner.py "scripts/<script>.md" --json
is_all_caps_candidate
Return True if line is a bare ALL-CAPS line worth classifying.
Excludes dividers, stage directions, scene headers, and very short or very long strings. Anything that passes is either a speaker name, a section header, or an unrecognized ALL-CAPS label.
Source code in src/xil_pipeline/XILP000_script_scanner.py
load_and_normalize
Read path and apply the two-pass markdown normalization.
Returns a list of individual lines (including blank lines) after both
strip_markdown_escapes and strip_markdown_formatting have been
applied.
Source code in src/xil_pipeline/XILP000_script_scanner.py
scan_script
scan_script(lines: list[str], known_speakers: list[str] | None = None, speaker_keys: dict[str, str] | None = None) -> dict
Scan normalized lines and classify every ALL-CAPS candidate.
Parameters:
-
lines(list[str]) –Normalized script lines.
-
known_speakers(list[str] | None, default:None) –Ordered list of speaker display names (longest-first). Defaults to the module-level speakers from XILP001.
-
speaker_keys(dict[str, str] | None, default:None) –Mapping from display names to normalized keys. Defaults to the module-level speakers from XILP001.
Returns a dict::
{
"sections": [{"text": str, "slug": str, "line": int}, ...],
"speakers": {key: {"display": str, "count": int, "lines": [int, ...]}, ...},
"unrecognized": [{"text": str, "lines": [int, ...]}, ...],
}
Source code in src/xil_pipeline/XILP000_script_scanner.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
scan_direction_texts
Audit direction texts against an existing SFX config.
Classifies each unique direction text as:
- matched: key exists in sfx_effects with a source field
- hinted: key not in sfx_effects but script has a pipe-hint (new source)
- new: key not in sfx_effects and no hint (will need generation prompt)
Parameters:
-
lines(list[str]) –Normalized script lines.
-
sfx_effects(dict) –The
effectsdict fromsfx_<TAG>.json.
Returns a dict with keys matched, hinted, new — each a list of
{"text": str, "hint": str | None, "lines": [int, ...]} dicts.
Source code in src/xil_pipeline/XILP000_script_scanner.py
scan_vintage_filter_pairing
Check that every VINTAGE FILTER ENGAGES has a matching DISENGAGES.
Returns a list of unpaired marker dicts:
{"text": str, "line": int, "type": "ENGAGES" | "DISENGAGES"}
Source code in src/xil_pipeline/XILP000_script_scanner.py
scan_preamble_postamble
Check whether PREAMBLE and POSTAMBLE sections are present.
Parameters:
Returns a dict {"preamble": bool, "postamble": bool}.
Source code in src/xil_pipeline/XILP000_script_scanner.py
scan_ambience_coverage
Check that every looping AMBIENCE direction has a stop marker.
A stop marker is either [AMBIENCE: STOP] or a direction ending in
FADES OUT. Returns a list of unclosed ambience dicts:
{"text": str, "line": int}
Source code in src/xil_pipeline/XILP000_script_scanner.py
scan_paralinguistic_tags
Flag inline [tags] that look like misspelled Chatterbox Turbo cues.
Turbo renders only the exact tokens in ALLOWED_TAGS and silently strips
everything else, so [laughs] (no such token) is dropped with no warning
at generation time. This catches those near-misses before stems are made.
Tags that are simply not Turbo cues (ElevenLabs-only [exhausted],
[pause], …) are left alone — they are valid under other backends.
Parameters:
Returns a list of::
[{"text": str, "suggestion": str, "lines": [int, ...]}, ...]
Source code in src/xil_pipeline/XILP000_script_scanner.py
format_report
Render scan results as a human-readable text report.
Source code in src/xil_pipeline/XILP000_script_scanner.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
harvest_cast
Scan all scripts for CAST: entries and optionally add new ones to speakers.json.
Reports every character declared in any CAST: block that is absent from the current speakers.json. With apply=True, appends those entries.
Source code in src/xil_pipeline/XILP000_script_scanner.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
backfill_cast
backfill_cast(scripts_dir: str, speakers_path: str | None, parsed_dir: str | None = None, dry_run: bool = True) -> None
Add CAST: blocks to scripts that don't have one.
Speaker lists are inferred from existing parsed JSON (most reliable) or by body-scanning the raw script against the known speakers.json list.
Source code in src/xil_pipeline/XILP000_script_scanner.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | |
get_parser
Return the argument parser for xil-scan.
Source code in src/xil_pipeline/XILP000_script_scanner.py
main
CLI entry point for the pre-flight script scanner.
Source code in src/xil_pipeline/XILP000_script_scanner.py
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | |