Skip to content

feat(output): Add options to control file summary and directory structure output#224

Merged
yamadashy merged 2 commits intomainfrom
feat/config-output-summary
Dec 29, 2024
Merged

feat(output): Add options to control file summary and directory structure output#224
yamadashy merged 2 commits intomainfrom
feat/config-output-summary

Conversation

@yamadashy
Copy link
Owner

Related: #206

Checklist

  • Run npm run test
  • Run npm run lint

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2024

📝 Walkthrough

Walkthrough

This pull request introduces two new configuration options, fileSummary and directoryStructure, to the Repomix tool. These options allow users to control the inclusion of file summaries and directory structures in the output. The changes span multiple files, including the README, configuration schema, and output generation files. The modifications primarily focus on enhancing the flexibility of output generation and updating terminology from "Repository Structure" to "Directory Structure" for improved clarity.

Changes

File Change Summary
README.md Updated terminology and added descriptions for new configuration options output.fileSummary and output.directoryStructure
repomix.config.json Added fileSummary and directoryStructure properties to the output section
src/config/configSchema.ts Added optional boolean properties fileSummary and directoryStructure to configuration schemas
src/core/output/outputStyles/* Modified output templates (Markdown, Plain, XML) to conditionally include file summaries and directory structures
src/core/output/outputStyleDecorate.ts Updated terminology from "Repository structure" to "Directory structure"
tests/* Updated test cases to reflect new configuration options and terminology changes

Suggested labels

enhancement

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Dec 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.07%. Comparing base (d17e8be) to head (8db9f95).
Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d17e8be and 8db9f95.

📒 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

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