feat(output): Add options to control file summary and directory structure output#224
feat(output): Add options to control file summary and directory structure output#224
Conversation
|
|
📝 WalkthroughWalkthroughThis pull request introduces two new configuration options, Changes
Suggested labels
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
==========================================
+ Coverage 92.05% 92.07% +0.02%
==========================================
Files 44 44
Lines 2052 2058 +6
Branches 450 450
==========================================
+ Hits 1889 1895 +6
Misses 163 163 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/core/output/outputStyles/xmlStyle.ts (1)
Line range hint
5-39: Ensure conditional file summary block is robust.The newly introduced
<file_summary>block is guarded by{{#if fileSummaryEnabled}}, which is good for enabling or disabling this section based on configuration. The content structure (purpose, file_format, usage_guidelines, notes, additional_info) effectively organizes the summary data.Consider documenting each sub-element (
<purpose>,<file_format>, etc.) somewhere in the code comments or a separate doc to ensure future maintainers understand their roles.src/core/output/outputStyles/markdownStyle.ts (1)
39-39: Block closure for directory structure.
Consistent with the handlebar syntax. Confirm that any nested blocks are well-indented for easier readability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
README.md(5 hunks)repomix.config.json(1 hunks)src/config/configSchema.ts(2 hunks)src/core/output/outputGenerate.ts(1 hunks)src/core/output/outputStyleDecorate.ts(1 hunks)src/core/output/outputStyles/markdownStyle.ts(2 hunks)src/core/output/outputStyles/plainStyle.ts(2 hunks)src/core/output/outputStyles/xmlStyle.ts(3 hunks)tests/cli/actions/defaultAction.test.ts(1 hunks)tests/cli/cliRun.test.ts(1 hunks)tests/config/configSchema.test.ts(2 hunks)tests/core/output/outputStyles/markdownStyle.test.ts(5 hunks)tests/core/output/outputStyles/plainStyle.test.ts(1 hunks)tests/core/output/outputStyles/xmlStyle.test.ts(1 hunks)tests/integration-tests/fixtures/packager/outputs/simple-project-output.txt(3 hunks)tests/integration-tests/fixtures/packager/outputs/simple-project-output.xml(4 hunks)
✅ Files skipped from review due to trivial changes (2)
- src/core/output/outputStyleDecorate.ts
- tests/integration-tests/fixtures/packager/outputs/simple-project-output.txt
🔇 Additional comments (30)
tests/core/output/outputStyles/xmlStyle.test.ts (1)
29-31: Validate new XML tag usage in tests.
By verifying the presence of "directory_structure" (line 29) and "files" (line 31), these assertions confirm that the test correctly checks for the newly introduced XML tags. This aligns with the updated output format, ensuring consistency with the renamed elements in the codebase.
tests/core/output/outputStyles/plainStyle.test.ts (1)
29-31: Check updated naming conventions in plain text output.
The introduction of "Directory Structure" (line 29) and "Files" (line 31) confirms the shift away from the older terminology. This test ensures that the plain-style output reflects the new naming, in line with the latest configuration options.
src/core/output/outputStyles/xmlStyle.ts (2)
41-45: Confirm directory structure flag usage.
The conditional block {{#if directoryStructureEnabled}} properly controls the <directory_structure> tag. This ensures the XML output remains flexible for users who might not need a directory overview.
Line range hint 47-56: Validate <files> block consistency.
Renaming <repository_files> to <files> aligns with the pull request’s objective. Including all processed files under <files> is clear and consistent with naming updates. The new structure remains intuitive for parsing or inspection in downstream processes.
src/core/output/outputStyles/plainStyle.ts (3)
Line range hint 8-44: Introduce conditional file summary for plain text.
Wrapping the file summary section with {{#if fileSummaryEnabled}} adds flexibility. The headings (“Purpose,” “File Format,” “Usage Guidelines,” etc.) provide a good hierarchy for the text-based summary.
46-51: Confirm conditional directory structure content.
Guarding “Directory Structure” with {{#if directoryStructureEnabled}} ensures that users can opt in or out of directory overviews. This mirrors the same logic used for the XML variant, maintaining consistency across formats.
54-54: Renamed “Files” section for clarity.
Switching from “Repository Files” to “Files” is consistent with the rest of the code changes. The plain style now matches the new terminology found elsewhere in the project.
src/config/configSchema.ts (2)
22-23: Good addition for configurability.
The introduction of fileSummary and directoryStructure as optional booleans in the base schema is a straightforward and useful extension, allowing greater control over output. Implementation here looks solid.
55-56: Consistent defaults enhance usability.
Providing default values of true for fileSummary and directoryStructure in the default schema ensures that new users immediately benefit from these features, while existing code remains unharmed if it doesn't specify them. This is an excellent choice for developer experience.
src/core/output/outputGenerate.ts (1)
37-38: Convenient flags for conditional rendering.
Extracting fileSummaryEnabled and directoryStructureEnabled from the config is a neat way to control whether you display file summaries or directory structures. This approach keeps the main rendering logic clean, as the code can now easily check for these flags before generating respective sections.
tests/cli/actions/defaultAction.test.ts (1)
24-25: Test coverage for new config options.
Including fileSummary and directoryStructure in the merged config helps ensure that the default action handles these new properties. This test update is well-aligned with the new functionality, improving coverage for these options.
tests/cli/cliRun.test.ts (1)
50-51: Mocked output config supports new features.
Declaring fileSummary and directoryStructure in the mocked default action response is crucial for validating that the CLI behaves correctly when these features are enabled. Nicely done.
tests/config/configSchema.test.ts (2)
67-68: Confirm alignment with default schema requirements.
These new properties (fileSummary and directoryStructure) look correct and match the schema updates. Ensure that any default values in other files (like repomix.config.json) are aligned consistently.
147-148: Validate merged schema with new fields.
Introducing fileSummary and directoryStructure in the merged schema should work seamlessly if the base and default schemas support these properties. Confirm that merging logic handles these new fields properly (e.g., fallback to true if absent).
tests/core/output/outputStyles/markdownStyle.test.ts (5)
10-11: Updated headers match new terminology.
The change from "Repository Structure" to "Directory Structure" and from "Repository Files" to "Files" is clear and consistent with the new configuration flags.
33-34: Check that flags correctly enable summary sections.
These flags (fileSummaryEnabled and directoryStructureEnabled) ensure that the generated Markdown sections are conditional. Tests appear correct.
56-57: Ensuring fileSummaryEnabled and directoryStructureEnabled consistency.
This test properly verifies that user-provided header text is displayed only when these flags are enabled. Good job!
71-72: Validation for absent header text.
With both flags enabled, the header is still omitted unless explicitly provided, which is the desired behavior. Looks good.
86-87: Verify instruction section toggling.
The test checks that instructions are displayed when these flags are active. Implementation is consistent with the new design.
repomix.config.json (1)
7-8: New properties for output control.
Adding "fileSummary": true and "directoryStructure": true by default is a sensible choice to provide comprehensive output.
src/core/output/outputStyles/markdownStyle.ts (4)
7-7: Conditional file summary section.
Wrapping the file summary in {{#if fileSummaryEnabled}} is a straightforward way to give users control. Implementation is clear.
32-32: Proper block closure for file summary.
Closing the conditional block here ensures clarity and maintainability. Keep up the clean structure.
34-35: Conditional directory structure rendering.
Using {{#if directoryStructureEnabled}} gives the user control over the directory structure output. Great approach.
41-41: Unified “Files” heading.
Renaming the heading to “Files” aligns well with the rest of the changes. This maintains consistent terminology.
tests/integration-tests/fixtures/packager/outputs/simple-project-output.xml (3)
16-16: LGTM! Terminology update improves clarity.
The change from "Repository Structure" to "Directory structure" in the file format section makes the purpose clearer and more intuitive.
Line range hint 50-61: LGTM! Tag renamed for consistency.
The XML tag has been appropriately renamed from repository_structure to directory_structure, maintaining consistency with the updated terminology.
Line range hint 63-147: LGTM! Tag simplified while maintaining clarity.
The XML tag has been simplified from repository_files to files while maintaining clear context within the XML structure.
README.md (3)
Line range hint 165-177: LGTM! Plain text format updated consistently.
The plain text format example has been updated to use the new "Directory Structure" terminology while maintaining a clear and well-structured format.
214-229: LGTM! XML format example accurately updated.
The XML format example has been updated to reflect the new tag names, maintaining consistency with the actual output format.
361-362: LGTM! New configuration options well-documented.
The new fileSummary and directoryStructure options are clearly documented with appropriate default values and are correctly demonstrated in the example configuration.
Also applies to: 383-384
Related: #206
Checklist
npm run testnpm run lint