CLI: Zap working tree building by establishing cratedb-about build#16
CLI: Zap working tree building by establishing cratedb-about build#16
cratedb-about build#16Conversation
WalkthroughThis update introduces a new build system for generating Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI (cratedb-about)
participant LllmsTxtBuilder
participant FileSystem
participant Shell
User->>CLI (cratedb-about): cratedb-about build --outdir <path>
CLI (cratedb-about)->>LllmsTxtBuilder: run(outdir)
LllmsTxtBuilder->>FileSystem: Ensure output directory exists
LllmsTxtBuilder->>FileSystem: Copy resource files (md, yaml)
LllmsTxtBuilder->>Shell: Run "cratedb-about outline" to generate outline.md
LllmsTxtBuilder->>Shell: Run "llms_txt2ctx" to generate llms.txt and llms-full.txt
LllmsTxtBuilder->>CLI (cratedb-about): Log build progress
CLI (cratedb-about)->>User: Print "Ready."
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (8)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
.github/workflows/tests.yml (1)
39-40: 💡 Verification agent🧩 Analysis chain
Verify if 'sponge' is still needed in the workflow.
Since you've moved from the old build process to a new CLI command, is the
spongeutility still required? If it was only used in the removedpoe buildtask, consider removing this installation step.
🏁 Script executed:
#!/bin/bash # Check if sponge is still used in the codebase # Search for sponge usage in Python files echo "Looking for sponge usage in Python files:" rg "sponge" --type py # Search for sponge usage in shell scripts or other files echo "Looking for sponge usage in other files:" rg "sponge" --type-not pyLength of output: 231
Remove unused
spongeinstallationNo references to
spongewere found anywhere in the codebase, so you can safely delete the installation step in your CI workflow.• File: .github/workflows/tests.yml
Lines 39–40 – remove the following:- - name: Install `sponge` - run: sudo apt-get --yes install moreutils
🧹 Nitpick comments (4)
CHANGES.md (1)
9-10: Changelog entry needs a grammatical correction.There's a minor grammar issue in the changelog entry.
- CLI: Zapped working tree building by establishing new `cratedb-about build` + CLI: Zapped working tree building by establishing a new `cratedb-about build`🧰 Tools
🪛 LanguageTool
[uncategorized] ~9-~9: You might be missing the article “a” here.
Context: ...d working tree building by establishing newcratedb-about buildsubcommand ## ...(AI_EN_LECTOR_MISSING_DETERMINER_A)
tests/test_cli.py (2)
62-76: New test added for the 'build' command.The test covers basic functionality by verifying exit code and expected log messages. Consider enhancing it to verify the actual output files are created correctly.
def test_cli_build(caplog, tmp_path): runner = CliRunner() result = runner.invoke( cli, args=["build"], env={"OUTDIR": str(tmp_path)}, catch_exceptions=False, ) assert result.exit_code == 0, result.output assert "Building llms-txt" in caplog.text assert "Dumping outline source file" in caplog.text assert "Generating llms-txt files" in caplog.text assert "Ready." in caplog.text + + # Verify that the expected output files are created + assert (tmp_path / "llms.txt").exists() + assert (tmp_path / "llms-full.txt").exists()
62-76: Consider adding tests for error scenarios.The current test only covers the happy path. Consider adding tests for error cases, such as when OUTDIR is not set or points to a non-existent directory.
def test_cli_build_without_outdir(): runner = CliRunner() # Test without OUTDIR environment variable result = runner.invoke( cli, args=["build"], env={}, # No OUTDIR set catch_exceptions=False, ) # Verify appropriate error handling assert result.exit_code != 0 assert "Error" in result.output or "OUTDIR" in result.outputsrc/cratedb_about/build/llmstxt.py (1)
20-43: Add error handling for build operations.The current implementation doesn't handle potential errors during file operations or command execution. Adding try-except blocks would make the build process more robust.
def run(self): logger.info(f"Building llms-txt. Output directory: {self.outdir}") - self.outdir.mkdir(parents=True, exist_ok=True) + try: + self.outdir.mkdir(parents=True, exist_ok=True) + except Exception as e: + logger.error(f"Failed to create output directory: {e}") + raise logger.info("Copying source and documentation files") - shutil.copy( - str(resources.files("cratedb_about.build") / "llmstxt-about.md"), - self.outdir / "readme.md", - ) - shutil.copy( - str(resources.files("cratedb_about.outline") / "cratedb-outline.yaml"), - self.outdir / "outline.yaml", - ) + try: + shutil.copy( + str(resources.files("cratedb_about.build") / "llmstxt-about.md"), + self.outdir / "readme.md", + ) + shutil.copy( + str(resources.files("cratedb_about.outline") / "cratedb-outline.yaml"), + self.outdir / "outline.yaml", + ) + except Exception as e: + logger.error(f"Failed to copy resource files: {e}") + raise # ... similar error handling for command execution
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.github/workflows/tests.yml(1 hunks)CHANGES.md(1 hunks)README.md(2 hunks)docs/sandbox.md(1 hunks)pyproject.toml(2 hunks)src/cratedb_about/build/llmstxt.py(1 hunks)src/cratedb_about/cli.py(3 hunks)tests/test_cli.py(1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGES.md
[uncategorized] ~9-~9: You might be missing the article “a” here.
Context: ...d working tree building by establishing new cratedb-about build subcommand ## ...
(AI_EN_LECTOR_MISSING_DETERMINER_A)
🔇 Additional comments (14)
docs/sandbox.md (1)
9-13: Documentation updated to reflect new build process correctly.The instructions now clearly show the two-step process required to rebuild
llms.txtfiles using the new CLI command, which aligns with the PR objective of making the build process self-contained..github/workflows/tests.yml (1)
58-58: Successfully updated dependencies to include 'all' group.Adding the 'all' optional dependency group ensures that all required dependencies are installed for testing the new build command.
pyproject.toml (3)
74-77: Good dependency management update!Adding colorlog for enhanced logging capabilities and specifying pueblo version will help maintain consistent behavior.
79-81: Well-structured dependency organization!Moving LLM-related dependencies to optional groups makes the package more modular, allowing users to install only what they need. This aligns perfectly with the PR objective of making the
llms.txtgeneration more self-contained.Also applies to: 89-92
108-111: Good addition to package data!Including
*.mdfiles alongside*.yamlensures that all necessary resources are properly packaged, which supports the new self-contained build system.README.md (2)
26-26: Good update to installation instructions!The updated installation command correctly includes the
[all]extra, which aligns with the dependency changes in pyproject.toml.
60-68: Clear documentation for new build functionality!The new "llms-txt" subsection with build instructions clearly communicates how to use the new CLI command, making the documentation consistent with the code changes.
src/cratedb_about/build/llmstxt.py (2)
1-19: Good implementation of builder class structure!The use of dataclasses and proper logging setup is good practice. The noqa comment for S605 is noted, as it's related to the shell commands used later.
20-33: Well-implemented resource management!The creation of the output directory and copying of resource files is handled properly using appropriate methods from standard libraries.
src/cratedb_about/cli.py (5)
1-8: Good import organization!The added imports for logging, Path, boot_click, and LllmsTxtBuilder are properly organized and necessary for the new functionality.
13-14: Good logger setup!Adding a logger instance follows best practices for Python applications.
19-20: Good CLI initialization!Replacing the no-op pass with boot_click provides better CLI initialization.
44-53: Well-implemented build command!The new build command is well-structured with:
- A clear docstring
- Proper environment variable support via envvar="OUTDIR"
- Required output directory parameter
- Simple integration with the LllmsTxtBuilder class
- Appropriate logging
This implementation achieves the PR's objective of making the llms.txt building process a self-contained CLI command.
27-27: Good type annotation additions!Adding return type annotations to all command functions improves code quality and maintainability.
Also applies to: 58-58, 82-82
About
Build the
llms.txtself-contained so it doesn't need the repository.