Skip to content

Add optional watch_extension hook to watch.py - #253

Open
Kimovate-git wants to merge 1 commit into
bradautomates:mainfrom
Kimovate-git:watch-extension-hook
Open

Kimovate-git wants to merge 1 commit into
bradautomates:mainfrom
Kimovate-git:watch-extension-hook

Conversation

@Kimovate-git

Copy link
Copy Markdown

What

Adds a tiny optional hook to skills/watch/scripts/watch.py: __main__ now calls _entry(), which tries import watch_extension and, if a sibling watch_extension.py exists, returns watch_extension.run(sys.modules[__name__]). Without that module, _entry() simply returns main(), so behaviour is exactly as today. A ModuleNotFoundError for any other module is re-raised, so a broken extension can't fail silently.

def _entry() -> int:
    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__])

Why

We vendor the watch skill into a larger video pipeline and add a few site-local things (extra subcommands, report sections, transcription routed through our render scheduler). Until now that meant patching watch.py, SKILL.md and friends, and every upstream release turned into a merge conflict — our nightly sync sat in conflict for two weeks after 0.3.x without anyone noticing.

With this hook every upstream file can stay byte-identical and all local logic lives in one separate file. Updates from you then apply without conflicts. It's 13 lines, adds no dependency, and changes nothing for anyone who doesn't ship a watch_extension.py.

Testing

  • Without watch_extension.py: watch.py --help and a normal run behave as before (same exit codes).
  • With an extension module: we've been running exactly this hook on top of 0.3.2 (03ceb42) in our fork, with our extension handling extra subcommands and delegating everything else back to main().

Happy to rename the hook/module or move it elsewhere if you prefer a different convention.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant