From a5a050af6cb7c4e14f66b3e1de009adcd0a713ba Mon Sep 17 00:00:00 2001 From: Kimovate-git Date: Thu, 8 Oct 2026 01:06:53 +0200 Subject: [PATCH] Add optional watch_extension hook to watch.py If a sibling module watch_extension.py exists, __main__ hands control to watch_extension.run(module) instead of main(). Without the module behaviour is unchanged. Lets teams that vendor the skill keep every upstream file byte-identical and put site-local logic into one separate file. Co-Authored-By: Claude Opus 5.5 --- skills/watch/scripts/watch.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/skills/watch/scripts/watch.py b/skills/watch/scripts/watch.py index b5b322aa..76a6c1c4 100755 --- a/skills/watch/scripts/watch.py +++ b/skills/watch/scripts/watch.py @@ -422,9 +422,21 @@ def main() -> int: return 1 if errors and not frames and not transcript_segments and not track_available else 0 +def _entry() -> int: + """Run main(), or let an optional sibling `watch_extension.py` wrap it (extra subcommands, + report sections) so site-local additions never require patching this file.""" + try: + import watch_extension # noqa: PLC0415 + except ModuleNotFoundError as exc: + if exc.name != "watch_extension": + raise + return main() + return watch_extension.run(sys.modules[__name__]) + + if __name__ == "__main__": configure_stdio() try: - raise SystemExit(main()) + raise SystemExit(_entry()) except (ConfigError, OSError) as exc: raise SystemExit(str(exc)) from None