diff --git a/docs/prompt-pool-routing-map.md b/docs/prompt-pool-routing-map.md index 0409534..4f5b50c 100644 --- a/docs/prompt-pool-routing-map.md +++ b/docs/prompt-pool-routing-map.md @@ -892,8 +892,11 @@ Run: ```bash python tools/prompt_map_audit.py +python tools/prompt_map_audit.py --quiet ``` +Use `--quiet` when you only need pass/fail output in a focused validation pass. + The script does not import ComfyUI. It parses the repo and prints: - registered display node names and known return names; diff --git a/tools/prompt_map_audit.py b/tools/prompt_map_audit.py index a4df28b..18e987b 100644 --- a/tools/prompt_map_audit.py +++ b/tools/prompt_map_audit.py @@ -10,6 +10,7 @@ ComfyUI loaded. from __future__ import annotations import ast +import argparse import json import re import sys @@ -1210,7 +1211,24 @@ def print_table(headers: tuple[str, ...], rows: list[tuple[Any, ...]]) -> None: print("| " + " | ".join(str(value).ljust(widths[index]) for index, value in enumerate(row)) + " |") -def main() -> int: +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--quiet", + action="store_true", + help="Suppress inventory tables and passing validation messages.", + ) + args = parser.parse_args(argv) + quiet = bool(args.quiet) + + def emit(message: str) -> None: + if not quiet: + print(message) + + def emit_table(headers: tuple[str, ...], rows: list[tuple[Any, ...]]) -> None: + if not quiet: + print_table(headers, rows) + category_paths = _category_json_paths() display: dict[str, Any] = {} returns: dict[str, tuple[str, ...]] = {} @@ -1219,14 +1237,14 @@ def main() -> int: display.update(_assignment_dict(path, "LOOP_NODE_DISPLAY_NAME_MAPPINGS")) returns.update(_class_return_names(path)) - print("# Node Display Map") + emit("# Node Display Map") node_rows = [] for class_name, display_name in sorted(display.items(), key=lambda item: str(item[1])): return_names = ", ".join(returns.get(class_name, ())) node_rows.append((display_name, class_name, return_names or "(dynamic or unnamed)")) - print_table(("Display name", "Class", "Return names"), node_rows) + emit_table(("Display name", "Class", "Return names"), node_rows) - print("\n# Category JSON Summary") + emit("\n# Category JSON Summary") category_rows = [] for path in category_paths: summary = _category_summary(path) @@ -1242,7 +1260,7 @@ def main() -> int: summary["pool_extensions"], ) ) - print_table( + emit_table( ( "File", "Categories", @@ -1256,91 +1274,93 @@ def main() -> int: category_rows, ) - print("\n# Named Pool Inventory") + emit("\n# Named Pool Inventory") pool_rows = [] for path in category_paths: for key in ("scene_pools", "expression_pools", "composition_pools"): names = _pool_names(path, key) if names: pool_rows.append((path.name, key, len(names), ", ".join(names[:8]) + (" ..." if len(names) > 8 else ""))) - print_table(("File", "Pool type", "Count", "First names"), pool_rows) + emit_table(("File", "Pool type", "Count", "First names"), pool_rows) - print("\n# JSON Reference Validation") + emit("\n# JSON Reference Validation") reference_errors = _json_reference_errors(category_paths) if reference_errors: print_table(("File", "Path", "Issue"), reference_errors) return 1 - print("OK: all JSON pool references and item template axes resolve.") + emit("OK: all JSON pool references and item template axes resolve.") - print("\n# Category Identity Validation") + emit("\n# Category Identity Validation") category_identity_errors = _category_identity_errors(category_paths) if category_identity_errors: print_table(("Source", "Path", "Issue"), category_identity_errors) return 1 - print("OK: category and subcategory identities are unique and selector-safe.") + emit("OK: category and subcategory identities are unique and selector-safe.") - print("\n# Hardcore Template Metadata Validation") + emit("\n# Hardcore Template Metadata Validation") hardcore_metadata_errors = _hardcore_template_metadata_errors(category_paths) if hardcore_metadata_errors: print_table(("File", "Path", "Issue"), hardcore_metadata_errors) return 1 - print("OK: hardcore template subcategories define explicit route metadata defaults.") + emit("OK: hardcore template subcategories define explicit route metadata defaults.") - print("\n# Effective Category Route Coverage Validation") + emit("\n# Effective Category Route Coverage Validation") category_coverage_errors = _effective_category_coverage_errors(category_paths) if category_coverage_errors: print_table(("Source", "Path", "Issue"), category_coverage_errors) return 1 - print("OK: category routes define effective item, scene, expression, composition, and route metadata coverage.") + emit("OK: category routes define effective item, scene, expression, composition, and route metadata coverage.") - print("\n# Registered Route Policy Validation") + emit("\n# Registered Route Policy Validation") registered_route_errors = _registered_route_policy_errors() if registered_route_errors: print_table(("Source", "Path", "Issue"), registered_route_errors) return 1 - print("OK: registered route families have SDXL tags, caption labels, and valid incompatibility filters.") + emit("OK: registered route families have SDXL tags, caption labels, and valid incompatibility filters.") - print("\n# Location Theme Camera Profile Validation") + emit("\n# Location Theme Camera Profile Validation") location_profile_errors = _location_theme_camera_profile_errors() if location_profile_errors: print_table(("Source", "Path", "Issue"), location_profile_errors) return 1 - print("OK: location themes and themed scene entries resolve to scene camera profiles.") + emit("OK: location themes and themed scene entries resolve to scene camera profiles.") - print("\n# Routing Documentation Validation") + emit("\n# Routing Documentation Validation") routing_doc_errors = _routing_doc_errors() if routing_doc_errors: print_table(("Module", "Location", "Issue"), routing_doc_errors) return 1 - print("OK: critical route modules are documented and covered by smoke cases.") + emit("OK: critical route modules are documented and covered by smoke cases.") - print("\n# Node Documentation Validation") + emit("\n# Node Documentation Validation") node_doc_errors = _node_documentation_errors(display) if node_doc_errors: print_table(("Node", "Location", "Issue"), node_doc_errors) return 1 - print("OK: registered node display names are documented in the route map or README.") + emit("OK: registered node display names are documented in the route map or README.") - print("\n# Node Registration Validation") + emit("\n# Node Registration Validation") node_registration_errors = _node_registration_errors() if node_registration_errors: print_table(("Module", "Node", "Issue"), node_registration_errors) return 1 - print("OK: concrete SxCP node classes are registered with matching display names.") + emit("OK: concrete SxCP node classes are registered with matching display names.") - print("\n# Metadata Prompt Fallback Validation") + emit("\n# Metadata Prompt Fallback Validation") prompt_row_read_errors = _prompt_row_read_errors() if prompt_row_read_errors: print_table(("Module", "Location", "Issue"), prompt_row_read_errors) return 1 - print("OK: metadata formatter modules avoid raw prompt reads outside audited fallback helpers.") + emit("OK: metadata formatter modules avoid raw prompt reads outside audited fallback helpers.") - print("\n# Runtime Metadata Route Validation") + emit("\n# Runtime Metadata Route Validation") runtime_metadata_errors = _runtime_metadata_errors() if runtime_metadata_errors: print_table(("Source", "Location", "Issue"), runtime_metadata_errors) return 1 - print("OK: builder rows, pair rows, and formatter traces preserve metadata routes.") + emit("OK: builder rows, pair rows, and formatter traces preserve metadata routes.") + if quiet: + print("OK: prompt map audit passed.") return 0