from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def read_text(path: str) -> str: return (ROOT / path).read_text(encoding="utf-8") def require(condition: bool, message: str) -> None: if not condition: raise SystemExit(message) def main() -> None: app = read_text("main/application.cc") filter_body = app.split("static bool IsInternalToolSpeech(const char* text)", 1)[1].split( "static bool IsStandbyRequestText", 1 )[0] require( "strncmp(text, \"% self.\", 7) == 0" in filter_body, "internal tool speech filter must continue to ignore percent-prefixed self tool calls", ) require( 'strstr(text, "\\\"arguments\\\"")' in filter_body, "internal tool speech filter must ignore leaked tool-call arguments JSON fragments", ) require( 'strstr(text, "\\\"trigger_time\\\"")' in filter_body, "internal tool speech filter must ignore leaked alarm trigger_time JSON fragments", ) require( 'strstr(text, "\\\"label\\\"")' in filter_body, "internal tool speech filter must ignore leaked alarm label JSON fragments", ) require( 'Ignore internal tool speech' in app, "TTS sentence_start must use the internal tool speech filter before updating display text", ) if __name__ == "__main__": main()