Skip to content

fix(config): output filename not matching style option#949

Closed
pranc1ngpegasus wants to merge 2 commits intoyamadashy:mainfrom
pranc1ngpegasus:fix/output-filename-not-matching-style
Closed

fix(config): output filename not matching style option#949
pranc1ngpegasus wants to merge 2 commits intoyamadashy:mainfrom
pranc1ngpegasus:fix/output-filename-not-matching-style

Conversation

@pranc1ngpegasus
Copy link

Summary

Fix output filename not matching the style option. When using --style plain (or other non-default styles)
without explicitly specifying --output, the output filename now correctly matches the style (e.g.,
repomix-output.txt for plain, repomix-output.md for markdown).

Before:

repomix --style plain
# Output: repomix-output.xml (wrong extension)

After:

repomix --style plain
# Output: repomix-output.txt (correct extension)

Changes

  • Updated mergeConfigs function in src/config/configLoad.ts to automatically update the default output filename
    when the style is changed
  • Added comprehensive tests for all style options in tests/cli/actions/defaultAction.buildCliConfig.test.ts

Root Cause

The default config hardcodes filePath: 'repomix-output.xml'. When users specified --style plain, the style was
correctly set but the filename remained repomix-output.xml because the merge logic only updated the filename when
filePath was null, not when it was still the default value.

Technical Details

The fix checks if:

  1. filePath is not explicitly set (is null), OR
  2. filePath is still the default AND style has been changed from default

If either condition is true, the filename is automatically updated to match the style.

Note: Explicitly specified output filenames via --output are still respected regardless of the style option.

Checklist

  • Run npm run test
  • Run npm run lint

Copilot AI review requested due to automatic review settings November 14, 2025 13:18
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pranc1ngpegasus, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a configuration inconsistency where the default output filename's extension would not update to reflect the chosen output style if the user did not explicitly specify an output file. The change ensures that the system automatically aligns the output file extension with the selected style, providing a more intuitive and consistent user experience without requiring manual intervention for default cases.

Highlights

  • Output Filename Correction: The pull request fixes an issue where the default output filename extension did not correctly match the specified output style (e.g., --style plain resulting in .txt instead of .xml) when the --output flag was not explicitly provided.
  • Configuration Logic Update: The mergeConfigs function in src/config/configLoad.ts has been updated to intelligently determine if the default output filename should be adjusted based on the selected style, even if the filePath was not null but still held its initial default value.
  • Enhanced Test Coverage: Comprehensive new tests have been added to tests/cli/actions/defaultAction.buildCliConfig.test.ts to ensure that all style options (plain, xml, markdown, json) are correctly handled and reflected in the configuration.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where the output filename did not automatically update to match the selected style option. Previously, when users specified a style like --style plain, the output filename would incorrectly remain as repomix-output.xml instead of updating to repomix-output.txt.

Key Changes:

  • Modified the config merging logic to automatically update the output filename when the style is changed from default
  • Added comprehensive test coverage for all style options (plain, xml, markdown, json)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/config/configLoad.ts Updated mergeConfigs to detect when style changes from default and automatically update the output filename accordingly
tests/cli/actions/defaultAction.buildCliConfig.test.ts Added test cases for all supported style options to ensure proper style handling

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Update configLoad to reassign the default output file path not only when filePath is missing but also when the chosen style changes while the filePath remains the default. Add tests covering style handling and merge behavior for various style/filePath combinations.

Changes

Cohort / File(s) Summary
Config Loading Logic
src/config/configLoad.ts
Modify conditional that assigns a default output filePath: compute style = mergedOutput.style ?? baseConfig.output.style, isFilePathDefault = mergedOutput.filePath === baseConfig.output.filePath, isStyleChanged = style !== baseConfig.output.style, and assign defaultFilePathMap[style] when `mergedOutput.filePath == null
Unit tests — config merge
tests/config/configLoad.test.ts
Add tests for mergeConfigs covering combinations of output.style and output.filePath: style-driven default filePath assignment, preservation of explicit CLI/fileConfig paths, and default behavior when style is unspecified.
Unit tests — CLI build config
tests/cli/actions/defaultAction.buildCliConfig.test.ts
Add tests verifying buildCliConfig handles --style values (plain, xml, markdown, json) alongside existing tokenCountTree tests.

Sequence Diagram(s)

sequenceDiagram
    actor User
    User->>ConfigLoad: provide merged config + base config
    rect rgb(240, 248, 255)
    note over ConfigLoad: compute values
    ConfigLoad->>ConfigLoad: style = mergedOutput.style ?? baseConfig.output.style
    ConfigLoad->>ConfigLoad: isFilePathDefault = (mergedOutput.filePath === baseConfig.output.filePath)
    ConfigLoad->>ConfigLoad: isStyleChanged = (style !== baseConfig.output.style)
    end
    alt filePath is null OR (isFilePathDefault AND isStyleChanged)
        rect rgb(220, 245, 220)
        note over ConfigLoad: assign style-specific default filePath
        ConfigLoad->>ConfigLoad: mergedOutput.filePath = defaultFilePathMap[style]
        ConfigLoad->>ConfigLoad: log assigned default path
        end
    else otherwise
        note over ConfigLoad: keep existing filePath
    end
    ConfigLoad-->>User: return merged config
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to focus during review:
    • src/config/configLoad.ts — correctness of computed booleans (style, isFilePathDefault, isStyleChanged) and combined condition.
    • Test coverage in tests/config/configLoad.test.ts — ensure scenarios correctly exercise default reassignment vs. preserved paths.
    • tests/cli/actions/defaultAction.buildCliConfig.test.ts — verify CLI parsing of --style variants.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main fix: output filename now matches the selected style option.
Description check ✅ Passed The description is comprehensive with clear sections (Summary, Changes, Root Cause, Technical Details) and includes specific before/after examples and a completed checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug where the output filename did not match the chosen style when an explicit output file was not specified. The logic change in mergeConfigs is clear and effectively resolves the issue. My review includes feedback on the accompanying tests. While it's great that tests were added, they are repetitive and, more importantly, do not cover the core logic of the fix in mergeConfigs. I've provided suggestions to parameterize the existing tests for better maintainability and to add new unit tests to ensure the fix is robust and prevent future regressions.

Comment on lines +28 to +68
describe('style option', () => {
it('should handle plain style', () => {
const options: CliOptions = {
style: 'plain',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('plain');
});

it('should handle xml style', () => {
const options: CliOptions = {
style: 'xml',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('xml');
});

it('should handle markdown style', () => {
const options: CliOptions = {
style: 'markdown',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('markdown');
});

it('should handle json style', () => {
const options: CliOptions = {
style: 'json',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('json');
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Thank you for adding tests. These tests correctly verify that the style option from the CLI is passed to the config object. However, the core logic for the bug fix, which is in the mergeConfigs function in src/config/configLoad.ts, is not covered by these tests. The fix ensures the output filename is updated based on the style, and this behavior should be tested directly.

Please consider adding unit tests for the mergeConfigs function to cover the following scenarios:

  • When --style is provided without --output, the filePath is correctly updated to match the style's default extension.
  • When both --style and --output are provided, the explicitly provided filePath from --output is respected.
  • When a filePath is set in a config file, it is respected even if a different --style is provided via CLI.

This will ensure the fix is robust and prevent future regressions.

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 9421138

Comment on lines +28 to +68
describe('style option', () => {
it('should handle plain style', () => {
const options: CliOptions = {
style: 'plain',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('plain');
});

it('should handle xml style', () => {
const options: CliOptions = {
style: 'xml',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('xml');
});

it('should handle markdown style', () => {
const options: CliOptions = {
style: 'markdown',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('markdown');
});

it('should handle json style', () => {
const options: CliOptions = {
style: 'json',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('json');
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The tests for the style option are very similar and contain duplicated code. To improve maintainability and reduce boilerplate, you could use parameterized tests. Most test runners, including Vitest, support this feature (e.g., with it.each).

  describe('style option', () => {
    it.each(['plain', 'xml', 'markdown', 'json'] as const)('should handle %s style', (style) => {
      const options: CliOptions = {
        style,
      };

      const result = buildCliConfig(options);

      expect(result.output?.style).toBe(style);
    });
  });

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 9421138

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: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b84c36 and 29ec254.

📒 Files selected for processing (2)
  • src/config/configLoad.ts (1 hunks)
  • tests/cli/actions/defaultAction.buildCliConfig.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/cli/actions/defaultAction.buildCliConfig.test.ts (2)
src/cli/types.ts (1)
  • CliOptions (4-62)
src/cli/actions/defaultAction.ts (1)
  • buildCliConfig (114-296)
🔇 Additional comments (1)
src/config/configLoad.ts (1)

198-202: LGTM! Logic correctly fixes the output filename/style mismatch.

The updated condition properly handles the case where style is changed without an explicit output path. The logic preserves user-specified output filenames while auto-updating the default filename to match the selected style.

Key behaviors verified:

  • --style plain without --output now correctly generates repomix-output.txt instead of repomix-output.xml
  • Explicit --output custom.txt is preserved regardless of style ✓
  • File config style changes without filePath override now work correctly ✓

Comment on lines +28 to +68
describe('style option', () => {
it('should handle plain style', () => {
const options: CliOptions = {
style: 'plain',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('plain');
});

it('should handle xml style', () => {
const options: CliOptions = {
style: 'xml',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('xml');
});

it('should handle markdown style', () => {
const options: CliOptions = {
style: 'markdown',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('markdown');
});

it('should handle json style', () => {
const options: CliOptions = {
style: 'json',
};

const result = buildCliConfig(options);

expect(result.output?.style).toBe('json');
});
});
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 14, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Tests don't verify the actual bug fix: missing filePath assertions.

According to the PR objectives, the bug was that "when using non-default styles (e.g., --style plain previously produced repomix-output.xml; now produces repomix-output.txt for plain, repomix-output.md for markdown)." However, these tests only verify that the style property is set correctly—they don't verify that the output filename matches the style.

These tests would have passed even before the fix, so they don't provide confidence that the core bug is actually resolved.

Add assertions to verify the filePath for each style:

   describe('style option', () => {
     it('should handle plain style', () => {
       const options: CliOptions = {
         style: 'plain',
       };
 
       const result = buildCliConfig(options);
 
       expect(result.output?.style).toBe('plain');
+      expect(result.output?.filePath).toBe('repomix-output.txt');
     });
 
     it('should handle xml style', () => {
       const options: CliOptions = {
         style: 'xml',
       };
 
       const result = buildCliConfig(options);
 
       expect(result.output?.style).toBe('xml');
+      expect(result.output?.filePath).toBe('repomix-output.xml');
     });
 
     it('should handle markdown style', () => {
       const options: CliOptions = {
         style: 'markdown',
       };
 
       const result = buildCliConfig(options);
 
       expect(result.output?.style).toBe('markdown');
+      expect(result.output?.filePath).toBe('repomix-output.md');
     });
 
     it('should handle json style', () => {
       const options: CliOptions = {
         style: 'json',
       };
 
       const result = buildCliConfig(options);
 
       expect(result.output?.style).toBe('json');
+      expect(result.output?.filePath).toBe('repomix-output.json');
     });
+
+    it('should respect explicit output path regardless of style', () => {
+      const options: CliOptions = {
+        style: 'plain',
+        output: 'custom-output.xml',
+      };
+
+      const result = buildCliConfig(options);
+
+      expect(result.output?.style).toBe('plain');
+      expect(result.output?.filePath).toBe('custom-output.xml');
+    });
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe('style option', () => {
it('should handle plain style', () => {
const options: CliOptions = {
style: 'plain',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('plain');
});
it('should handle xml style', () => {
const options: CliOptions = {
style: 'xml',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('xml');
});
it('should handle markdown style', () => {
const options: CliOptions = {
style: 'markdown',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('markdown');
});
it('should handle json style', () => {
const options: CliOptions = {
style: 'json',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('json');
});
});
describe('style option', () => {
it('should handle plain style', () => {
const options: CliOptions = {
style: 'plain',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('plain');
expect(result.output?.filePath).toBe('repomix-output.txt');
});
it('should handle xml style', () => {
const options: CliOptions = {
style: 'xml',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('xml');
expect(result.output?.filePath).toBe('repomix-output.xml');
});
it('should handle markdown style', () => {
const options: CliOptions = {
style: 'markdown',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('markdown');
expect(result.output?.filePath).toBe('repomix-output.md');
});
it('should handle json style', () => {
const options: CliOptions = {
style: 'json',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('json');
expect(result.output?.filePath).toBe('repomix-output.json');
});
it('should respect explicit output path regardless of style', () => {
const options: CliOptions = {
style: 'plain',
output: 'custom-output.xml',
};
const result = buildCliConfig(options);
expect(result.output?.style).toBe('plain');
expect(result.output?.filePath).toBe('custom-output.xml');
});
});
🤖 Prompt for AI Agents
In tests/cli/actions/defaultAction.buildCliConfig.test.ts around lines 28 to 68,
the test cases only assert the style property and do not verify the output
filename, so they don't confirm the bugfix that output filePath changes per
style; update each test block to also assert result.output?.filePath (or the
correct property name used by buildCliConfig) equals the expected filename for
that style (e.g., repomix-output.txt for plain, repomix-output.xml for xml,
repomix-output.md for markdown, repomix-output.json for json), keeping existing
style assertions and using the same result variable.

Copy link
Author

Choose a reason for hiding this comment

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

fixed in 9421138

Copy link
Author

Choose a reason for hiding this comment

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

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 (1)
tests/config/configLoad.test.ts (1)

305-375: Excellent test coverage for style-based filename generation!

The new tests comprehensively validate the fix for automatic filename updates when style changes. The scenarios covered are:

  • Automatic filename updates for plain/markdown/json styles (tests at 305-315, 317-327, 329-339)
  • Preservation of explicit CLI output paths (341-351)
  • Preservation of file config paths (353-365)
  • Default behavior when no style specified (367-375)

Optional: Consider adding edge case tests

To further strengthen coverage, consider adding tests for these scenarios:

  1. File config with style but no filePath:
test('should update filePath when fileConfig has style but no filePath', () => {
  const fileConfig: RepomixConfigFile = {
    output: { style: 'plain' },
  };
  const cliConfig: RepomixConfigCli = {};

  const result = mergeConfigs(process.cwd(), fileConfig, cliConfig);

  expect(result.output.style).toBe('plain');
  expect(result.output.filePath).toBe('repomix-output.txt');
});
  1. CLI style overrides file config style:
test('should update filePath when CLI style overrides fileConfig style', () => {
  const fileConfig: RepomixConfigFile = {
    output: { style: 'plain' },
  };
  const cliConfig: RepomixConfigCli = {
    output: { style: 'markdown' },
  };

  const result = mergeConfigs(process.cwd(), fileConfig, cliConfig);

  expect(result.output.style).toBe('markdown');
  expect(result.output.filePath).toBe('repomix-output.md');
});

Optional: Consider test parameterization

Tests at lines 305-315, 317-327, and 329-339 follow a similar pattern and could be parameterized using test.each() to reduce duplication. However, the current explicit approach is also fine for readability.

test.each([
  { style: 'plain', expectedPath: 'repomix-output.txt' },
  { style: 'markdown', expectedPath: 'repomix-output.md' },
  { style: 'json', expectedPath: 'repomix-output.json' },
])('should update filePath to $expectedPath for $style style', ({ style, expectedPath }) => {
  const result = mergeConfigs(process.cwd(), {}, { output: { style } });
  expect(result.output.style).toBe(style);
  expect(result.output.filePath).toBe(expectedPath);
});
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29ec254 and 9421138.

📒 Files selected for processing (2)
  • tests/cli/actions/defaultAction.buildCliConfig.test.ts (1 hunks)
  • tests/config/configLoad.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/cli/actions/defaultAction.buildCliConfig.test.ts

@yamadashy
Copy link
Owner

Hi @pranc1ngpegasus!

Thank you so much for the detailed analysis of the issue and this fix PR!

I'm sorry, but #947 was submitted earlier with a similar fix, so we've prioritized that PR. Unfortunately, this means I won't be able to merge this PR.

I'm closing this, but I wanted to show my appreciation for your contribution with a small sponsorship.

Thank you again for taking the time to investigate and fix this issue! 🙏

@pranc1ngpegasus
Copy link
Author

Hi, @yamadashy !

Thanks for letting me know! No worries at all — I’m glad the issue got resolved, whether through my PR or another one.
I appreciate you taking the time to review my work and for the generous sponsorship — that really means a lot.
If there’s anything else I can help with in the future, feel free to ping me anytime! 🙏

@pranc1ngpegasus pranc1ngpegasus deleted the fix/output-filename-not-matching-style branch November 16, 2025 13:32
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.

3 participants