-
Notifications
You must be signed in to change notification settings - Fork 1
fix: replace stale flat command references and guard llms.txt freshness #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """Guard against stale generated command artifacts (llms.txt and command reference). | ||
|
|
||
| The pre-commit command-overview gate only fires when specific paths are staged, so a | ||
| commit that bypasses it (merge commits, --no-verify, bot commits) can land a stale | ||
| llms.txt. A stale llms.txt misleads agents worse than a missing one, so this test | ||
| re-runs the generator in --check mode on every test run. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parents[3] | ||
| GENERATOR = REPO_ROOT / "scripts" / "generate-command-overview.py" | ||
| GENERATED_ARTIFACTS = ( | ||
| "llms.txt", | ||
| "docs/reference/commands.generated.json", | ||
| "docs/reference/commands.generated.md", | ||
| ) | ||
|
|
||
|
|
||
| def _paired_worktree_modules_repo() -> Path | None: | ||
| """Mirror the generator's paired-worktree candidate (specfact-cli-worktrees layout).""" | ||
| parts = REPO_ROOT.parts | ||
| if "specfact-cli-worktrees" not in parts: | ||
| return None | ||
| marker_index = parts.index("specfact-cli-worktrees") | ||
| base = Path(*parts[:marker_index]) | ||
| suffix = Path(*parts[marker_index + 1 :]) | ||
| return base / "specfact-cli-modules-worktrees" / suffix | ||
|
|
||
|
|
||
| def _modules_repo_available() -> bool: | ||
| configured = os.environ.get("SPECFACT_MODULES_REPO", "").strip() | ||
| candidates = [ | ||
| Path(configured).expanduser() if configured else None, | ||
| REPO_ROOT.parent / "specfact-cli-modules", | ||
| _paired_worktree_modules_repo(), | ||
| ] | ||
| return any(candidate is not None and (candidate / "packages").is_dir() for candidate in candidates) | ||
|
|
||
|
|
||
| def test_generated_command_artifacts_exist() -> None: | ||
| for relative in GENERATED_ARTIFACTS: | ||
| assert (REPO_ROOT / relative).is_file(), f"Missing generated artifact: {relative}" | ||
|
|
||
|
|
||
| def test_llms_and_command_overview_are_current() -> None: | ||
| """llms.txt and the generated command reference must match the current CLI surface.""" | ||
| if not _modules_repo_available(): | ||
| pytest.skip("specfact-cli-modules packages checkout not available") | ||
|
|
||
| result = subprocess.run( | ||
| [sys.executable, str(GENERATOR), "--check"], | ||
| cwd=REPO_ROOT, | ||
| capture_output=True, | ||
| text=True, | ||
| check=False, | ||
| timeout=300, | ||
| ) | ||
| assert result.returncode == 0, ( | ||
| "Generated command artifacts (llms.txt, docs/reference/commands.generated.*) are stale. " | ||
| "Regenerate with 'hatch run generate-command-overview' and commit the result.\n" | ||
| f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.