Skip to content

feat: --watch mode — auto-regenerate llms.txt on file change - #82

Merged
wuzzzzaah merged 2 commits into
mainfrom
feat/watch-mode-8779591166687098691
May 27, 2026
Merged

feat: --watch mode — auto-regenerate llms.txt on file change#82
wuzzzzaah merged 2 commits into
mainfrom
feat/watch-mode-8779591166687098691

Conversation

@wuzzzzaah

Copy link
Copy Markdown
Owner

This PR introduces a --watch flag to the generate command, allowing llmstxt-gen to automatically rebuild the llms.txt files whenever a tracked source file is modified.

Key changes:

  • Dependency: Added watchfiles as an optional dependency under the watch extra.
  • Watcher Utility: Created src/llmstxt_gen/watcher.py to provide a clean iterator over file changes.
  • CLI Enhancement: Updated the generate command to support a continuous loop when --watch is enabled. It uses the existing incremental caching logic to ensure rebuilds are fast.
  • Error Handling: Explicitly prevents using --watch with --diff and handles KeyboardInterrupt to exit gracefully.
  • Logging: Prints timestamped rebuild summaries, e.g., [14:02:31] Rebuilt in 0.4s (3 files changed).
  • Tests: Added new unit tests to verify the watch loop, its interaction with the generator, and error conditions.

Fixes #76


PR created automatically by Jules for task 8779591166687098691 started by @wuzzzzaah

- Added `watch` extra with `watchfiles` dependency in `pyproject.toml`.
- Implemented `iter_changes` in new `src/llmstxt_gen/watcher.py`.
- Added `--watch` flag to `generate` command in `src/llmstxt_gen/cli.py`.
- Implemented watch loop that reuses incremental cache for fast rebuilds.
- Added comprehensive tests for watch mode in `tests/test_watcher.py`.
- Ensured `--watch` and `--diff` are mutually exclusive.
- Added clean SIGINT/KeyboardInterrupt handling.

Co-authored-by: wuzzzzaah <1645504+wuzzzzaah@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- raise typer.Exit from None inside except KeyboardInterrupt (B904)
- Remove unused imports in test_watcher.py: time, MagicMock, pytest (F401)
- Remove unused TYPE_CHECKING import of FileChange in watcher.py (F401)
- Use collections.abc.Iterator instead of typing.Iterator (UP035)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wuzzzzaah
wuzzzzaah merged commit 50315ca into main May 27, 2026
3 checks passed
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.

feat: --watch mode — auto-regenerate llms.txt on file change

1 participant